diff options
Diffstat (limited to 'views/default/navigation/menu')
-rw-r--r-- | views/default/navigation/menu/default.php | 31 | ||||
-rw-r--r-- | views/default/navigation/menu/elements/item.php | 43 | ||||
-rw-r--r-- | views/default/navigation/menu/elements/section.php | 30 | ||||
-rw-r--r-- | views/default/navigation/menu/page.php | 36 | ||||
-rw-r--r-- | views/default/navigation/menu/site.php | 30 | ||||
-rw-r--r-- | views/default/navigation/menu/user_hover.php | 60 |
6 files changed, 230 insertions, 0 deletions
diff --git a/views/default/navigation/menu/default.php b/views/default/navigation/menu/default.php new file mode 100644 index 000000000..006deb3ea --- /dev/null +++ b/views/default/navigation/menu/default.php @@ -0,0 +1,31 @@ +<?php +/** + * Default menu + * + * @uses $vars['name'] Name of the menu + * @uses $vars['menu'] Array of menu items + * @uses $vars['class'] Additional CSS class for the menu + * @uses $vars['item_class'] Additional CSS class for each menu item + * @uses $vars['show_section_headers'] Do we show headers for each section? + */ + +// we want css classes to use dashes +$vars['name'] = preg_replace('/[^a-z0-9\-]/i', '-', $vars['name']); +$headers = elgg_extract('show_section_headers', $vars, false); +$item_class = elgg_extract('item_class', $vars, ''); + +$class = "elgg-menu elgg-menu-{$vars['name']}"; +if (isset($vars['class'])) { + $class .= " {$vars['class']}"; +} + +foreach ($vars['menu'] as $section => $menu_items) { + echo elgg_view('navigation/menu/elements/section', array( + 'items' => $menu_items, + 'class' => "$class elgg-menu-{$vars['name']}-$section", + 'section' => $section, + 'name' => $vars['name'], + 'show_section_headers' => $headers, + 'item_class' => $item_class, + )); +} 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>'; diff --git a/views/default/navigation/menu/page.php b/views/default/navigation/menu/page.php new file mode 100644 index 000000000..56a288234 --- /dev/null +++ b/views/default/navigation/menu/page.php @@ -0,0 +1,36 @@ +<?php +/** + * Page menu + * + * @uses $vars['menu'] + * @uses $vars['selected_item'] + * @uses $vars['class'] + * @uses $vars['name'] + * @uses $vars['show_section_headers'] + */ + +$headers = elgg_extract('show_section_headers', $vars, false); + +$class = 'elgg-menu elgg-menu-page'; +if (isset($vars['class'])) { + $class = "$class {$vars['class']}"; +} + +if (isset($vars['selected_item'])) { + $parent = $vars['selected_item']->getParent(); + + while ($parent) { + $parent->setSelected(); + $parent = $parent->getParent(); + } +} + +foreach ($vars['menu'] as $section => $menu_items) { + echo elgg_view('navigation/menu/elements/section', array( + 'items' => $menu_items, + 'class' => "$class elgg-menu-page-$section", + 'section' => $section, + 'name' => $vars['name'], + 'show_section_headers' => $headers + )); +} diff --git a/views/default/navigation/menu/site.php b/views/default/navigation/menu/site.php new file mode 100644 index 000000000..24c21dd57 --- /dev/null +++ b/views/default/navigation/menu/site.php @@ -0,0 +1,30 @@ +<?php +/** + * Site navigation menu + * + * @uses $vars['menu']['default'] + * @uses $vars['menu']['more'] + */ + +$default_items = elgg_extract('default', $vars['menu'], array()); +$more_items = elgg_extract('more', $vars['menu'], array()); + +echo '<ul class="elgg-menu elgg-menu-site elgg-menu-site-default clearfix">'; +foreach ($default_items as $menu_item) { + echo elgg_view('navigation/menu/elements/item', array('item' => $menu_item)); +} + +if ($more_items) { + echo '<li class="elgg-more">'; + + $more = elgg_echo('more'); + echo "<a href=\"#\">$more</a>"; + + echo elgg_view('navigation/menu/elements/section', array( + 'class' => 'elgg-menu elgg-menu-site elgg-menu-site-more', + 'items' => $more_items, + )); + + echo '</li>'; +} +echo '</ul>'; diff --git a/views/default/navigation/menu/user_hover.php b/views/default/navigation/menu/user_hover.php new file mode 100644 index 000000000..5c89e585c --- /dev/null +++ b/views/default/navigation/menu/user_hover.php @@ -0,0 +1,60 @@ +<?php +/** + * User hover menu + * + * Register for the 'register', 'menu:user_hover' plugin hook to add to the user + * hover menu. There are three sections: action, default, and admin. + * + * @uses $vars['menu'] Menu array provided by elgg_view_menu() + */ + +$user = $vars['entity']; +$actions = elgg_extract('action', $vars['menu'], null); +$main = elgg_extract('default', $vars['menu'], null); +$admin = elgg_extract('admin', $vars['menu'], null); + +echo '<ul class="elgg-menu elgg-menu-hover">'; + +// name and username +$name_link = elgg_view('output/url', array( + 'href' => $user->getURL(), + 'text' => "<span class=\"elgg-heading-basic\">$user->name</span>@$user->username", + 'is_trusted' => true, +)); +echo "<li>$name_link</li>"; + +// actions +if (elgg_is_logged_in() && $actions) { + echo '<li>'; + echo elgg_view('navigation/menu/elements/section', array( + 'class' => "elgg-menu elgg-menu-hover-actions", + 'items' => $actions, + )); + echo '</li>'; +} + +// main +if ($main) { + echo '<li>'; + + echo elgg_view('navigation/menu/elements/section', array( + 'class' => 'elgg-menu elgg-menu-hover-default', + 'items' => $main, + )); + + echo '</li>'; +} + +// admin +if (elgg_is_admin_logged_in() && $admin) { + echo '<li>'; + + echo elgg_view('navigation/menu/elements/section', array( + 'class' => 'elgg-menu elgg-menu-hover-admin', + 'items' => $admin, + )); + + echo '</li>'; +} + +echo '</ul>'; |