Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
layout_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  'name' => Array(
44  'added' => '0.0.1',
45  'type' => 'text',
46  'default' => '',
47  ),
48  'options' => Array(
49  'added' => '0.2',
50  'type' => 'serialise',
51  'default' => Array(
52  'show_cascade_metadata_field' => FALSE,
53  ),
54  ),
55 
56  );
57 
58  }//end constructor
59 
60 
67  public function getEventList()
68  {
69  return Array(
70  Array(
71  'event_name' => 'requestKeywords',
72  'broadcast_type_code' => 'content_type',
73  'broadcast_strict_type_code' => FALSE,
74  'options' => Array(
75  'side_of_link' => 'major',
76  'indirect' => TRUE,
77  'is_exclusive' => NULL,
78  'is_dependant' => 1,
79  'value' => '',
80  'link_type' => SQ_LINK_TYPE_2 | SQ_LINK_TYPE_1,
81  ),
82  ),
83  );
84 
85  }//end getEventList()
86 
87 
95  public function _getFileList()
96  {
97  return Array(
98  'popups/print_limbo_keywords.php',
99  );
100 
101  }//end _getFileList()
102 
103 
112  public function _upgrade($current_version)
113  {
114  if (!parent::_upgrade($current_version)) return FALSE;
115 
116  $asset_name = strtoupper($this->_pm->getTypeInfo($this->getAssetType(), 'name'));
117  $am = $GLOBALS['SQ_SYSTEM']->am;
118 
119  if (version_compare($current_version, '0.2', '<')) {
120  // version 0.1 -> 0.2
121  pre_echo('STARTING '.$asset_name.' UPGRADE - TO VERSION 0.2');
122 
123  $default_val = Array('show_cascade_metadata_field' => FALSE);
124 
125  $pages = $GLOBALS['SQ_SYSTEM']->am->getTypeAssetids($this->getAssetType(), TRUE, TRUE);
126 
127  foreach ($pages as $assetid => $type_code) {
128  $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid, $type_code['type_code']);
129  if (is_null($asset)) continue;
130  echo 'Upgrading Asset #'.$assetid."...\n";
131 
132  // Add "options" attribute to existing Layout assets
133 
134  if (!$asset->setAttrValue('options', $default_val)) {
135  echo 'Asset #', $asset->id, ' (', $asset->name,') Could not add "options" attribute to existing Layout', "\n";
136  continue;
137  }
138 
139  if (!$asset->saveAttributes()) {
140  echo 'Asset #', $asset->id, ' (', $asset->name,') Unable to save attributes', "\n";
141  continue;
142  }
143  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($asset);
144  unset($asset);
145  }//end foreach
146  pre_echo($asset_name.' UPGRADE COMPLETE - TO VERSION 0.2');
147 
148  }//end if - upgrade to version 0.2
149 
150  return TRUE;
151 
152  }//end _upgrade()
153 
154 
155 }//end class
156 ?>