Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
content_type_nest_content_management.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset_management.inc';
19 
31 {
32 
33 
38  function __construct(&$pm)
39  {
40  $this->Asset_Management($pm);
41 
42  $this->vars['paint_with'] = Array(
43  'type' => 'text',
44  'default' => 'raw',
45  'added' => '0.2',
46  );
47 
48  $this->vars['additional_get'] = Array(
49  'type' => 'serialise',
50  'default' => Array(),
51  'added' => '0.4',
52  );
53 
54  $this->vars['dynamic_nest_get'] = Array(
55  'type' => 'text',
56  'default' => '',
57  'added' => '0.4',
58  );
59 
60  }//end constructor
61 
62 
71  function _upgrade($current_version)
72  {
73  if (!parent::_upgrade($current_version)) return FALSE;
74 
75  $asset_name = strtoupper($this->_pm->getTypeInfo($this->getAssetType(), 'name'));
76 
77  if (version_compare($current_version, '0.3', '<') &&
78  (version_compare($current_version, '0.1', '<=') ||
79  version_compare($current_version, '0.2', '>=')) ) {
80 
81  pre_echo('STARTING '.$asset_name.' UPGRADE - TO VERSION 0.3');
82 
83  // get all 'bodycopy_container' assets (or their descendants)
84  $content_type_nested_content_ids = $GLOBALS['SQ_SYSTEM']->am->getTypeAssetIds($this->getAssetType(), FALSE);
85  pre_echo('Upgrading '.count($content_type_nested_content_ids).' assets...');
86  foreach ($content_type_nested_content_ids as $assetid) {
87  $content_type_nested_content_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid);
88 
89  // reasonably critical upgrade - report any assets that didn't make it
90  if (is_null($content_type_nested_content_asset)) {
91  pre_echo('Could get asset #'.$assetid);
92  continue;
93  }
94 
95  // Get all the bodycopy_container which are the parents of this asset.
96  $parent_container_ids = $GLOBALS['SQ_SYSTEM']->am->getDependantParents($content_type_nested_content_asset->id, 'bodycopy_div');
97  if (!empty($parent_container_ids)) {
98  foreach ($parent_container_ids as $container_id) {
99  $container = $GLOBALS['SQ_SYSTEM']->am->getAsset($container_id);
100  // regenerate the bodycopy_container's content file
101  $container_edit_fns = $container->getEditFns();
102  if (!$container_edit_fns->generateContentFile($container)) {
103  pre_echo('Could not generate content file for container asset #'.$assetid);
104  }
105  unset($container_edit_fns);
106 
107  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($container);
108  }
109  }
110  $GLOBALS['SQ_SYSTEM']->am->forgetAsset($content_type_nested_content_asset);
111  }
112  pre_echo($asset_name.' UPGRADE COMPLETE - FROM VERSION '.$current_version.' TO 0.3');
113 
114  }//end version 0.3 upgrade
115 
116  return TRUE;
117 
118  }//end _upgrade()
119 
120 
121 }//end class
122 
123 ?>