18 require_once SQ_CORE_PACKAGE_PATH.
'/designs/design_area/design_area.inc';
43 parent::__construct($assetid);
58 SQ_LINK_TYPE_1 => Array(),
59 SQ_LINK_TYPE_2 => Array(),
60 SQ_LINK_TYPE_3 => Array(),
61 SQ_LINK_NOTICE => Array(
'design_area_menu_type' => Array(
'card' =>
'M',
'exclusive' => FALSE)),
79 if (substr($name, 0, 9) ==
'settings.') {
82 $split = explode(
'.', $name);
83 if (count($split) != 3) {
84 trigger_localised_error(
'CORE0173', E_USER_WARNING, $name);
91 $new_value = $this->vars[
'settings'][
'value'];
92 if (!is_array($new_value)) $new_value = Array();
93 if (!isset($new_value[$split[1]])) {
94 $new_value[$split[1]] = Array();
96 $new_value[$split[1]][$split[2]] = $value;
102 trigger_localised_error(
'CORE0174', E_USER_WARNING, $split[2]);
107 }
else if ($name ==
'level') {
108 switch (strtolower($value)) {
122 $value = (int) $value;
124 }
else if (($name ==
'unwanted_asset_types') && is_scalar($value)) {
125 $sub_menu_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'design_area_menu_type', FALSE,
'sub_menu');
127 if (!empty($sub_menu_link)) {
128 $smenu = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sub_menu_link[
'minorid'], $sub_menu_link[
'minor_type_code'], TRUE);
129 $smenu->setAttrValue(
'unwanted_asset_types', $value);
130 $smenu->saveAttributes();
133 }
else if (($name ==
'wanted_asset_types') && is_scalar($value)) {
134 $sub_menu_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'design_area_menu_type', FALSE,
'sub_menu');
136 if (!empty($sub_menu_link)) {
137 $smenu = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($sub_menu_link[
'minorid'], $sub_menu_link[
'minor_type_code'], TRUE);
138 $smenu->setAttrValue(
'wanted_asset_types', $value);
139 $smenu->saveAttributes();
144 if (($name ==
'unwanted_asset_types' || $name ==
'wanted_asset_types') && is_scalar($value)) {
146 $value = preg_split(
'/[ ,]+/', (
string)$value);
147 foreach ($value as $type_code) {
148 if (!$GLOBALS[
'SQ_SYSTEM']->am->installed($type_code)) {
149 trigger_localised_error(
'CORE0145', E_USER_WARNING, $type_code);
156 return parent::setAttrValue($name, $value);
172 if (substr($name, 0, 9) ==
'settings.') {
174 $split = explode(
'.', $name);
175 if (count($split) == 3) {
176 $settings = $this->
attr(
'settings');
177 if (isset($settings[$split[1]][$split[2]])) {
178 return $settings[$split[1]][$split[2]];
184 return parent::attr($name);
197 $var_refs = parent::getVarReferences();
199 if (!is_null($sub_menu)) {
200 $sub_var_refs = $sub_menu->getVarReferences();
201 for (reset($sub_var_refs); NULL !== ($id_name = key($sub_var_refs)); next($sub_var_refs)) {
202 if (!isset($var_refs[$id_name])) {
203 $var_refs[$id_name] = Array();
205 foreach ($sub_var_refs[$id_name] as $var) {
206 if (in_array($var, $var_refs[$id_name]))
continue;
207 $var_refs[$id_name][] = $var;
227 $settings = $this->
attr(
'settings');
228 $settings_changed = FALSE;
229 foreach ($this->vars[
'var_references'][
'value'] as $var_name => $info) {
231 if (substr($var_name, 0, 9) ==
'settings.' && isset($var_ref_values[$info[
'id_name']][$info[
'var']])) {
233 $split = explode(
'.', $var_name);
234 if (count($split) == 3) {
235 if (!isset($settings[$split[1]])) {
236 $settings[$split[1]] = Array();
238 $settings[$split[1]][$split[2]] = $var_ref_values[$info[
'id_name']][$info[
'var']];
239 $settings_changed = TRUE;
244 if ($settings_changed) {
245 $this->_tmp[
'var_reference_values'][
'settings'] = $settings;
249 parent::setVarReferenceValues($var_ref_values);
251 if (!is_null($sub_menu)) {
253 $sub_menu->setVarReferenceValues($var_ref_values);
267 if (empty($this->_tmp[
'sub_menu_link']) ||(!isset($this->_tmp[
'sub_menu_link']))) {
268 $this->_tmp[
'sub_menu_link'] = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'design_area_menu_type', FALSE,
'sub_menu');
270 return $this->_tmp[
'sub_menu_link'];
288 $smenu = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code'], TRUE);
303 if (!isset($this->_tmp[
'parent_menu_link'])) {
304 $this->_tmp[
'parent_menu_link'] = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_NOTICE,
'design_area_menu_type', FALSE,
'sub_menu',
'minor');
306 if (empty($this->_tmp[
'parent_menu_link'])) {
310 $pmenu = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($this->_tmp[
'parent_menu_link'][
'majorid'], $this->_tmp[
'parent_menu_link'][
'major_type_code'], TRUE) ;
327 parent::linksUpdated();
328 unset($this->_tmp[
'sub_menu_link']);
329 unset($this->_tmp[
'parent_menu_link']);
344 $settings = $this->
attr(
'settings');
345 return !empty($settings[$name]);
369 parent::printInitCode();
386 if (is_null($parent_menu)) {
389 if (!empty($ASSET_LINEAGE) && !empty($ASSET_LINEAGE[$'.$this->attr(
'id_name').
'_level])) {
392 $this->_tmp[
'parent_assetid_name'] =
'$ASSET_LINEAGE[$'.$this->attr(
'id_name').
'_level][\'assetid\']';
394 $this->_tmp[
'parent_assetid_name'] =
'$'.$parent_menu->attr(
'id_name').
'_row[\'assetid\']';
398 $'.$this->attr(
'id_name').
'_settings = '.var_export($this->
_getSettingsArray(), TRUE).
';
402 if (is_null($parent_menu)) {
404 }// end if found in ASSET_LINEAGE
430 if (isset('.$this->_tmp[
'parent_assetid_name'].
') && !empty($GLOBALS[\'MENU_DATA\']['.$this->
_safeStringLiteral($this->
attr(
'id_name')).
']['.$this->_tmp[
'parent_assetid_name'].
'])) {
434 parent::_printPaintingCode();
438 }// end if subs '.$this->attr(
'id_name').
'
456 if (empty($GLOBALS[
'SQ_'.__CLASS__.__FUNCTION__.
'_RUN_'.$GLOBALS[
'DESIGN_BEING_GENERATED']->id])) {
458 $db = MatrixDAL::getDb();
460 require_once SQ_FUDGE_PATH.\'/db_extras/db_extras.inc\';
461 require_once SQ_CORE_PACKAGE_PATH.\'/designs/design_areas/menu/design_area_menu_type/menu_get_assets.inc\';
463 $GLOBALS[\'MENU_DATA\'] = Array();
466 $GLOBALS[
'SQ_'.__CLASS__.__FUNCTION__.
'_RUN_'.$GLOBALS[
'DESIGN_BEING_GENERATED']->id] = TRUE;
470 if (!is_null($sub_menu)) {
471 $sub_menu->printStaticInitOutput();
485 $level = (int) $this->
attr(
'level');
487 if (!is_null($parent_menu)) {
494 $'.$this->attr(
'id_name').
'_level = $'.$parent_menu->attr(
'id_name').
'_level + 1;';
498 if (!is_null($level)) {
501 $'.$this->attr(
'id_name').
'_level = (count($ASSET_LINEAGE) -2) + '.(-1 * ($level + 1)).
';';
504 $'.$this->attr(
'id_name').
'_level = '.$level.
';';
509 if (!is_null($sub_menu)) $sub_menu->printInitOutput();
528 $'.$this->attr(
'id_name').
'_assetids = Array(); // menu_get_assets(majorids);
529 $'.$this->
attr(
'id_name').
'_urls = $am->getAssetURL($'.$this->
attr(
'id_name').
'_assetids);
534 if (!is_null($sub_menu)) {
535 $sub_menu->printDataCollection();
552 public function printVar($var, Array $args, $value_prefix=
'', $value_suffix=
'')
555 if (substr($var, 0, 9) ==
'settings.') {
557 list(,$setting_name) = explode(
'.', $var, 2);
562 $settings = $this->
attr(
'settings');
563 echo
'<',
'?php switch ($'.$this->attr(
'id_name').
'_current_setting){ ';
564 foreach ($settings[$setting_name] as $case => $value) {
565 echo
'case \''.addslashes($case).
'\' : ?
','>
', $value, '<
','?php
break;
';
571 echo
'<',
'?php echo $'.$this->attr(
'id_name').
'_settings[\''.$setting_name.
'\'][$
'.$this->attr('id_name
').'_current_setting]; ?
', '>
';
579 // if we are not in the asset looping section then we need to print the details of
580 // our parent asset - if we are not a sub menu there is nothing we can do
581 if (empty($this->_tmp['outputting_asset_section
'])) {
582 $parent_menu = $this->getParentMenu();
583 // if we aren't a sub menu, there is nothing we can
do
584 if (is_null($parent_menu)) {
587 $id_name = $parent_menu->attr(
'id_name');
591 $id_name = $this->
attr(
'id_name');
598 echo
'<',
'?php echo $'.$id_name.
'_row[\'assetid\']; ?',
'>';
604 echo
'<',
'?php echo $'.$id_name.
'_urls[$'.$id_name.
'_row[\'assetid\']].((SQ_LIMBO_EDITING) ? \'/\'.SQ_CONF_LIMBO_SUFFIX.\'?SQ_BACKEND_PAGE=main\' : \'\'); ?',
'>';
608 case 'asset_short_name' :
610 echo
'<',
'?php echo ', $this->
_escapeVar($value_prefix.
'htmlspecialchars($'.$id_name.
'_row[\'short_name\'])'.$value_suffix, $args),
'; ?',
'>';
616 echo
'<',
'?php echo ', $this->
_escapeVar($value_prefix.
'htmlspecialchars($'.$id_name.
'_row[\'name\'])'.$value_suffix, $args),
'; ?',
'>';
620 case 'asset_name_linked' :
621 case 'asset_short_name_linked' :
624 $name_var = substr($var, 0, -7);
626 if ($this->
attr(
'self_link')) {
627 echo
'<a href="', $this->
printVar(
'asset_link', Array()),
'">', $this->
printVar($name_var, Array(), $value_prefix, $value_suffix),
'</a>';
629 echo
'<',
'?php ',
"\n";
630 echo
' if ($'.$id_name.
'_current_setting == \'current\') { ',
"\n";
631 echo
'?',
'>', $this->
printVar($name_var, Array(), $value_prefix, $value_suffix),
'<',
'?php ',
"\n";
632 echo
'} else { ',
"\n";
633 echo
'?',
'><a href="', $this->
printVar(
'asset_link', Array()),
'">', $this->
printVar($name_var, Array(), $value_prefix, $value_suffix),
'</a><',
'?php ',
"\n";
634 echo
'}// end if ?',
'>';
640 case 'asset_thumbnail' :
643 echo
'$thumbnail = NULL;'.
"\n";
644 echo
'$thumbnail_asset = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($'.$id_name.
'_row[\'assetid\']);'.
"\n";
645 echo
'if ($thumbnail_asset->useSystemVersion()) {'.
"\n";
646 echo
' $notice_links = unserialize(file_to_string($thumbnail_asset->data_path.\'/.sq_notice_links\'));'.
"\n";
647 echo
' foreach ($notice_links as $link) {'.
"\n";
648 echo
' if ($link[\'value\'] == \'thumbnail\') {'.
"\n";
649 echo
' $thumbnail = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($link[\'minorid\']);'.
"\n";
653 echo
'} else {'.
"\n";
654 echo
' $link = $GLOBALS[\'SQ_SYSTEM\']->am->getLink($'.$id_name.
'_row[\'assetid\'], SQ_LINK_NOTICE, \'image\', FALSE, \'thumbnail\');'.
"\n";
655 echo
' if (!empty($link)) {'.
"\n";
656 echo
' $thumbnail = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($link[\'minorid\']);'.
"\n";
659 echo
'if ($thumbnail) echo $thumbnail->printImageTag(\'\', \'\', TRUE);'.
"\n";
664 case 'asset_thumbnail_url' :
667 echo
'$thumbnail = NULL;'.
"\n";
668 echo
'$thumbnail_asset = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($'.$id_name.
'_row[\'assetid\']);'.
"\n";
669 echo
'if ($thumbnail_asset->useSystemVersion()) {'.
"\n";
670 echo
' $notice_links = unserialize(file_to_string($thumbnail_asset->data_path.\'/.sq_notice_links\'));'.
"\n";
671 echo
' foreach ($notice_links as $link) {'.
"\n";
672 echo
' if ($link[\'value\'] == \'thumbnail\') {'.
"\n";
673 echo
' $thumbnail = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($link[\'minorid\']);'.
"\n";
677 echo
'} else {'.
"\n";
678 echo
' $link = $GLOBALS[\'SQ_SYSTEM\']->am->getLink($'.$id_name.
'_row[\'assetid\'], SQ_LINK_NOTICE, \'image\', FALSE, \'thumbnail\');'.
"\n";
679 echo
' if (!empty($link)) {'.
"\n";
680 echo
' $thumbnail = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($link[\'minorid\']);'.
"\n";
683 echo
'if ($thumbnail) echo $thumbnail->getURL($'.$id_name.
'_row[\'name\']);'.
"\n";
688 case (preg_match(
'/^asset_/i', $var) ? $var : !$var):
690 echo
'$keyword = \'',$var,
'\';
';
691 echo '$ROW_ASSET = $GLOBALS[\
'SQ_SYSTEM\']->am->getAsset($'.$id_name.
'_row[\'assetid\']);';
692 echo
'if (!is_null($ROW_ASSET)) {';
693 echo
'$replacement = '.$this->_escapeVar(
'$ROW_ASSET->getKeywordReplacement($keyword)', $args).
';';
694 echo
'if ($replacement == $keyword) {';
697 echo
' echo $replacement;';
699 echo
'$GLOBALS[\'SQ_SYSTEM\']->am->forgetAsset($ROW_ASSET);';
707 parent::printVar($var, $args);
724 $settings = $this->
attr(
'settings');
726 $has_php_code = FALSE;
727 foreach ($settings[$setting_name] as $case => $value) {
729 if (strpos($value,
'<'.
'?php') !== FALSE)
return TRUE;
743 $settings = $this->
attr(
'settings');
745 $names = array_keys($settings);
746 foreach ($names as $setting_name) {
749 unset($settings[$setting_name]);
769 $res = parent::getProtectedAttrs();
770 $res[] =
'asset_contents';
771 $res[] =
'divider_contents';
788 switch (array_get_index($element,
'operation')) {
790 if ($divider_contents = $this->
attr(
'divider_contents')) {
792 foreach ($divider_contents as $item) {
795 $divider = ob_get_contents();
802 if ($this->
attr(
'prefix_with_divider')) echo $divider;
806 $'.$this->attr(
'id_name').
'_lineage_assetid = (empty($ASSET_LINEAGE[$'.$this->
attr(
'id_name').
'_level + 1])) ? 0 : $ASSET_LINEAGE[$'.$this->
attr(
'id_name').
'_level + 1][\'assetid\'];
807 $'.$this->
attr(
'id_name').
'_lineage_setting = (count($ASSET_LINEAGE) - 1 == $'.$this->
attr(
'id_name').
'_level + 1) ? \'current\' : \'hierarchy\';
812 if (is_null($parent_menu)) {
813 $this->_tmp[
'parent_assetid_name'] =
'$ASSET_LINEAGE[$'.$this->attr(
'id_name').
'_level][\'assetid\']';
816 $'.$this->attr(
'id_name').
'_base_url = (empty($ASSET_LINEAGE[$'.$this->
attr(
'id_name').
'_level])) ? \'\' : current_protocol().\'://\'.$ASSET_LINEAGE[$'.$this->
attr(
'id_name').
'_level][\'url\'];
817 $'.$this->
attr(
'id_name').
'_urls = $am->getAssetURL(array_keys($GLOBALS[\'MENU_DATA\']['.$this->
_safeStringLiteral($this->
attr(
'id_name')).
'][$ASSET_LINEAGE[$'.$this->
attr(
'id_name').
'_level][\'assetid\']]), $'.$this->
attr(
'id_name').
'_base_url);
821 $this->_tmp[
'parent_assetid_name'] =
'$'.$parent_menu->attr(
'id_name').
'_row[\'assetid\']';
824 $'.$this->attr(
'id_name').
'_base_url = $'.$parent_menu->attr(
'id_name').
'_urls[$'.$parent_menu->attr(
'id_name').
'_row[\'assetid\']];
825 $'.$this->
attr(
'id_name').
'_urls = $am->getAssetURL(array_keys($GLOBALS[\'MENU_DATA\']['.$this->
_safeStringLiteral($this->
attr(
'id_name')).
'][$'.$parent_menu->attr(
'id_name').
'_row[\'assetid\']]), $'.$this->
attr(
'id_name').
'_base_url);
832 if ($divider !=
'' && !$this->
attr(
'suffix_with_divider')) {
835 $'.$this->attr(
'id_name').
'_i = -1;
836 $'.$this->
attr(
'id_name').
'_total = count($GLOBALS[\'MENU_DATA\']['.$this->
_safeStringLiteral($this->
attr(
'id_name')).
']['.$this->_tmp[
'parent_assetid_name'].
']);
842 foreach ($GLOBALS[\'MENU_DATA\']['.$this->_safeStringLiteral($this->
attr(
'id_name')).
']['.$this->_tmp[
'parent_assetid_name'].
'] as $'.$this->
attr(
'id_name').
'_row) {
843 $'.$this->
attr(
'id_name').
'_current_setting = ($'.$this->
attr(
'id_name').
'_lineage_assetid == $'.$this->
attr(
'id_name').
'_row[\'assetid\']) ? $'.$this->
attr(
'id_name').
'_lineage_setting : \'normal\';
846 $unwanted_types = $this->
attr(
'unwanted_asset_types');
847 $all_type_codes = Array();
848 foreach ($unwanted_types as $type) {
850 $all_type_codes = array_merge($all_type_codes, $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type, TRUE));
853 $unwanted_types = $all_type_codes;
855 if (!empty($unwanted_types)) {
856 $unwanted_types_literal_array =
'Array("'.implode(
'", "', $unwanted_types).
'")';
858 echo
'<?php if (in_array($'.$this->attr(
'id_name').
'_row[\'type_code\'], '.$unwanted_types_literal_array.
')) continue ;?>';
861 $wanted_types = $this->
attr(
'wanted_asset_types');
862 $all_type_codes = Array();
863 foreach ($wanted_types as $type) {
865 $all_type_codes = array_merge($all_type_codes, $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($type, TRUE));
868 $wanted_types = $all_type_codes;
870 if (!empty($wanted_types)) {
871 $wanted_types_literal_array =
'Array("'.implode(
'", "', $wanted_types).
'")';
872 echo
'<?php if (!in_array($'.$this->attr(
'id_name').
'_row[\'type_code\'], '.$wanted_types_literal_array.
')) continue ;?>';
875 if ($this_contents = $this->
attr(
'asset_contents')) {
876 $this->_tmp[
'outputting_asset_section'] = TRUE;
877 foreach ($this_contents as $item) {
880 unset($this->_tmp[
'outputting_asset_section']);
886 if ($divider !=
'') {
889 if (!$this->
attr(
'suffix_with_divider')) {
891 $'.$this->attr(
'id_name').
'_i++;
892 if ($'.$this->
attr(
'id_name').
'_i != $'.$this->
attr(
'id_name').
'_total - 1) {
899 if (!$this->
attr(
'suffix_with_divider')) {
908 }// end foreach '.$this->attr(
'id_name').
' data
915 if (is_null($sub))
return TRUE;
919 $current_designs = $sub->getDesigns();
920 foreach ($current_designs as $current_design) {
922 if (is_null($current_design))
continue;
925 $customisation_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($current_design->id, SQ_LINK_TYPE_2,
'design_customisation', TRUE,
'major',
'customisation');
926 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
927 foreach ($customisation_links as $link) {
928 $customisation = $am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
929 if (is_null($customisation))
continue;
932 $custom_das = $customisation->getCustomisedAreas();
933 foreach ($custom_das as $custom_da) {
934 if ($custom_da[
'minorid'] != $sub->id) {
935 $new_da = $am->getAsset($custom_da[
'minorid'], $custom_da[
'minor_type_code']);
936 if (is_null($new_da))
continue;
937 if ($new_da->name == $sub->name) {
938 foreach ($new_da->vars as $name => $details) {
939 if (in_array($name, Array(
'unwanted_asset_types',
'self_link',
'wanted_asset_types'))) {
940 $sub->vars[$name] = $new_da->vars[$name];
948 return $sub->printAreaCode();
951 return parent::_printContentItemCode($element);