CMS  Version 3.9
MenuView Class Reference

Public Member Functions

 MenuView ($m)
 
 getLink ($menuItem)
 
 getItemCSS ($m)
 
 drawView ()
 

Public Attributes

 $m
 
 $pages
 
 $componentPages
 

Detailed Description

Definition at line 53 of file menu_view.inc.

Member Function Documentation

◆ drawView()

MenuView::drawView ( )

Definition at line 174 of file menu_view.inc.

175  {
176  global $script;
177 
178  // JDG 2/4/2011 - remove FakoliMenu for now b/c of placement issue
179  /*
180  $script .= <<<ENDSCRIPT
181 <script type="text/javascript">
182 window.addEvent('domready', function() { new FakoliMenu('{$this->m->identifier}'); });
183 </script>
184 ENDSCRIPT;
185 */
186  $startspan = $this->m->wrap_menu_items ? "<span>" : "";
187  $endspan = $this->m->wrap_menu_items ? "</span>" : "";
188 
189  $gmenus = regroupList($this->m->MenuItems("WHERE published=1 ORDER BY sort_order"), "parent_id");
190  if (count($gmenus) == 0) return;
191 
192  ob_start();
193 
194  $css = ($this->m->css_class) ? " class='{$this->m->css_class}'" : "";
195  echo "<ul{$css}>"; // has end tag
196  $found = false;
197 
198  foreach($gmenus[0] as $m)
199  {
200 
201  if ( preg_match('/^\\-\\-*/', $m->title) )
202  {
203  echo "<li><hr/></li>";
204  $found = true;
205  }
206  else
207  {
208  $link = $this->getLink($m);
209  if ($link) $found = true;
210 
211  $mTitle = $m->custom_format ? $m->format($m->custom_format) : $m->title;
212 
213  if(!$gmenus[$m->menu_item_id])
214  {
215  if ($link) echo "<li".$this->getItemCSS($m).">{$startspan}<a href='$link'>$mTitle</a>{$endspan}</li>"; // has et
216  }
217  else
218  {
219  if ($link)
220  {
221  echo "<li".$this->getItemCSS($m).">{$startspan}<a href='$link'>$mTitle</a>"; // no li et
222  if (array_key_exists($m->menu_item_id, $gmenus))
223  {
224  echo "<ul>"; // no ul et
225  foreach ($gmenus[$m->menu_item_id] as $submenu)
226  {
227  $link = $this->getLink($submenu);
228 
229  $smTitle = $submenu->custom_format ? $submenu->format($submenu->custom_format) : $submenu->title;
230 
231  if ($link)
232  {
233  echo "<li".$this->getItemCSS($submenu)."><a href='$link'>$smTitle</a>"; // only one level;
234  if($gmenus[$submenu->menu_item_id])
235  {
236  echo "<ul>";
237  foreach ($gmenus[$submenu->menu_item_id] as $subsubmenu)
238  {
239  $link = $this->getLink($subsubmenu);
240  $ssmTitle = $subsubmenu->custom_format ? $subsubmenu->format($subsubmenu->custom_format) : $subsubmenu->title;
241 
242  if ($link) echo "<li".$this->getItemCSS($subsubmenu)."><a href='$link'>$ssmTitle</a></li>"; // level 3 menus GOOD
243  }
244  echo "</ul>"; // end ul for level 3 //GOOD
245  }
246  else
247  {
248  echo "</li>"; //end tag for level 2 good
249  }
250  }
251  }
252 
253  echo "</ul>";
254  echo $endspan;
255  echo "</li>";
256  }
257  }
258  }
259  }
260  } # main foreach
261 
262  echo "</ul>"; // top level ul
263 
264  $out = ob_get_contents();
265  ob_end_clean();
266 
267  return ($found) ? $out : "";
268  }
$out
Definition: page.inc:66
getLink($menuItem)
Definition: menu_view.inc:75

◆ getItemCSS()

MenuView::getItemCSS (   $m)

Definition at line 145 of file menu_view.inc.

146  {
147  global $menu_identifier;
148  global $identifier;
149  global $section;
150 
151  $classes = array();
152 
153  if ($this->m->highlight_current_item)
154  {
155  if ($m->identifier == $identifier || ($menu_identifier && $m->identifier == $menu_identifier))
156  {
157  $classes[] = "current";
158  }
159  }
160 
161  if ($this->m->highlight_current_section && $m->identifier == $section->default_page)
162  {
163  $classes[] = "current";
164  }
165 
166  if ($m->css_class)
167  {
168  $classes[] = $m->css_class;
169  }
170 
171  return count($classes) > 0 ? " class='".implode(" ", $classes)."'" : "";
172  }
$section
Definition: event_form.inc:44
$identifier
Definition: rss.inc:37

◆ getLink()

MenuView::getLink (   $menuItem)

Definition at line 75 of file menu_view.inc.

76  {
77  if (!checkRole($menuItem->role) || !Settings::checkPermissions($menuItem->permissions)) return null;
78 
79  if ($menuItem->required_parameters)
80  {
81  $params = explode(",", $menuItem->required_parameters);
82 
83  foreach($params as $param)
84  {
85  if (!isset($_GET[$param])) return null;
86  }
87  }
88 
89  if (!MenuManager::testFlags($menuItem->display_flags)) return null;
90 
91  // If the URL field is set explicitly, use that
92  if ($menuItem->url)
93  {
94  if (startsWith($menuItem->url, "http://") || startsWith($menuItem->url, "https://"))
95  {
96  return $menuItem->url;
97  }
98 
99  $link = $menuItem->url;
100  if ($this->queryString) $link .= $this->queryString;
101  return $link;
102  }
103 
104  if ($menuItem->identifier)
105  {
106  if (array_key_exists($menuItem->identifier, $this->pages))
107  {
108  $page = $this->pages[$menuItem->identifier];
109  if (!$page->published)
110  {
111  // No link if the page is unpublished, or the user role doesn't match.
112  return null;
113  }
114 
115  $link = $menuItem->identifier;
116  if ($this->queryString) $link .= $this->queryString;
117  return $link;
118  }
119  else if (array_key_exists($menuItem->identifier, $this->componentPages))
120  {
121  $page = $this->componentPages[$menuItem->identifier];
122 
123  // JDG - remove check role on page 12/14/2011
124  // Allow menu item link to show even if user can't get to page
125  if (!$page->enabled)
126  {
127  // No link if the component page is unpublished.
128  return null;
129  }
130 
131  $link = $menuItem->identifier;
132  if ($this->queryString) $link .= $this->queryString;
133  return $link;
134  }
135  else
136  {
137  return null;
138  }
139  }
140 
141  // No related page or URL - use a placeholder link.
142  return "#";
143  }
$page
Definition: help.inc:39
$menuItem
static testFlags($flags)
static checkPermissions($permissions, $account=null)
Check all the permissions specified in the given string.
Definition: settings.inc:270

◆ MenuView()

MenuView::MenuView (   $m)

Definition at line 59 of file menu_view.inc.

60  {
61  $this->m = $m;
62 
63  $this->pages = IndexedQuery::create(Page)
64  ->constraints("WHERE site_id=:s")
65  ->indexBy("identifier")
66  ->filter(new InclusionFilter("page_id", "identifier", "published", "role"))
67  ->bind(":s", $this->m->site_id)
68  ->execute();
69 
70  $this->componentPages = IndexedQuery::create(ComponentPage)
71  ->indexBy("identifier")
72  ->execute();
73  }
Definition: page.inc:43

Member Data Documentation

◆ $componentPages

MenuView::$componentPages

Definition at line 57 of file menu_view.inc.

◆ $m

MenuView::$m

Definition at line 55 of file menu_view.inc.

◆ $pages

MenuView::$pages

Definition at line 56 of file menu_view.inc.


The documentation for this class was generated from the following file: