aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/admin.php2
-rw-r--r--engine/lib/navigation.php64
-rw-r--r--engine/lib/river.php3
-rw-r--r--engine/lib/users.php3
4 files changed, 69 insertions, 3 deletions
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index aab4b3aea..a5f7e1f88 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -122,7 +122,7 @@ function admin_init() {
elgg_register_action('admin/site/update_basic', '', 'admin');
elgg_register_action('admin/site/update_advanced', '', 'admin');
- elgg_register_action('admin/menu_items', '', 'admin');
+ elgg_register_action('admin/menu/save', '', 'admin');
elgg_register_action('admin/plugins/simple_update_states', '', 'admin');
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 7b8c32f02..ed19976cd 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -568,3 +568,67 @@ function elgg_get_breadcrumbs() {
return (is_array($CONFIG->breadcrumbs)) ? $CONFIG->breadcrumbs : array();
}
+
+/**
+ * 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'); \ No newline at end of file
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 46f11da46..459d351c1 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -806,7 +806,8 @@ function elgg_river_page_handler($page) {
*/
function elgg_river_init() {
register_page_handler('activity', 'elgg_river_page_handler');
- add_menu(elgg_echo('activity'), "pg/activity/");
+ $item = new ElggMenuItem('activity', elgg_echo('activity'), 'pg/activity');
+ elgg_register_menu_item('site', $item);
}
elgg_register_event_handler('init', 'system', 'elgg_river_init');
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 4e34586a3..d22e42ebf 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -1526,7 +1526,8 @@ function users_init() {
register_page_handler('members', 'elgg_members_page_handler');
//register_page_handler('collections', 'collections_page_handler');
- add_menu(elgg_echo('members'), 'pg/members/');
+ $item = new ElggMenuItem('members', elgg_echo('members'), 'pg/members');
+ elgg_register_menu_item('site', $item);
elgg_register_action("register", '', 'public');
elgg_register_action("useradd", '', 'public');