17 require_once SQ_INCLUDE_PATH.
'/asset_management.inc';
45 $this->vars[
'create_type'] = Array(
47 'type' =>
'serialise',
51 $this->vars[
'create_form_customisations'] = Array(
53 'type' =>
'serialise',
57 $this->vars[
'create_status'] = Array(
63 $this->vars[
'required_fields'] = Array(
65 'type' =>
'serialise',
69 $this->vars[
'link_value'] = Array(
79 $this->vars[
'create_location'] = Array(
81 'type' =>
'serialise',
97 $this->vars[
'create_location_optional'] = Array(
99 'type' =>
'serialise',
100 'default' => Array(),
125 $this->vars[
'create_location_dynamic'] = Array(
127 'type' =>
'serialise',
128 'default' => Array(),
143 $this->vars[
'create_location_rules'] = Array(
145 'type' =>
'serialise',
146 'default' => Array(),
152 $this->vars[
'login_invite'] = Array(
155 'default' =>
'<p>Sign in using the form below.</p>',
156 'is_contextable' => TRUE,
158 $this->vars[
'login_error'] = Array(
161 'default' =>
'<p>Incorrect username or password entered. Please try again.</p>',
162 'is_contextable' => TRUE,
164 $this->vars[
'create_invite'] = Array(
167 'default' =>
'<p>Create an asset using the form below.</p>',
168 'is_contextable' => TRUE,
170 $this->vars[
'create_error'] = Array(
173 'default' =>
'<p>The new asset was not created. Ensure you have entered all required information and try again.</p>',
174 'is_contextable' => TRUE,
178 $this->vars[
'additional_location_parents'] = Array(
180 'type' =>
'serialise',
181 'default' => Array(),
185 $this->vars[
'additional_location_default_link_type'] = Array(
187 'type' =>
'selection',
188 'default' => SQ_LINK_TYPE_1,
189 'parameters' => Array(
191 SQ_LINK_TYPE_1 =>
'TYPE_1',
192 SQ_LINK_TYPE_2 =>
'TYPE_2',
193 SQ_LINK_TYPE_3 =>
'TYPE_3',
194 SQ_LINK_NOTICE =>
'NOTICE',
198 'allow_empty' => FALSE,
202 $this->vars[
'additional_location_types'] = Array(
204 'type' =>
'serialise',
205 'default' => Array(),
209 $this->vars[
'parameter_map'] = Array(
211 'type' =>
'parameter_map',
212 'parameters' => Array(
213 'parameters' => Array(
214 'additional_locations' =>
'Additional Create Locations',
217 'default' => Array(),
220 $this->vars[
'allow_public_user'] = Array(
224 'parameters' => Array(
225 'allow_empty' => FALSE,
229 $this->vars[
'submit_to_page_url'] = Array(
233 'parameters' => Array(
234 'allow_empty' => FALSE,
237 $this->vars[
'require_captcha'] = Array(
240 'parameters' => Array(
241 'allow_empty' => FALSE,
244 $this->vars[
'captcha_length'] = Array(
249 $this->vars[
'captcha_zoom'] = Array(
254 $this->vars[
'captcha_link_text'] = Array(
257 'default' =>
'Regenerate security key',
260 $this->vars[
'captcha_bgcolour'] = Array(
263 'default' =>
'FFFFFF',
266 $this->vars[
'captcha_textcolour'] = Array(
269 'default' =>
'000000',
272 $this->vars[
'captcha_bordercolour'] = Array(
275 'default' =>
'000000',
278 $this->vars[
'captcha_use_colours'] = Array(
281 'parameters' => Array(
282 'allow_empty' => FALSE,
286 $this->vars[
'captcha_usefont'] = Array(
289 'parameters' => Array(
290 'allow_empty'=> FALSE,
294 $this->vars[
'captcha_ttf'] = Array(
298 'description' =>
'The asset id of the font file.',
301 $this->vars[
'captcha_font_size'] = Array(
307 $this->vars[
'captcha_min_angle'] = Array(
313 $this->vars[
'captcha_max_angle'] = Array(
319 $this->vars[
'captcha_x_start'] = Array(
325 $this->vars[
'captcha_min_distance'] = Array(
331 $this->vars[
'captcha_max_distance'] = Array(
337 $this->vars[
'captcha_width'] = Array(
343 $this->vars[
'captcha_height'] = Array(
349 $this->vars[
'captcha_arc'] = Array(
352 'parameters'=> Array(
353 'allow_empty'=> FALSE,
357 $this->vars[
'captcha_arc_colour'] = Array(
360 'default'=>
'D20A0A',
363 $this->vars[
'captcha_include_uppercase'] = Array(
366 'parameters'=> Array(
367 'allow_empty'=> FALSE,
371 $this->vars[
'captcha_include_numbers'] = Array(
374 'parameters' => Array(
375 'allow_empty' => FALSE,
379 $this->vars[
'provide_accessible_captcha'] = Array(
382 'parameters' => Array(
383 'allow_empty' => FALSE,
387 $this->vars[
'layout_to_apply'] = Array(
392 $this->vars[
'override_layout_to_apply'] = Array(
399 $this->vars[
'use_mollom'] = Array(
403 'parameters' => Array(
404 'allow_empty' => FALSE,
407 $this->vars[
'mollom_attributes_to_check'] = Array(
409 'type' =>
'serialise',
410 'default' => Array(),
411 'description' =>
'Asset attributes to check for spam',
413 $this->vars[
'mollom_unsure_submission_text'] = Array(
416 'default' =>
'Please enter the characters in the image to verify your submission',
417 'description' =>
'Mollom error message text for unsure submission',
419 $this->vars[
'mollom_spam_submission_text'] = Array(
422 'default' =>
'This submission looks like a spam. Cannot accept this submission',
423 'description' =>
'Mollom error message text for spam submission',
425 $this->vars[
'mollom_captcha_incorrect_text'] = Array(
428 'default' =>
'Incorrect security key. Please try again',
429 'description' =>
'Mollom error message text for incorrect captcha',
431 $this->vars[
'mollom_captcha_regen_link_text'] = Array(
434 'default' =>
'Regenerate security key',
435 'description' =>
'Mollom CAPTCHA regen link text',
451 'event_name' =>
'requestKeywords',
452 'broadcast_type_code' =>
'content_type',
453 'broadcast_strict_type_code' => FALSE,
455 'side_of_link' =>
'major',
457 'is_exclusive' => NULL,
460 'link_type' => SQ_LINK_TYPE_2 | SQ_LINK_TYPE_1,
480 if (version_compare($current_version,
'0.2',
'<=')) {
481 $root_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_folder');
482 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($root_folder->id, $this->getAssetType(), FALSE);
483 foreach ($children as $assetid => $type) {
485 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $type);
486 if (is_null($asset))
continue;
488 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'attributes')) {
489 trigger_localised_error(
'CMS0025', E_USER_WARNING,
'0.2', $asset->name, $asset->id);
493 $old_create_type = $asset->attr(
'create_type');
494 $create_type = Array($old_create_type => TRUE);
495 $asset->setAttrValue(
'create_type', serialize($create_type));
497 if (!$asset->saveAttributes()) {
498 trigger_localised_error(
'CMS0026', E_USER_WARNING,
'0.2');
502 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($asset->id,
'attributes');
508 if (!parent::_upgrade($current_version))
return FALSE;
510 if ($current_version ==
'0.1') {
514 $root_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_folder');
515 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($root_folder->id, $this->getAssetType(), FALSE);
516 foreach ($children as $assetid => $type) {
517 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $type);
518 if (is_null($asset))
continue;
520 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'attributes')) {
521 trigger_localised_error(
'CMS0025', E_USER_WARNING,
'0.1', $asset->name, $asset->id);
526 $new_locations = Array();
527 $old_locations = $asset->attr(
'create_location_rules');
530 foreach ($old_locations as $rule_text => $locations) {
531 if (empty($rule_text))
continue;
532 $bits = explode(
' && ', $rule_text);
534 foreach ($bits as $bit) {
535 list($attr, $value) = explode(
'==', $bit);
536 $attr = trim($attr,
'$');
537 $value = trim($value,
" '");
538 $new_locations[$i][$attr][
'equals'] = $value;
541 $new_locations[$i][
'_create_locations_'] = array_keys($locations);
546 $asset->setAttrValue(
'create_location_rules', $new_locations);
548 if (!$asset->saveAttributes()) {
549 trigger_localised_error(
'CMS0026', E_USER_WARNING,
'0.1');
552 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($asset->id,
'attributes');
553 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
556 pre_echo(
'ASSET BUILDER UPGRADE COMPLETE - VERSION 0.1');
559 if ($current_version ==
'0.2') {
562 pre_echo(
'STARTING ASSET BUILDER UPGRADE - VERSION 0.2');
564 $root_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_folder');
565 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($root_folder->id, $this->getAssetType(), FALSE);
566 foreach ($children as $assetid => $type) {
567 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $type);
568 if (is_null($asset))
continue;
570 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'attributes')) {
571 trigger_localised_error(
'CMS0025', E_USER_WARNING,
'0.2', $asset->name, $asset->id);
575 $create_locs = $asset->attr(
'create_location_rules');
576 $create_locs = Array($old_create_type => $create_locs);
578 $asset->setAttrValue(
'create_location_rules', $create_locs);
580 $required_fields = $asset->attr(
'required_fields');
581 $required_fields = Array($old_create_type => $required_fields);
583 $asset->setAttrValue(
'required_fields', $required_fields);
584 if (!$asset->saveAttributes()) {
585 trigger_localised_error(
'CMS0026', E_USER_WARNING,
'0.2');
588 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($asset->id,
'attributes');
589 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
592 pre_echo(
'ASSET BUILDER UPGRADE COMPLETE - VERSION 0.2');
595 if ($current_version ==
'0.3') {
596 pre_echo(
'STARTING ASSET BUILDER UPGRADE - VERSION 0.3');
598 pre_echo(
'ASSET BUILDER UPGRADE COMPLETE - VERSION 0.3');
616 $root_folder = $GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_folder');
617 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($root_folder->id, $this->getAssetType(), FALSE);
618 foreach ($children as $assetid => $type) {
619 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $type);
620 if (is_null($asset))
continue;
623 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'attributes')) {
624 trigger_localised_error(
'CMS0025', E_USER_WARNING,
'0.3', $asset->name, $asset->id);
628 $old_link_type = $asset->attr(
'create_link_type');
631 $old_create_locations = $asset->attr(
'create_location');
632 if (!Array($old_create_locations)) {
633 $old_create_locations = Array(0 => $old_create_locations);
635 $fixed_create_locations = Array();
636 foreach ($old_create_locations as $assetid => $null) {
637 $fixed_create_locations[$assetid] = $old_link_type;
639 $asset->setAttrValue(
'create_location', $fixed_create_locations);
642 if ($asset->attr(
'create_location_optional')) {
643 $old_input_style = ($asset->attr(
'create_location_type') ==
'select') ?
'dropdown' :
'radio';
644 $old_selectable_locations = array_values($asset->attr(
'create_location_optional'));
645 if (!is_array($old_selectable_locations)) {
646 $old_selectable_locations = Array($old_selectable_locations);
648 $old_allow_multiple = $asset->attr(
'create_location_multiple') ? 1 : 0;
649 $selectable_locations_set_details = Array();
650 $location_details = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($old_selectable_locations);
651 $selectable_locations_set_details[
'locations'] = Array();
652 foreach ($old_selectable_locations as $assetid) {
653 $selectable_locations_set_details[
'locations'][$assetid] = $location_details[$assetid][
'name'];
655 echo
"\n\n Allow Multiple is $old_allow_multiple\n\n";
656 $selectable_locations_set_details[
'allow_multiple'] = $old_allow_multiple;
657 $selectable_locations_set_details[
'allow_empty'] = 0;
658 $selectable_locations_set_details[
'link_type'] = $old_link_type;
659 $selectable_locations_set_details[
'input_style'] = $old_input_style;
660 $asset->setAttrValue(
'create_location_optional', Array(
'First Selectable Location' => $selectable_locations_set_details));
664 $old_rules = $asset->attr(
'create_location_rules');
665 $create_location_rules = Array();
667 foreach ($old_rules as $create_type => $type_rules) {
668 $create_location_rules[$create_type] = Array();
669 foreach ($type_rules as $i => $rule_details) {
671 'attributes' => Array(),
672 'comparators' => Array(),
674 'locations' => Array(),
676 foreach ($rule_details as $attr_name => $conditions) {
677 if ($attr_name ==
'_create_locations_')
continue;
678 foreach ($conditions as $comparator => $value) {
679 $new_rule[
'attributes'][] = $attr_name;
680 $new_rule[
'comparators'][] = $comparator;
681 $new_rule[
'values'][] = $value;
684 if (is_array($rule_details[
'_create_locations_'])) {
685 foreach ($rule_details[
'_create_locations_'] as $assetid) {
686 $new_rule[
'locations'][] = $assetid;
687 $new_rule[
'link_types'][] = $old_link_type;
689 }
else if ($rule_details[
'_create_locations_']) {
690 $new_rule[
'locations'][$rule_details[
'_create_locations_']] = $old_link_type;
692 $create_location_rules[$create_type][] = $new_rule;
695 $asset->setAttrValue(
'create_location_rules', $create_location_rules);
697 if (!$asset->saveAttributes()) {
698 trigger_localised_error(
'CMS0027', E_USER_WARNING,
'0.3');
703 $content_assetids = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($asset->id,
'content_type_wysiwyg');
704 foreach (array_keys($content_assetids) as $assetid) {
705 $content_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
706 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($content_asset->id,
'attributes')) {
707 trigger_localised_error(
'CMS0025', E_USER_WARNING,
'0.3', $content_asset->name, $content_asset->id);
710 $html = $content_asset->attr(
'html');
711 $html = str_replace(
'%create_location%',
'%first_selectable_location_field%', $html);
712 $content_asset->setAttrValue(
'html', $html);
713 $content_asset->saveAttributes();
714 $content_asset->_updated();
715 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($content_asset->id,
'attributes');
716 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($content_asset);
720 $container_assetids = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($asset->id,
'bodycopy_container', FALSE);
721 foreach (array_keys($container_assetids) as $assetid) {
722 $container_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
723 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($container_asset->id,
'attributes')) {
724 trigger_localised_error(
'CMS0025', E_USER_WARNING,
'0.3', $container_asset->name, $container_asset->id);
727 $container_asset->saveSystemVersion();
728 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($container_asset->id,
'attributes');
729 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($container_asset);
732 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($asset->id,
'attributes');
733 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
735 if (!$asset->saveAttributes()) {
736 trigger_localised_error(
'CMS0027', E_USER_WARNING,
'0.3');