Elgg  Version 3.0
item.php
Go to the documentation of this file.
1 <?php
13 if (!$item instanceof ElggMenuItem) {
14  return;
15 }
16 
19 
20 $children = $item->getChildren();
21 if (!empty($children)) {
22  $link_class = 'elgg-menu-closed';
23  if ($item->getSelected()) {
24  $link_class = 'elgg-menu-opened';
25  }
26  $item->addLinkClass($link_class);
27 
28  $item->addLinkClass('elgg-menu-parent');
29 
30  $child_menu_vars = $item->getChildMenuOptions();
31  $child_menu_vars['items'] = $children;
32  $child_menu_vars['class'] = elgg_extract_class($child_menu_vars, ['elgg-menu', 'elgg-child-menu']);
33 
34  $display = elgg_extract('display', $child_menu_vars, 'default');
35  unset($child_menu_vars['display']);
36 
37  switch ($display) {
38  case 'dropdown' :
39  $item->addDeps(['elgg/menus/dropdown']);
40  $item->addItemClass('elgg-menu-item-has-dropdown');
41  break;
42 
43  case 'toggle' :
44  $item->addDeps(['elgg/menus/toggle']);
45  $item->addItemClass('elgg-menu-item-has-toggle');
46  break;
47  }
48 
49  $child_menu_view = elgg_view('navigation/menu/elements/section', $child_menu_vars);
50 }
51 
52 $item_vars['data-menu-item'] = $item->getName();
53 
54 $item_vars['class'] = elgg_extract_class($vars, $item->getItemClass(), 'item_class');
55 if ($item->getSelected()) {
56  $item_vars['class'][] = "elgg-state-selected";
57 }
58 
60 
if(!$item instanceof ElggMenuItem) $item_vars
Definition: item.php:17
elgg_view_menu_item(\ElggMenuItem $item, array $vars=[])
Render a menu item (usually as a link)
Definition: views.php:794
$children
Definition: item.php:20
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:1153
$item
Definition: item.php:12
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg echo
Translates a string.
Definition: languages.js:43
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
$child_menu_view
Definition: item.php:18
$vars['type']
Definition: save.php:11
if($item->getSelected()) $item_view
Definition: item.php:59
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246