diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-18 16:37:16 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-18 16:37:16 +0000 |
commit | 8ec093ecc1bf28c09f5d2dbe3c7bc8e6a2485ac6 (patch) | |
tree | 2b0c0454d9305cd61b92f57d02be06deccaf5d9b /views | |
parent | fc0fb6ec66aca4e439f434ce0d97df6d09388ef4 (diff) | |
download | elgg-8ec093ecc1bf28c09f5d2dbe3c7bc8e6a2485ac6.tar.gz elgg-8ec093ecc1bf28c09f5d2dbe3c7bc8e6a2485ac6.tar.bz2 |
site nav menu now uses new menu code (and finished the implementation of custom menu items while I was at it - not backward compatible with the previous half finished version)
git-svn-id: http://code.elgg.org/elgg/trunk@7668 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views')
-rw-r--r-- | views/default/admin/appearance/menu_items.php | 43 | ||||
-rw-r--r-- | views/default/navigation/menu/elements/item.php | 10 | ||||
-rw-r--r-- | views/default/navigation/menu/site.php | 25 | ||||
-rw-r--r-- | views/default/navigation/site_nav.php | 83 | ||||
-rw-r--r-- | views/default/page/elements/header.php | 2 |
5 files changed, 57 insertions, 106 deletions
diff --git a/views/default/admin/appearance/menu_items.php b/views/default/admin/appearance/menu_items.php index 9bed69a06..7572d2e0c 100644 --- a/views/default/admin/appearance/menu_items.php +++ b/views/default/admin/appearance/menu_items.php @@ -6,18 +6,17 @@ * @subpackage Core */ -$menu_items = get_register('menu'); -$featured_urls = get_config('menu_items_featured_urls'); +$builder = new ElggMenuBuilder('site'); +$menu = $builder->getMenu('name'); +$menu_items = $menu['default']; -// get an alphabetical sort of the items + urls -foreach ($menu_items as $name => $info) { - $menu_sorted[$info->name] = $info->value->url; -} - -ksort($menu_sorted); +$featured_menu_names = elgg_get_config('site_featured_menu_names'); -$pulldown_values = array_flip($menu_sorted); -$pulldown_values[''] = elgg_echo('none'); +$dropdown_values = array(); +foreach ($menu_items as $item) { + $dropdown_values[$item->getName()] = $item->getTitle(); +} +$dropdown_values[''] = elgg_echo('none'); echo elgg_view_title(elgg_echo('admin:menu_items')); echo "<div class='admin_settings menuitems'><h3>".elgg_echo('admin:menu_items:configure')."</h3>"; @@ -26,15 +25,15 @@ $form_body = ''; // @todo Could probably make this number configurable for ($i=0; $i<6; $i++) { - if (array_key_exists($i, $featured_urls)) { - $current_value = $featured_urls[$i]->value->url; + if (array_key_exists($i, $featured_menu_names)) { + $current_value = $featured_menu_names[$i]; } else { $current_value = ''; } $form_body .= elgg_view('input/pulldown', array( - 'options_values' => $pulldown_values, - 'internalname' => 'featured_urls[]', + 'options_values' => $dropdown_values, + 'internalname' => 'featured_menu_names[]', 'value' => $current_value )); } @@ -43,7 +42,7 @@ for ($i=0; $i<6; $i++) { $form_body .= "<h3>".elgg_echo('admin:add_menu_item')."</h3>"; $form_body .= elgg_view('output/longtext', array('value' => elgg_echo("admin:add_menu_item:description"))); -$custom_items = get_config('menu_items_custom_items'); +$custom_items = elgg_get_config('site_custom_menu_items'); $name_str = elgg_echo('name'); $url_str = elgg_echo('admin:plugins:label:website'); @@ -51,14 +50,14 @@ $url_str = elgg_echo('admin:plugins:label:website'); $form_body .= '<ul class="custom_menuitems">'; if (is_array($custom_items)) { - foreach ($custom_items as $url => $name) { + foreach ($custom_items as $title => $url) { $name_input = elgg_view('input/text', array( - 'internalname' => 'custom_item_names[]', - 'value' => $name + 'internalname' => 'custom_menu_titles[]', + 'value' => $title )); $url_input = elgg_view('input/text', array( - 'internalname' => 'custom_item_urls[]', + 'internalname' => 'custom_menu_urls[]', 'value' => $url )); @@ -68,11 +67,11 @@ if (is_array($custom_items)) { $new = elgg_echo('new'); $name_input = elgg_view('input/text', array( - 'internalname' => 'custom_item_names[]', + 'internalname' => 'custom_menu_titles[]', )); $url_input = elgg_view('input/text', array( - 'internalname' => 'custom_item_urls[]', + 'internalname' => 'custom_menu_urls[]', )); $form_body .= "<li class='custom_menuitem'>$name_str: $name_input $url_str: $url_input</li> @@ -82,6 +81,6 @@ $form_body .= elgg_view('input/submit', array('value' => elgg_echo('save'))); echo elgg_view('input/form', array( 'body' => $form_body, - 'action' => "action/admin/menu_items" + 'action' => "action/admin/menu/save" )); echo "</div>";
\ No newline at end of file diff --git a/views/default/navigation/menu/elements/item.php b/views/default/navigation/menu/elements/item.php new file mode 100644 index 000000000..f6959b2f4 --- /dev/null +++ b/views/default/navigation/menu/elements/item.php @@ -0,0 +1,10 @@ +<?php + +$item = $vars['item']; + +$class = ''; +if ($item->getSelected()) { + $class = 'class="selected"'; +} + +echo "<li $class>{$item->getLink()}</li>"; diff --git a/views/default/navigation/menu/site.php b/views/default/navigation/menu/site.php new file mode 100644 index 000000000..c2b00fd72 --- /dev/null +++ b/views/default/navigation/menu/site.php @@ -0,0 +1,25 @@ +<?php +/** + * Site navigation menu + * + * @uses $vars['menu']['default'] + * @uses $vars['menu']['more'] + */ + +echo '<ul class="elgg-site-menu">'; +foreach ($vars['menu']['default'] as $menu_item) { + echo elgg_view('navigation/menu/elements/item', array('item' => $menu_item)); +} + +if (isset($vars['menu']['more'])) { + $more = elgg_echo('more'); + echo '<li class="elgg-more">'; + echo "<a class='subnav' title=\"$more\"><span class=\"elgg-icon elgg-icon-arrow-s\"></span>$more</a>"; + echo '<ul>'; + foreach ($vars['menu']['more'] as $menu_item) { + echo elgg_view('navigation/menu/elements/item', array('item' => $menu_item)); + } + echo '</ul>'; + echo '</li>'; +} +echo '</ul>'; diff --git a/views/default/navigation/site_nav.php b/views/default/navigation/site_nav.php deleted file mode 100644 index aaf596b93..000000000 --- a/views/default/navigation/site_nav.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/** - * Site-wide navigation - * - */ - -$nav_items = elgg_get_nav_items(); -$featured = $nav_items['featured']; -$more = $nav_items['more']; - -$nav_html = ''; -$more_nav_html = ''; -$context = elgg_get_context(); - -// sort more links alphabetically -$more_sorted = array(); -foreach ($more as $info) { - $more_sorted[] = $info->name; -} - -// required because array multisort is case sensitive -$more_sorted_lower = array_map('elgg_strtolower', $more_sorted); -array_multisort($more_sorted_lower, $more); - -$item_count = 0; - -// if there are no featured items, display the standard tools in alphabetical order -if ($featured) { - foreach ($featured as $info) { - $selected = ($info->value->context == $context) ? 'class="selected"' : ''; - $title = htmlentities($info->name, ENT_QUOTES, 'UTF-8'); - $url = htmlentities($info->value->url, ENT_QUOTES, 'UTF-8'); - - $nav_html .= "<li $selected><a href=\"$url\" title=\"$title\"><span>$title</span></a></li>"; - } -} elseif ($more) { - for ($i=0; $i<5; $i++) { - if (!array_key_exists($i, $more)) { - break; - } - $info = $more[$i]; - - $selected = ($info->value->context == $context) ? 'class="selected"' : ''; - $title = htmlentities($info->name, ENT_QUOTES, 'UTF-8'); - $url = htmlentities($info->value->url, ENT_QUOTES, 'UTF-8'); - - $nav_html .= "<li $selected><a href=\"$url\" title=\"$title\">$title</a></li>"; - $more[$i]->used = TRUE; - $item_count++; - } -} - -// display the rest. -foreach ($more as $info) { - if ($info->used) { - continue; - } - $selected = ($info->value->context == $context) ? 'class="selected"' : ''; - $title = htmlentities($info->name, ENT_QUOTES, 'UTF-8'); - $url = htmlentities($info->value->url, ENT_QUOTES, 'UTF-8'); - - $more_nav_html .= "<li $selected><a href=\"$url\" title=\"$title\">$title</a></li>\n"; - $item_count++; -} - -if ($more_nav_html) { - $more = elgg_echo('more'); - $nav_html .= "<li class='elgg-more'><a class='subnav' title=\"$more\"><span class=\"elgg-icon elgg-icon-arrow-s\"></span>$more</a> - <ul> - $more_nav_html - </ul> - </li>"; -} - -// only display, if there are nav items to display -if ($nav_html) { - echo <<<___END - <ul class="elgg-site-menu"> - $nav_html - </ul> -___END; -} - diff --git a/views/default/page/elements/header.php b/views/default/page/elements/header.php index 0cedd33e2..125d80bfa 100644 --- a/views/default/page/elements/header.php +++ b/views/default/page/elements/header.php @@ -15,7 +15,7 @@ echo elgg_view('core/account/login_dropdown'); // insert site-wide navigation - echo elgg_view('navigation/site_nav'); + echo elgg_view_menu('site'); // insert a view which can be extended echo elgg_view('header/extend'); |