18 require_once SQ_INCLUDE_PATH.
'/asset_management.inc';
43 'duration_from' => Array(
46 'parameters' => Array(
47 'allow_negative' => TRUE,
50 'duration_to' => Array(
53 'parameters' => Array(
54 'allow_negative' => TRUE,
57 'day_filter' => Array(
58 'type' =>
'selection',
68 'parameters' => Array(
70 'Sun' => translate(
'sunday'),
71 'Mon' => translate(
'monday'),
72 'Tue' => translate(
'tuesday'),
73 'Wed' => translate(
'wednesday'),
74 'Thu' => translate(
'thursday'),
75 'Fri' => translate(
'friday'),
76 'Sat' => translate(
'saturday'),
79 'allow_empty' => FALSE,
83 'type' =>
'selection',
85 'parameters' => Array(
87 'days' => translate(
'days'),
88 'weeks' => translate(
'weeks'),
89 'months' => translate(
'months'),
91 'allow_empty' => FALSE,
94 'root_nodes' => Array(
95 'type' =>
'serialise',
100 'type' =>
'serialise',
102 'calendar_event_single' => 0,
103 'calendar_event_recurring' => 0,
108 $this->components = Array(
109 'short_name' => Array(
110 'description' =>
'Short Name',
111 'default_weighting' =>
'1',
128 'event_name' =>
'requestKeywords',
129 'broadcast_type_code' =>
'content_type',
130 'broadcast_strict_type_code' => FALSE,
132 'side_of_link' =>
'major',
134 'is_exclusive' => NULL,
137 'link_type' => SQ_LINK_TYPE_2 | SQ_LINK_TYPE_1,
155 if (!parent::_upgrade($current_version))
return FALSE;
157 $asset_name = strtoupper($this->_pm->getTypeInfo($this->getAssetType(),
'name'));
158 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
161 if (version_compare($current_version,
'0.2',
'<')) {
163 pre_echo(
'STARTING '.$asset_name.
' UPGRADE - FROM VERSION 0.1');
164 $pages = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids($this->
getAssetType(), FALSE, TRUE);
165 foreach ($pages as $assetid => $type_code) {
166 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $type_code);
167 if (is_null($asset))
continue;
171 if (!$asset->setAttrValue(
'days_from', ($asset->attr(
'days_past') * -1)) || !$asset->setAttrValue(
'days_to', $asset->attr(
'days_future'))) {
172 echo
'Asset #', $asset->id,
' (', $asset->name,
') Unable to convert old past and/or future values',
"\n";
176 if (!$asset->saveAttributes()) {
177 echo
'Asset #', $asset->id,
' (', $asset->name,
') Unable to save attributes',
"\n";
180 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
183 pre_echo($asset_name.
' UPGRADE COMPLETE - FROM VERSION 0.1');
188 if (version_compare($current_version,
'0.3',
'<')) {
190 pre_echo(
'STARTING '.$asset_name.
' UPGRADE - FROM VERSION '.$current_version);
192 $am->includeAsset(
'bodycopy');
194 $pages = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids($this->
getAssetType(), TRUE, TRUE);
195 foreach ($pages as $assetid => $type_code) {
196 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $type_code);
197 if (is_null($asset))
continue;
199 echo
'Upgrading Asset #'.$assetid.
"...\n";
202 if (!$asset->setAttrValue(
'duration_from', $asset->attr(
'days_from')) || !$asset->setAttrValue(
'duration_to', $asset->attr(
'days_to'))) {
203 echo
'Asset #', $asset->id,
' (', $asset->name,
') Unable to convert old days_from and/or days_to values',
"\n";
208 $date_format = $asset->attr(
'day_heading_format');
210 for ($ii = 0; $ii < strlen($date_format); $ii++) {
211 if (preg_match(
'/[[:alpha:]]/', $date_format[$ii]) && ($ii == 0 || $date_format[$ii - 1] !=
'\\')) {
212 $heading_date .=
'%time_unit_start_datetime_'.$date_format[$ii].
'%';
213 }
else if ($date_format[$ii] !=
'\\') {
214 $heading_date .= $date_format[$ii];
217 $heading = $asset->attr(
'day_heading_tag');
218 $unit_format =
'<'.$heading.
'>'.$heading_date.
'</'.$heading.
'>'.
"\n".
'%time_unit_event_list%';
225 'link_type' => SQ_LINK_TYPE_2,
228 'value' =>
'time_unit',
231 $time_unit_details = array_get_index($asset->bodycopies,
'time_unit', Array());
232 $bodycopy->setAttrValue(
'name', array_get_index($time_unit_details,
'name'));
233 if (!$bodycopy->create($link, Array(
'content' => $unit_format))) {
234 echo
'Asset #', $asset->id,
' (', $asset->name,
') Could not create Time Unit bodycopy',
"\n";
238 if (!$asset->saveAttributes()) {
239 echo
'Asset #', $asset->id,
' (', $asset->name,
') Unable to save attributes',
"\n";
242 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
248 $GLOBALS[
'ROLLING_CAL_PAGE_UPGRADED_TO_03'] = 1;
250 pre_echo($asset_name.
' UPGRADE COMPLETE - FROM VERSION 0.2');
254 if (version_compare($current_version,
'0.4',
'<')) {
256 pre_echo(
'STARTING '.$asset_name.
' UPGRADE - FROM VERSION '.$current_version);
259 $pages = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids($this->
getAssetType(), FALSE, TRUE);
260 foreach ($pages as $assetid => $type_code) {
261 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $type_code);
262 if (is_null($asset))
continue;
264 $tf_folder_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($assetid, SQ_LINK_TYPE_2,
'folder', TRUE,
'',
'major', TRUE);
265 if ($tf_folder_link[
'value'] !=
'type_formats') {
266 $GLOBALS[
'SQ_SYSTEM']->am->updateLink($tf_folder_link[
'linkid'], SQ_LINK_TYPE_2,
'type_formats');
269 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
272 pre_echo($asset_name.
' UPGRADE COMPLETE - FROM VERSION 0.3');