]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #3750. Added annotation menu for generic comments (delete) and default annotatio...
authorBrett Profitt <brett.profitt@gmail.com>
Thu, 25 Aug 2011 00:06:39 +0000 (17:06 -0700)
committerBrett Profitt <brett.profitt@gmail.com>
Thu, 25 Aug 2011 00:06:39 +0000 (17:06 -0700)
engine/lib/navigation.php
views/default/annotation/default.php
views/default/annotation/generic_comment.php
views/default/css/elements/navigation.php

index 1305ee3def1009276eee188bfe0faafee33790bf..cefe40ecf5e3d5cd13a946373c41d8b072567938 100644 (file)
@@ -372,6 +372,31 @@ function elgg_entity_menu_setup($hook, $type, $return, $params) {
        return $return;
 }
 
+/**
+ * Adds a delete link to "generic_comment" annotations
+ */
+function elgg_annotation_menu_setup($hook, $type, $return, $params) {
+       $annotation = $params['annotation'];
+
+       if ($annotation->name == 'generic_comment' && $annotation->canEdit()) {
+               $url = elgg_http_add_url_query_elements('action/comments/delete', array(
+                       'annotation_id' => $annotation->id,
+               ));
+
+               $options = array(
+                       'name' => 'delete',
+                       'href' => $url,
+                       'text' => "<span class=\"elgg-icon elgg-icon-delete\"></span>",
+                       'confirm' => elgg_echo('deleteconfirm'),
+                       'text_encode' => false
+               );
+               $return[] = ElggMenuItem::factory($options);
+       }
+
+       return $return;
+}
+
+
 /**
  * Navigation initialization
  */
@@ -379,6 +404,7 @@ 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_plugin_hook_handler('register', 'menu:annotation', 'elgg_annotation_menu_setup');
 }
 
 elgg_register_event_handler('init', 'system', 'elgg_nav_init');
index a21fdee51fbc41cec1677ce679eee97402020c34..0e626ad9a11997d8c5b62a7319e841b44e508100 100644 (file)
@@ -2,9 +2,9 @@
 /**
  * Elgg default annotation view
  *
+ * @note To add or remove from the annotation menu, register handlers for the menu:annotation hook.
+ *
  * @uses $vars['annotation']
- * @uses $vars['delete_action'] A custom action for the delete button.
- *                              The annotation ID is passed as 'annotation_id'.
  */
 
 $annotation = $vars['annotation'];
@@ -16,28 +16,19 @@ if (!$owner) {
 $icon = elgg_view_entity_icon($owner, 'tiny');
 $owner_link = "<a href=\"{$owner->getURL()}\">$owner->name</a>";
 
-$delete_action = elgg_extract('delete_action', $vars, '');
+$menu = elgg_view_menu('annotation', array(
+       'annotation' => $annotation,
+       'sort_by' => 'priority',
+       'class' => 'elgg-menu-hz right',
+));
 
 $text = elgg_view("output/longtext", array("value" => $annotation->value));
 
 $friendlytime = elgg_view_friendly_time($annotation->time_created);
 
-$delete_button = '';
-if ($delete_action && $annotation->canEdit()) {
-       $url = elgg_http_add_url_query_elements($delete_action, array(
-               'annotation_id' => $annotation->id,
-       ));
-       $delete_button = elgg_view("output/confirmlink", array(
-                                               'href' => $url,
-                                               'text' => "<span class=\"elgg-icon elgg-icon-delete right\"></span>",
-                                               'confirm' => elgg_echo('deleteconfirm'),
-                                               'text_encode' => false,
-                                       ));
-}
-
 $body = <<<HTML
 <div class="mbn">
-       $delete_button
+       $menu
        $owner_link
        <span class="elgg-subtext">
                $friendlytime
index 69520d1021e2493fe8ae12aee11e1a5c60a93d59..a4fbf904e18a71ac78f82c71e304970e32081325 100644 (file)
@@ -29,23 +29,17 @@ $entity_title = $entity->title ? $entity->title : elgg_echo('untitled');
 $entity_link = "<a href=\"{$entity->getURL()}\">$entity_title</a>";
 
 if ($full_view) {
-
-       $delete_button = '';
-       if ($comment->canEdit()) {
-               $url = "action/comments/delete?annotation_id=$comment->id";
-               $delete_button = elgg_view("output/confirmlink", array(
-                                                       'href' => $url,
-                                                       'text' => "<span class=\"elgg-icon elgg-icon-delete right\"></span>",
-                                                       'confirm' => elgg_echo('deleteconfirm'),
-                                                       'text_encode' => false,
-                                               ));
-       }
+       $menu = elgg_view_menu('annotation', array(
+               'annotation' => $comment,
+               'sort_by' => 'priority',
+               'class' => 'elgg-menu-hz right',
+       ));
 
        $comment_text = elgg_view("output/longtext", array("value" => $comment->value));
 
        $body = <<<HTML
 <div class="mbn">
-       $delete_button
+       $menu
        $commenter_link
        <span class="elgg-subtext">
                $friendlytime
index 64b7c47b4ccd605c571f351c38d0263a036ce688..b5388715e9573e503d708ae20237484ce7023973 100644 (file)
@@ -424,10 +424,10 @@ li:hover > .elgg-menu-site-more {
 }
 
 /* ***************************************
-       ENTITY
+       ENTITY AND ANNOTATION
 *************************************** */
 <?php // height depends on line height/font size ?>
-.elgg-menu-entity {
+.elgg-menu-entity, elgg-menu-annotation {
        float: right;
        margin-left: 15px;
        font-size: 90%;
@@ -435,17 +435,17 @@ li:hover > .elgg-menu-site-more {
        line-height: 16px;
        height: 16px;
 }
-.elgg-menu-entity > li {
+.elgg-menu-entity > li, .elgg-menu-annotation > li {
        margin-left: 15px;
 }
-.elgg-menu-entity > li > a {
+.elgg-menu-entity > li > a, .elgg-menu-annotation > li > a {
        color: #aaa;
 }
 <?php // need to override .elgg-menu-hz ?>
-.elgg-menu-entity > li > a {
+.elgg-menu-entity > li > a, .elgg-menu-annotation > li > a {
        display: block;
 }
-.elgg-menu-entity > li > span {
+.elgg-menu-entity > li > span, .elgg-menu-annotation > li > span {
        vertical-align: baseline;
 }