Elgg  Version 3.0
default.php
Go to the documentation of this file.
1 <?php
15 
17 if (!$menu instanceof PreparedMenu) {
18  return;
19 }
20 
21 // we want css classes to use dashes
22 $name = elgg_extract('name', $vars, '');
23 
24 $name_class_selector = preg_replace('/[^a-z0-9\-]/i', '-', strtolower($name));
25 
26 $show_section_headers = elgg_extract('show_section_headers', $vars, false);
27 $item_class = elgg_extract('item_class', $vars, '');
28 
29 $class = elgg_extract_class($vars, ["elgg-menu", "elgg-menu-{$name_class_selector}"]);
30 
32 
33 foreach ($menu as $section) {
34  if (!$section instanceof MenuSection) {
35  continue;
36  }
37 
38  $section_class = $class;
39  $section_class_selector = preg_replace('/[^a-z0-9\-]/i', '-', strtolower($section->getId()));
40  $section_class[] = "elgg-menu-{$name_class_selector}-{$section_class_selector}";
41 
42  $menu_view .= elgg_view('navigation/menu/elements/section', [
43  'items' => $section->all(),
44  'class' => $section_class,
45  'section' => $section->getId(),
46  'name' => $name,
47  'show_section_headers' => $show_section_headers,
48  'item_class' => $item_class,
49  'id' => elgg_extract('id', $vars),
50  ]);
51 }
52 
53 if (!$menu_view) {
54  return;
55 }
56 
58  'class' => [
59  'elgg-menu-container',
60  "elgg-menu-{$name_class_selector}-container",
61  ],
62  'data-menu-name' => $name,
63 ], $menu_view);
Menu section.
Definition: MenuSection.php:12
$name_class_selector
Definition: default.php:24
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
$class
Definition: default.php:29
$show_section_headers
Definition: default.php:26
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
Represents a menu that has been broken down into sections, with menu hierarchy trees setup...
if(!array_key_exists($size, $icon_sizes)) $vars['size']
Definition: default.php:27
Default menu.
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
$menu
Definition: default.php:23
if(!array_key_exists($size, $icon_sizes)) $name
Definition: default.php:30
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
$menu_view
Definition: default.php:31
$item_class
Definition: default.php:27