Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
design_management.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset_management.inc';
19 
31 {
32 
33 
39  {
40  Asset_Management::__construct($pm);
41 
42  $this->vars = Array(
43  'id_name' => Array(
44  'added' => '0.0.1',
45  'type' => 'text',
46  'default' => '',
47  ),
48  'wysiwyg_classes' => Array(
49  'added' => '0.2',
50  'type' => 'serialise',
51  'default' => Array(),
52  'description' => 'Use saved classes in the wysiwyg dropdown list',
53  ),
54  'div_classes' => Array(
55  'added' => '0.2',
56  'type' => 'serialise',
57  'default' => Array(),
58  'description' => 'Use saved classes in the DIV container properties class dropdown',
59  ),
60  'limbo_no_frames' => Array(
61  'added' => '0.1',
62  'type' => 'boolean',
63  'default' => FALSE,
64  'parameters' => Array (
65  'allow_empty' => FALSE,
66  ),
67  'description' => 'LIMBO no frame options for each design, not using frames while inside LIMBO mode',
68  ),
69  'static_url_versioning' => Array(
70  'added' => '0.3',
71  'type' => 'boolean',
72  'default' => TRUE,
73  'parameters' => Array('allow_empty' => FALSE),
74  )
75  );
76 
77  }//end constructor
78 
79 
88  function _upgrade($current_version)
89  {
90  // first do things as normal
91  $res = parent::_upgrade($current_version);
92 
93  if (version_compare($current_version, '0.3', '<')) {
94  pre_echo('UPGRADING DESIGN FROM v < 0.3');
95 
96  // get all design assets
97  $design_ids = $GLOBALS['SQ_SYSTEM']->am->getTypeAssetids('design', TRUE, TRUE);
98  foreach ($design_ids as $design_id => $type) {
99  $design = $GLOBALS['SQ_SYSTEM']->am->getAsset($design_id, $type['type_code']);
100  $design->setAttrValue('static_url_versioning', FALSE);
101  $design->saveAttributes();
102  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($design);
103  unset($design);
104  }
105 
106  }//end if
107 
108 
109  if (version_compare($current_version, '0.4', '<')) {
110  pre_echo('UPGRADING DESIGN FROM v < 0.4');
111 
112  // regenerate all design assets
113  $design_ids = $GLOBALS['SQ_SYSTEM']->am->getTypeAssetids('design', TRUE, TRUE);
114  foreach ($design_ids as $design_id => $type) {
115  $vars = Array('assetid' => $design_id);
116  $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
117  $hh->freestyleHipo('hipo_job_regenerate_design', $vars);
118  }
119 
120  }//end if
121 
122  if (version_compare($current_version, '0.5', '<')) {
123  pre_echo('UPGRADING DESIGN FROM v < 0.5');
124 
125  $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
126  $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
127  $sql = 'UPDATE sq_ast_lnk SET is_exclusive = \'1\' WHERE link_type = \'2\' AND value = \'customisation\' AND minorid IN ';
128  $sql .= '(SELECT assetid from sq_ast WHERE type_code = \'design_customisation\')';
129  try {
130  $result = MatrixDAL::executeSql($sql);
131  } catch (Exception $e) {
132  throw new Exception('Failed to get package information for package "'.$package_name.'" due to database error: '.$e->getMessage());
133  }
134  $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
135  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
136 
137  }//end if
138 
139  return TRUE;
140 
141  }//end _upgrade()
142 
143 
144 }//end class
145 
146 
147 ?>