aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-07 12:15:38 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-07 12:15:38 +0000
commit142aef30294caab47a184393103aa6644131ba19 (patch)
tree495f2308c99f76f2e33bdac26ceff4f0c9ff5496
parent5991e7a915191a0d7655b51794dfdc1ac05ce5d7 (diff)
downloadelgg-142aef30294caab47a184393103aa6644131ba19.tar.gz
elgg-142aef30294caab47a184393103aa6644131ba19.tar.bz2
Refs #2895 entity menu uses new menu system
git-svn-id: http://code.elgg.org/elgg/trunk@8622 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/navigation.php111
-rw-r--r--engine/lib/river.php57
-rw-r--r--mod/blog/start.php31
-rw-r--r--mod/blog/views/default/object/blog.php13
-rw-r--r--mod/bookmarks/views/default/object/bookmarks.php6
-rw-r--r--mod/file/views/default/object/file.php6
-rw-r--r--mod/groups/start.php69
-rw-r--r--mod/groups/views/default/group/default.php41
-rw-r--r--mod/groups/views/default/object/groupforumtopic.php6
-rw-r--r--mod/pages/start.php28
-rw-r--r--mod/pages/views/default/object/page_top.php12
-rw-r--r--views/default/css/elements/navigation.php8
12 files changed, 269 insertions, 119 deletions
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 4affc9c30..b79156986 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -207,10 +207,121 @@ function elgg_site_menu_setup($hook, $type, $return, $params) {
}
/**
+ * Add the comment and like links to river actions menu
+ */
+function elgg_river_menu_setup($hook, $type, $return, $params) {
+ if (elgg_is_logged_in()) {
+ $item = $params['item'];
+ $object = $item->getObjectEntity();
+ // comments and non-objects cannot be commented on or liked
+ if (!elgg_in_context('widgets') && $item->annotation_id == 0) {
+ // comments
+ if ($object->canComment()) {
+ $options = array(
+ 'name' => 'comment',
+ 'href' => "#comments-add-$object->guid",
+ 'text' => elgg_echo('generic_comments:text'),
+ 'class' => "elgg-toggler",
+ 'priority' => 50,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+
+ // like this
+ if ($object->canAnnotate(0, 'likes')) {
+ if (!elgg_annotation_exists($object->getGUID(), 'likes')) {
+ $url = "action/likes/add?guid={$object->getGUID()}";
+ $options = array(
+ 'name' => 'like',
+ 'href' => $url,
+ 'text' => elgg_echo('likes:likethis'),
+ 'is_action' => true,
+ 'priority' => 100,
+ );
+ } else {
+ $likes = elgg_get_annotations(array(
+ 'guid' => $guid,
+ 'annotation_name' => 'likes',
+ 'owner_guid' => elgg_get_logged_in_user_guid()
+ ));
+ $url = elgg_get_site_url() . "action/likes/delete?annotation_id={$likes[0]->id}";
+ $options = array(
+ 'name' => 'like',
+ 'href' => $url,
+ 'text' => elgg_echo('likes:remove'),
+ 'is_action' => true,
+ 'priority' => 100,
+ );
+ }
+ $return[] = ElggMenuItem::factory($options);
+ }
+ }
+ }
+
+ return $return;
+}
+
+/**
+ * Entity menu is list of links and info on any entity
+ */
+function elgg_entity_menu_setup($hook, $type, $return, $params) {
+ if (elgg_in_context('widgets')) {
+ return $return;
+ }
+
+ $entity = $params['entity'];
+ $handler = elgg_extract('handler', $params, false);
+
+ // access
+ $access = elgg_view('output/access', array('entity' => $entity));
+ $options = array(
+ 'name' => 'access',
+ 'text' => $access,
+ 'href' => false,
+ 'priority' => 100,
+ );
+ $return[] = ElggMenuItem::factory($options);
+
+ if ($entity->canEdit() && $handler) {
+ // edit link
+ $options = array(
+ 'name' => 'edit',
+ 'text' => elgg_echo('edit'),
+ 'href' => "pg/$handler/edit/{$entity->getGUID()}",
+ 'priority' => 200,
+ );
+ $return[] = ElggMenuItem::factory($options);
+
+ // delete link
+ $options = array(
+ 'name' => 'delete',
+ 'text' => elgg_view_icon('delete'),
+ 'href' => "action/$handler/delete?guid={$entity->getGUID()}",
+ 'confirm' => elgg_echo('deleteconfirm'),
+ 'priority' => 300,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+
+ // likes
+ $options = array(
+ 'name' => 'likes',
+ 'text' => elgg_view_likes($entity),
+ 'href' => false,
+ 'priority' => 1000,
+ );
+ $return[] = ElggMenuItem::factory($options);
+
+ return $return;
+}
+
+/**
* Navigation initialization
*/
function elgg_nav_init() {
elgg_register_plugin_hook_handler('prepare', 'menu:site', 'elgg_site_menu_setup');
+ elgg_register_plugin_hook_handler('register', 'menu:river', 'elgg_river_menu_setup');
+ elgg_register_plugin_hook_handler('register', 'menu:entity', 'elgg_entity_menu_setup');
}
elgg_register_event_handler('init', 'system', 'elgg_nav_init');
diff --git a/engine/lib/river.php b/engine/lib/river.php
index 6bc0645a9..3a351805e 100644
--- a/engine/lib/river.php
+++ b/engine/lib/river.php
@@ -506,61 +506,6 @@ function update_river_access_by_object($object_guid, $access_id) {
}
/**
- * Add the comment and like links to river actions menu
- */
-function elgg_river_add_menu_items($hook, $type, $return, $params) {
- if (elgg_is_logged_in()) {
- $item = $params['item'];
- $object = $item->getObjectEntity();
- // comments and non-objects cannot be commented on or liked
- if (!elgg_in_context('widgets') && $item->annotation_id == 0) {
- // comments
- if ($object->canComment()) {
- $options = array(
- 'name' => 'comment',
- 'href' => "#comments-add-$object->guid",
- 'text' => elgg_echo('generic_comments:text'),
- 'class' => "elgg-toggler",
- 'priority' => 50,
- );
- $return[] = ElggMenuItem::factory($options);
- }
-
- // like this
- if ($object->canAnnotate(0, 'likes')) {
- if (!elgg_annotation_exists($object->getGUID(), 'likes')) {
- $url = "action/likes/add?guid={$object->getGUID()}";
- $options = array(
- 'name' => 'like',
- 'href' => $url,
- 'text' => elgg_echo('likes:likethis'),
- 'is_action' => true,
- 'priority' => 100,
- );
- } else {
- $likes = elgg_get_annotations(array(
- 'guid' => $guid,
- 'annotation_name' => 'likes',
- 'owner_guid' => elgg_get_logged_in_user_guid()
- ));
- $url = elgg_get_site_url() . "action/likes/delete?annotation_id={$likes[0]->id}";
- $options = array(
- 'name' => 'like',
- 'href' => $url,
- 'text' => elgg_echo('likes:remove'),
- 'is_action' => true,
- 'priority' => 100,
- );
- }
- $return[] = ElggMenuItem::factory($options);
- }
- }
- }
-
- return $return;
-}
-
-/**
* Page handler for activiy
*
* @param array $page
@@ -589,8 +534,6 @@ function elgg_river_init() {
elgg_register_page_handler('activity', 'elgg_river_page_handler');
$item = new ElggMenuItem('activity', elgg_echo('activity'), 'pg/activity');
elgg_register_menu_item('site', $item);
-
- elgg_register_plugin_hook_handler('register', 'menu:river', 'elgg_river_add_menu_items');
}
elgg_register_event_handler('init', 'system', 'elgg_river_init');
diff --git a/mod/blog/start.php b/mod/blog/start.php
index 437970de4..344da21d4 100644
--- a/mod/blog/start.php
+++ b/mod/blog/start.php
@@ -63,6 +63,9 @@ function blog_init() {
elgg_register_action('blog/auto_save_revision', "$action_path/auto_save_revision.php");
elgg_register_action('blog/delete', "$action_path/delete.php");
+ // entity menu
+ elgg_register_plugin_hook_handler('register', 'menu:entity', 'blog_entity_menu_setup');
+
// ecml
elgg_register_plugin_hook_handler('get_views', 'ecml', 'blog_ecml_views_hook');
}
@@ -181,6 +184,34 @@ function blog_owner_block_menu($hook, $type, $return, $params) {
}
/**
+ * Add particular blog links/info to entity menu
+ */
+function blog_entity_menu_setup($hook, $type, $return, $params) {
+ if (elgg_in_context('widgets')) {
+ return $return;
+ }
+
+ $entity = $params['entity'];
+ $handler = elgg_extract('handler', $params, false);
+ if ($handler != 'blog') {
+ return $return;
+ }
+
+ if ($entity->canEdit() && $entity->status != 'published') {
+ $status_text = elgg_echo("blog:status:{$entity->status}");
+ $options = array(
+ 'name' => 'published_status',
+ 'text' => $status_text,
+ 'href' => false,
+ 'priority' => 150,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+
+ return $return;
+}
+
+/**
* Register blogs with ECML.
*/
function blog_ecml_views_hook($hook, $entity_type, $return_value, $params) {
diff --git a/mod/blog/views/default/object/blog.php b/mod/blog/views/default/object/blog.php
index a24d8758e..8c339236c 100644
--- a/mod/blog/views/default/object/blog.php
+++ b/mod/blog/views/default/object/blog.php
@@ -43,16 +43,11 @@ if ($blog->comments_on != 'Off') {
$comments_link = '';
}
-$extra_links = false;
-if ($blog->canEdit() && $blog->status != 'published') {
- $status_text = elgg_echo("blog:status:{$blog->status}");
- $extra_links = array($status_text);
-}
-
-$metadata = elgg_view('navigation/menu/metadata', array(
- 'entity' => $blog,
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $vars['entity'],
'handler' => 'blog',
- 'links' => $extra_links,
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
));
$subtitle = "<p>$author_text $date $comments_link</p>";
diff --git a/mod/bookmarks/views/default/object/bookmarks.php b/mod/bookmarks/views/default/object/bookmarks.php
index 71a75731f..8a4b982e1 100644
--- a/mod/bookmarks/views/default/object/bookmarks.php
+++ b/mod/bookmarks/views/default/object/bookmarks.php
@@ -41,9 +41,11 @@ if ($comments_count != 0) {
$comments_link = '';
}
-$metadata = elgg_view('navigation/menu/metadata', array(
- 'entity' => $bookmark,
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $vars['entity'],
'handler' => 'bookmarks',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
));
$subtitle = "$author_text $date $categories $comments_link";
diff --git a/mod/file/views/default/object/file.php b/mod/file/views/default/object/file.php
index c5773600b..75c72e2b5 100644
--- a/mod/file/views/default/object/file.php
+++ b/mod/file/views/default/object/file.php
@@ -44,9 +44,11 @@ if ($comments_count != 0) {
$comments_link = '';
}
-$metadata = elgg_view('navigation/menu/metadata', array(
- 'entity' => $file,
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $vars['entity'],
'handler' => 'file',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
));
$subtitle = "$author_text $date $categories $comments_link";
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 08c0d1966..9a80fd366 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -58,6 +58,8 @@ function groups_init() {
// add link to owner block
elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'groups_activity_owner_block_menu');
+ // group entity menu
+ elgg_register_plugin_hook_handler('register', 'menu:entity', 'groups_entity_menu_setup');
//extend some views
elgg_extend_view('css/elgg', 'groups/css');
@@ -278,6 +280,73 @@ function groups_activity_owner_block_menu($hook, $type, $return, $params) {
}
/**
+ * Add links/info to entity menu particular to group entities
+ */
+function groups_entity_menu_setup($hook, $type, $return, $params) {
+ if (elgg_in_context('widgets')) {
+ return $return;
+ }
+
+ $entity = $params['entity'];
+ $handler = elgg_extract('handler', $params, false);
+ if ($handler != 'groups') {
+ return $return;
+ }
+
+ foreach ($return as $index => $item) {
+ if (in_array($item->getName(), array('access', 'likes', 'edit', 'delete'))) {
+ unset($return[$index]);
+ }
+ }
+
+ // membership type
+ $membership = $entity->membership;
+ if ($membership == ACCESS_PUBLIC) {
+ $mem = elgg_echo("groups:open");
+ } else {
+ $mem = elgg_echo("groups:closed");
+ }
+ $options = array(
+ 'name' => 'membership',
+ 'text' => $mem,
+ 'href' => false,
+ 'priority' => 100,
+ );
+ $return[] = ElggMenuItem::factory($options);
+
+ // number of members
+ $num_members = get_group_members($entity->guid, 10, 0, 0, true);
+ $members_string = elgg_echo('groups:member');
+ $options = array(
+ 'name' => 'members',
+ 'text' => $num_members . ' ' . $members_string,
+ 'href' => false,
+ 'priority' => 200,
+ );
+ $return[] = ElggMenuItem::factory($options);
+
+ // feature link
+ if (elgg_is_admin_logged_in()) {
+ if ($group->featured_group == "yes") {
+ $url = "action/groups/featured?group_guid={$group->guid}&action_type=unfeature";
+ $wording = elgg_echo("groups:makeunfeatured");
+ } else {
+ $url = "action/groups/featured?group_guid={$group->guid}&action_type=feature";
+ $wording = elgg_echo("groups:makefeatured");
+ }
+ $options = array(
+ 'name' => 'feature',
+ 'text' => $wording,
+ 'href' => $url,
+ 'priority' => 300,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+
+ return $return;
+}
+
+/**
* Groups created so create an access list for it
*/
function groups_create_event_listener($event, $object_type, $object) {
diff --git a/mod/groups/views/default/group/default.php b/mod/groups/views/default/group/default.php
index 77b17402b..14bdc7aa3 100644
--- a/mod/groups/views/default/group/default.php
+++ b/mod/groups/views/default/group/default.php
@@ -9,41 +9,12 @@ $group = $vars['entity'];
$icon = elgg_view_entity_icon($group, 'tiny');
-//get the membership type
-$membership = $group->membership;
-if ($membership == ACCESS_PUBLIC) {
- $mem = elgg_echo("groups:open");
-} else {
- $mem = elgg_echo("groups:closed");
-}
-
-// number of members
-$num_members = get_group_members($group->guid, 10, 0, 0, true);
-$members_string = elgg_echo('groups:member');
-
-$metadata = "<ul class=\"elgg-menu elgg-menu-metadata\"><li>$mem</li>";
-$metadata .= "<li>$num_members $members_string</li>";
-
-// feature link
-if (elgg_is_admin_logged_in()) {
- if ($group->featured_group == "yes") {
- $url = "action/groups/featured?group_guid={$group->guid}&action_type=unfeature";
- $wording = elgg_echo("groups:makeunfeatured");
- } else {
- $url = "action/groups/featured?group_guid={$group->guid}&action_type=feature";
- $wording = elgg_echo("groups:makefeatured");
- }
- $feature_link = elgg_view('output/url', array(
- 'href' => $url,
- 'text' => $wording,
- 'is_action' => true,
- ));
- $metadata .= "<li>$feature_link</li>";
-}
-
-$metadata .= elgg_view("entity/metadata", array('entity' => $group));
-
-$metadata .= "</ul>";
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $group,
+ 'handler' => 'groups',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+));
if (elgg_in_context('owner_block') || elgg_in_context('widgets')) {
$metadata = '';
diff --git a/mod/groups/views/default/object/groupforumtopic.php b/mod/groups/views/default/object/groupforumtopic.php
index b5efa0e6c..1b972c77f 100644
--- a/mod/groups/views/default/object/groupforumtopic.php
+++ b/mod/groups/views/default/object/groupforumtopic.php
@@ -45,9 +45,11 @@ if ($num_replies != 0) {
));
}
-$metadata = elgg_view('navigation/menu/metadata', array(
- 'entity' => $topic,
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $vars['entity'],
'handler' => 'discussion',
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
));
// do not show the metadata and controls in widget view
diff --git a/mod/pages/start.php b/mod/pages/start.php
index 82f3a2ba9..8c2645f05 100644
--- a/mod/pages/start.php
+++ b/mod/pages/start.php
@@ -71,6 +71,9 @@ function pages_init() {
// icon url override
elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'pages_icon_url_override');
+ // entity menu
+ elgg_register_plugin_hook_handler('register', 'menu:entity', 'pages_entity_menu_setup');
+
// register ecml views to parse
elgg_register_plugin_hook_handler('get_views', 'ecml', 'pages_ecml_views_hook');
}
@@ -211,6 +214,31 @@ function pages_owner_block_menu($hook, $type, $return, $params) {
}
/**
+ * Add links/info to entity menu particular to pages plugin
+ */
+function pages_entity_menu_setup($hook, $type, $return, $params) {
+ if (elgg_in_context('widgets')) {
+ return $return;
+ }
+
+ $entity = $params['entity'];
+ $handler = elgg_extract('handler', $params, false);
+ if ($handler != 'pages') {
+ return $return;
+ }
+
+ $options = array(
+ 'name' => 'history',
+ 'text' => elgg_echo('pages:history'),
+ 'href' => "pg/pages/history/$entity->guid",
+ 'priority' => 150,
+ );
+ $return[] = ElggMenuItem::factory($options);
+
+ return $return;
+}
+
+/**
* Returns a more meaningful message
*
* @param unknown_type $hook
diff --git a/mod/pages/views/default/object/page_top.php b/mod/pages/views/default/object/page_top.php
index aca75b625..72d9720ef 100644
--- a/mod/pages/views/default/object/page_top.php
+++ b/mod/pages/views/default/object/page_top.php
@@ -51,15 +51,11 @@ if ($comments_count != 0 && !$revision) {
$comments_link = '';
}
-$history_link = elgg_view('output/url', array(
- 'href' => "pg/pages/history/$page->guid",
- 'text' => elgg_echo('pages:history'),
-));
-
-$metadata = elgg_view('navigation/menu/metadata', array(
- 'entity' => $page,
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $vars['entity'],
'handler' => 'pages',
- 'links' => array($history_link),
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
));
$subtitle = "$editor_text $categories $comments_link";
diff --git a/views/default/css/elements/navigation.php b/views/default/css/elements/navigation.php
index de63a5ce6..1f3be3539 100644
--- a/views/default/css/elements/navigation.php
+++ b/views/default/css/elements/navigation.php
@@ -422,19 +422,19 @@ li:hover > .elgg-menu-site-more {
}
/* ***************************************
- ENTITY METADATA
+ ENTITY
*************************************** */
-.elgg-menu-metadata {
+.elgg-menu-entity {
float: right;
margin-left: 15px;
font-size: 90%;
color: #aaa;
}
-.elgg-menu-metadata > li {
+.elgg-menu-entity > li {
display: inline-block;
margin-left: 15px;
}
-.elgg-menu-metadata > li > a {
+.elgg-menu-entity > li > a {
color: #aaa;
}