Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
design_area_menu_normal.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/designs/design_areas/menu/design_area_menu_type/design_area_menu_type.inc';
19 
32 {
33 
34 
41  function __construct($assetid=0)
42  {
43  parent::__construct($assetid);
44 
45  }//end constructor
46 
47 
55  public function printDataCollection()
56  {
57  $parent_menu = $this->getParentMenu();
58  $ignore_permissions = $this->attr('ignore_permissions') ? ' , TRUE' : ' , FALSE';
59 
60  // if we aren't a sub menu, or if our parent is only showing subs if we are in the lineage, use the asset from the lineage
61  if (is_null($parent_menu) || $parent_menu->attr('show_subs') == 'on_current') {
62 
63 
64  $majorids = 'Array((int) $ASSET_LINEAGE[$'.$this->attr('id_name').'_level][\'assetid\'])';
65  if ($this->attr('root_node') == 0) {
66  echo '
67  if (isset($ASSET_LINEAGE[$'.$this->attr('id_name').'_level])) {
68  $'.$this->attr('id_name').'_assetids = menu_get_assets(\''.$this->attr('id_name').'\', Array((int) $ASSET_LINEAGE[$'.$this->attr('id_name').'_level][\'assetid\'])'.$ignore_permissions.');
69  } else {
70  $'.$this->attr('id_name').'_assetids = Array();
71  }
72  ';
73  } else if ($this->attr('root_node') != 0 && $this->attr('level') == 0) {
74  // generate the menu data based on the supplied root node if level is set to 'Top'
75  echo '$'.$this->attr('id_name').'_assetids = menu_get_assets(\''.$this->attr('id_name').'\', Array((int) '.$this->attr('root_node').')'.$ignore_permissions.');';
76  }
77  } else {
78  echo '
79  $'.$this->attr('id_name').'_assetids = menu_get_assets(\''.$this->attr('id_name').'\', $'.$parent_menu->attr('id_name').'_assetids'.$ignore_permissions.');
80 
81  ';
82  }// end if
83 
84  $sub_menu = $this->getSubMenu();
85  if (!is_null($sub_menu)) {
86  echo '
87  if (!empty($'.$this->attr('id_name').'_assetids)) {
88  ';
89  $sub_menu->printDataCollection();
90  echo '
91  }// end if $'.$this->attr('id_name').'_assetids not empty
92  ';
93  }// end if
94 
95  }//end printDataCollection()
96 
97 
107  protected function _printInitCode()
108  {
109  if ($this->attr('root_node') != 0 && $this->attr('level') == 0) {
110  echo '
111  <?php
112 
113  $within_site = FALSE;
114  $menu_'.$this->attr('id_name').'_lineage = Array();
115 
116  // if the specified root node is within the current site
117  foreach ($ASSET_LINEAGE as $i => $asset_lineage) {
118  if ($asset_lineage[\'assetid\'] == '.$this->attr('root_node').') {
119  $menu_'.$this->attr('id_name').'_lineage = array_slice($ASSET_LINEAGE, $i);
120  $within_site = TRUE;
121  break;
122  }
123  }
124 
125  // get the lineage from the site asset to the specified root node
126  if (!$within_site) {
127  $root_node = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset('.$this->attr('root_node').');
128  $root_url = $root_node->getURL(current_url());
129  $root_url = str_replace(Array(\'http://\', \'https://\'), \'\' , $root_url);
130  $root_lineage = $GLOBALS[\'SQ_SYSTEM\']->am->getLineageFromURL(null, $root_url);
131 
132  // extract the relevant lineage, and overwrites it with the original
133  if (!empty($root_lineage)) {
134  foreach ($root_lineage as $i => $info) {
135  if ($info[\'assetid\'] == '.$this->attr('root_node').') {
136  $menu_'.$this->attr('id_name').'_lineage[0] = $root_lineage[$i];
137  break;
138  }
139  }
140  }
141  }
142 
143  if (!empty($menu_'.$this->attr('id_name').'_lineage)) {
144  $original_lineage = $ASSET_LINEAGE;
145  $ASSET_LINEAGE = $menu_'.$this->attr('id_name').'_lineage;
146  }
147  ?>';
148  }//end if
149 
150  parent::_printInitCode();
151 
152  if ($this->attr('root_node') != 0 && $this->attr('level') == 0) {
153  echo '
154  <?php
155  // restore the asset lineage so that other menus are not affected
156  if (!empty($menu_'.$this->attr('id_name').'_lineage)) {
157  $ASSET_LINEAGE = $original_lineage;
158  }
159  ?>';
160  }
161 
162  }//end _printInitCode()
163 
164 
176  protected function _printPaintingCode()
177  {
178  if ($this->attr('root_node') != 0 && $this->attr('level') == 0) {
179  echo '
180  <?php
181  if (!empty($menu_'.$this->attr('id_name').'_lineage)) {
182  $original_lineage = $ASSET_LINEAGE;
183  $ASSET_LINEAGE = $menu_'.$this->attr('id_name').'_lineage;
184  }
185  ?>';
186  }//end if
187 
188  parent::_printPaintingCode();
189 
190  if ($this->attr('root_node') != 0 && $this->attr('level') == 0) {
191  echo '
192  <?php
193  // restore the asset lineage so that other menus are not affected
194  if (!empty($menu_'.$this->attr('id_name').'_lineage)) {
195  $ASSET_LINEAGE = $original_lineage;
196  }
197  ?>';
198  }
199 
200  }//end _printPaintingCode()
201 
202 
203 }//end class
204 ?>