aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-27 14:20:22 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-27 14:20:22 +0000
commit4c94f8809f1131e2d8e073518195b6b65b26aceb (patch)
tree461af7e0e4414871c519acdef84ce397fa534325 /engine
parent543e50d2aabfbd3c116cbb670018c66fae535955 (diff)
downloadelgg-4c94f8809f1131e2d8e073518195b6b65b26aceb.tar.gz
elgg-4c94f8809f1131e2d8e073518195b6b65b26aceb.tar.bz2
improved menu creation for on demand menus and integrated hover menu items into profile owner block
git-svn-id: http://code.elgg.org/elgg/trunk@7724 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/classes/ElggMenuBuilder.php6
-rw-r--r--engine/classes/ElggMenuItem.php11
-rw-r--r--engine/lib/users.php16
-rw-r--r--engine/lib/views.php25
4 files changed, 31 insertions, 27 deletions
diff --git a/engine/classes/ElggMenuBuilder.php b/engine/classes/ElggMenuBuilder.php
index b57ea6e18..3528eaef8 100644
--- a/engine/classes/ElggMenuBuilder.php
+++ b/engine/classes/ElggMenuBuilder.php
@@ -18,10 +18,8 @@ class ElggMenuBuilder {
*
* @param string $name Identifier of the menu
*/
- public function __construct($name) {
- global $CONFIG;
-
- $this->menu = $CONFIG->menus[$name];
+ public function __construct($menu) {
+ $this->menu = $menu;
}
/**
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php
index f2eb1534f..2205ebc89 100644
--- a/engine/classes/ElggMenuItem.php
+++ b/engine/classes/ElggMenuItem.php
@@ -318,15 +318,14 @@ class ElggMenuItem {
/**
* Get the menu link
*
- * @todo add styling
+ * @params array $vars Options to pass to output/url
*
* @return string
*/
- public function getLink() {
- $vars = array(
- 'href' => $this->url,
- 'text' => $this->title
- );
+ public function getLink(array $vars = array()) {
+ $vars['href'] = $this->url;
+ $vars['text'] = $this->title;
+
return elgg_view('output/url', $vars);
}
}
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 353575307..a87b241a2 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -1493,17 +1493,17 @@ function elgg_user_hover_menu($hook, $type, $return, $params) {
$url = elgg_add_action_tokens_to_url($url);
$item = new ElggMenuItem('addfriend', $text, $url);
$item->setSection('action');
- elgg_register_menu_item('user_hover', $item);
+ $return[] = $item;
} else {
$url = "pg/profile/$user->username/edit";
$item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url);
$item->setSection('action');
- elgg_register_menu_item('user_hover', $item);
+ $return[] = $item;
$url = "pg/avatar/edit/$user->username";
$item = new ElggMenuItem('avatar:edit', elgg_echo('avatar:edit'), $url);
$item->setSection('action');
- elgg_register_menu_item('user_hover', $item);
+ $return[] = $item;
}
}
@@ -1532,14 +1532,16 @@ function elgg_user_hover_menu($hook, $type, $return, $params) {
$url = elgg_add_action_tokens_to_url($url);
$item = new ElggMenuItem($action, elgg_echo($action), $url);
$item->setSection('admin');
- elgg_register_menu_item('user_hover', $item);
+ $return[] = $item;
}
$url = "pg/profile/$user->username/edit";
$item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url);
$item->setSection('admin');
- elgg_register_menu_item('user_hover', $item);
+ $return[] = $item;
}
+
+ return $return;
}
/**
@@ -1566,8 +1568,10 @@ function elgg_user_admin_menu($hook, $type, $return, $params) {
$url = "action/admin/user/$action?guid={$user->guid}";
$url = elgg_add_action_tokens_to_url($url);
$item = new ElggMenuItem($action, elgg_echo($action), $url);
- elgg_register_menu_item('user_admin', $item);
+ $return[] = $item;
}
+
+ return $return;
}
/**
diff --git a/engine/lib/views.php b/engine/lib/views.php
index 1e309f5bd..b5240b431 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -657,27 +657,30 @@ function elgg_view_layout($layout_name, $vars = array()) {
* @since 1.8.0
*/
function elgg_view_menu($menu_name, array $vars = array()) {
-
+ global $CONFIG;
+
$vars['name'] = $menu_name;
$sort_by = elgg_get_array_value('sort_by', $vars, 'title');
- // Give plugins a chance to add menu items just before creation.
- // This supports context sensitive menus (ex. user hover).
- elgg_trigger_plugin_hook('register', "menu:$menu_name", $vars, NULL);
+ $menu = $CONFIG->menus[$menu_name];
+
+ // Give plugins a chance to add menu items just before creation.
+ // This supports context sensitive menus (ex. user_hover).
+ $menu = elgg_trigger_plugin_hook('register', "menu:$menu_name", $vars, $menu);
- $builder = new ElggMenuBuilder($menu_name);
+ $builder = new ElggMenuBuilder($menu);
$vars['menu'] = $builder->getMenu($sort_by);
$vars['selected_item'] = $builder->getSelected();
// Let plugins modify the menu
- $vars['menu'] = elgg_trigger_plugin_hook('prepare', "menu:$menu_name", $vars, $vars['menu']);
+ $vars['menu'] = elgg_trigger_plugin_hook('prepare', "menu:$menu_name", $vars, $vars['menu']);
- if (elgg_view_exists("navigation/menu/$menu_name")) {
- return elgg_view("navigation/menu/$menu_name", $vars);
- } else {
- return elgg_view("navigation/menu/default", $vars);
- }
+ if (elgg_view_exists("navigation/menu/$menu_name")) {
+ return elgg_view("navigation/menu/$menu_name", $vars);
+ } else {
+ return elgg_view("navigation/menu/default", $vars);
+ }
}
/**