diff options
Diffstat (limited to 'views/default/navigation/menu/elements')
-rw-r--r-- | views/default/navigation/menu/elements/item.php | 43 | ||||
-rw-r--r-- | views/default/navigation/menu/elements/section.php | 30 |
2 files changed, 73 insertions, 0 deletions
diff --git a/views/default/navigation/menu/elements/item.php b/views/default/navigation/menu/elements/item.php new file mode 100644 index 000000000..fd9738826 --- /dev/null +++ b/views/default/navigation/menu/elements/item.php @@ -0,0 +1,43 @@ +<?php +/** + * A single element of a menu. + * + * @package Elgg.Core + * @subpackage Navigation + * + * @uses $vars['item'] ElggMenuItem + * @uses $vars['item_class'] Additional CSS class for the menu item + */ + +$item = $vars['item']; + +$link_class = 'elgg-menu-closed'; +if ($item->getSelected()) { + // @todo switch to addItemClass when that is implemented + //$item->setItemClass('elgg-state-selected'); + $link_class = 'elgg-menu-opened'; +} + +$children = $item->getChildren(); +if ($children) { + $item->addLinkClass($link_class); + $item->addLinkClass('elgg-menu-parent'); +} + +$item_class = $item->getItemClass(); +if ($item->getSelected()) { + $item_class = "$item_class elgg-state-selected"; +} +if (isset($vars['item_class']) && $vars['item_class']) { + $item_class .= ' ' . $vars['item_class']; +} + +echo "<li class=\"$item_class\">"; +echo $item->getContent(); +if ($children) { + echo elgg_view('navigation/menu/elements/section', array( + 'items' => $children, + 'class' => 'elgg-menu elgg-child-menu', + )); +} +echo '</li>'; diff --git a/views/default/navigation/menu/elements/section.php b/views/default/navigation/menu/elements/section.php new file mode 100644 index 000000000..c0e9ba750 --- /dev/null +++ b/views/default/navigation/menu/elements/section.php @@ -0,0 +1,30 @@ +<?php +/** + * Menu group + * + * @uses $vars['items'] Array of menu items + * @uses $vars['class'] Additional CSS class for the section + * @uses $vars['name'] Name of the menu + * @uses $vars['section'] The section name + * @uses $vars['item_class'] Additional CSS class for each menu item + * @uses $vars['show_section_headers'] Do we show headers for each section + */ + +$headers = elgg_extract('show_section_headers', $vars, false); +$class = elgg_extract('class', $vars, ''); +$item_class = elgg_extract('item_class', $vars, ''); + +if ($headers) { + $name = elgg_extract('name', $vars); + $section = elgg_extract('section', $vars); + echo '<h2>' . elgg_echo("menu:$name:header:$section") . '</h2>'; +} + +echo "<ul class=\"$class\">"; +foreach ($vars['items'] as $menu_item) { + echo elgg_view('navigation/menu/elements/item', array( + 'item' => $menu_item, + 'item_class' => $item_class, + )); +} +echo '</ul>'; |