aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-01-29 23:08:34 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-01-29 23:08:34 +0000
commit27829ab5e2d7427cebc986d503e774ab199ba3b3 (patch)
treea64a585aaa0f2b44de5fb5486c6f219dec137cbf /engine
parent5026cb1b92ccd679bf9a425b1c9be401ab56eed7 (diff)
downloadelgg-27829ab5e2d7427cebc986d503e774ab199ba3b3.tar.gz
elgg-27829ab5e2d7427cebc986d503e774ab199ba3b3.tar.bz2
accidently removed the site menu set up function
git-svn-id: http://code.elgg.org/elgg/trunk@7953 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/navigation.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 155392645..8ed87ffb7 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -237,3 +237,67 @@ function menu_item($menu_name, $menu_url) {
elgg_deprecated_notice('menu_item() is deprecated by add_submenu_item', 1.7);
return make_register_object($menu_name, $menu_url);
}
+
+/**
+ * Set up the site menu
+ *
+ * Handles default, featured, and custom menu items
+ *
+ * @param string $hook
+ * @param string $type
+ * @param array $return Menu array
+ * @param array $params
+ * @return array
+ */
+function elgg_site_menu_setup($hook, $type, $return, $params) {
+
+ $featured_menu_names = elgg_get_config('site_featured_menu_names');
+ $custom_menu_items = elgg_get_config('site_custom_menu_items');
+ if ($featured_menu_names || $custom_menu_items) {
+ // we have featured or custom menu items
+
+ $registered = $return['default'];
+
+ // set up featured menu items
+ $featured = array();
+ foreach ($featured_menu_names as $name) {
+ foreach ($registered as $index => $item) {
+ if ($item->getName() == $name) {
+ $featured[] = $item;
+ unset($registered[$index]);
+ }
+ }
+ }
+
+ // add custom menu items
+ $n = 1;
+ foreach ($custom_menu_items as $title => $url) {
+ $item = new ElggMenuItem("custom$n", $title, $url);
+ $featured[] = $item;
+ $n++;
+ }
+
+ $return['default'] = $featured;
+ $return['more'] = $registered;
+ } else {
+ // no featured menu items set
+ $max_display_items = 5;
+
+ // the first n are shown, rest added to more list
+ $num_menu_items = count($return['default']);
+ if ($num_menu_items > $max_display_items) {
+ $return['more'] = array_splice($return['default'], $max_display_items);
+ }
+ }
+
+ return $return;
+}
+
+/**
+ * Navigation initialization
+ */
+function elgg_nav_init() {
+ elgg_register_plugin_hook_handler('prepare', 'menu:site', 'elgg_site_menu_setup');
+}
+
+elgg_register_event_handler('init', 'system', 'elgg_nav_init');