aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-06-25 09:52:54 -0400
committerCash Costello <cash.costello@gmail.com>2011-06-25 09:52:54 -0400
commita2c9bf0f294758dc546adaf27120ba1880d2832a (patch)
tree080fe487d28da6dba6f2b8f5a0d123f1ea94044a
parent30958fd27d81717354bc04e029213239f6b9bc6b (diff)
downloadelgg-a2c9bf0f294758dc546adaf27120ba1880d2832a.tar.gz
elgg-a2c9bf0f294758dc546adaf27120ba1880d2832a.tar.bz2
Fixes #3566 separate out likes button from likes count
-rw-r--r--mod/likes/start.php31
-rw-r--r--mod/likes/views/default/likes/button.php25
-rw-r--r--mod/likes/views/default/likes/count.php30
-rw-r--r--mod/likes/views/default/likes/css.php4
-rw-r--r--views/default/river/elements/body.php6
5 files changed, 68 insertions, 28 deletions
diff --git a/mod/likes/start.php b/mod/likes/start.php
index b2aa83260..df1c7b109 100644
--- a/mod/likes/start.php
+++ b/mod/likes/start.php
@@ -29,15 +29,27 @@ function likes_entity_menu_setup($hook, $type, $return, $params) {
$entity = $params['entity'];
- // likes
+ // likes button
$options = array(
'name' => 'likes',
- 'text' => elgg_view('likes/display', array('entity' => $entity)),
+ 'text' => elgg_view('likes/button', array('entity' => $entity)),
'href' => false,
'priority' => 1000,
);
$return[] = ElggMenuItem::factory($options);
+ // likes count
+ $count = elgg_view('likes/count', array('entity' => $entity));
+ if ($count) {
+ $options = array(
+ 'name' => 'likes_count',
+ 'text' => $count,
+ 'href' => false,
+ 'priority' => 1001,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+
return $return;
}
@@ -50,14 +62,27 @@ function likes_river_menu_setup($hook, $type, $return, $params) {
$object = $item->getObjectEntity();
if (!elgg_in_context('widgets') && $item->annotation_id == 0) {
if ($object->canAnnotate(0, 'likes')) {
+ // like button
$options = array(
'name' => 'likes',
'href' => false,
- 'text' => elgg_view('likes/display', array('entity' => $object)),
+ 'text' => elgg_view('likes/button', array('entity' => $object)),
'is_action' => true,
'priority' => 100,
);
$return[] = ElggMenuItem::factory($options);
+
+ // likes count
+ $count = elgg_view('likes/count', array('entity' => $object));
+ if ($count) {
+ $options = array(
+ 'name' => 'likes_count',
+ 'text' => $count,
+ 'href' => false,
+ 'priority' => 101,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
}
}
}
diff --git a/mod/likes/views/default/likes/button.php b/mod/likes/views/default/likes/button.php
index 2dc50ddd0..383e1bb63 100644
--- a/mod/likes/views/default/likes/button.php
+++ b/mod/likes/views/default/likes/button.php
@@ -1,6 +1,6 @@
<?php
/**
- * Elgg likes display
+ * Elgg likes button
*
* @uses $vars['entity']
*/
@@ -40,26 +40,3 @@ if (elgg_is_logged_in() && $vars['entity']->canAnnotate(0, 'likes')) {
}
echo $likes_button;
-
-$list = '';
-$num_of_likes = likes_count($vars['entity']);
-
-if ($num_of_likes) {
- // display the number of likes
- if ($num_of_likes == 1) {
- $likes_string = elgg_echo('likes:userlikedthis', array($num_of_likes));
- } else {
- $likes_string = elgg_echo('likes:userslikedthis', array($num_of_likes));
- }
- $params = array(
- 'text' => $likes_string,
- 'title' => elgg_echo('likes:see'),
- 'rel' => 'popup',
- 'href' => "#likes-$guid"
- );
- $list = elgg_view('output/url', $params);
- $list .= "<div class='elgg-module elgg-module-popup elgg-likes-list hidden clearfix' id='likes-$guid'>";
- $list .= elgg_list_annotations(array('guid' => $guid, 'annotation_name' => 'likes', 'limit' => 99));
- $list .= "</div>";
- echo $list;
-}
diff --git a/mod/likes/views/default/likes/count.php b/mod/likes/views/default/likes/count.php
new file mode 100644
index 000000000..3d03fec66
--- /dev/null
+++ b/mod/likes/views/default/likes/count.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Count of who has liked something
+ *
+ * @uses $vars['entity']
+ */
+
+
+$list = '';
+$num_of_likes = likes_count($vars['entity']);
+
+if ($num_of_likes) {
+ // display the number of likes
+ if ($num_of_likes == 1) {
+ $likes_string = elgg_echo('likes:userlikedthis', array($num_of_likes));
+ } else {
+ $likes_string = elgg_echo('likes:userslikedthis', array($num_of_likes));
+ }
+ $params = array(
+ 'text' => $likes_string,
+ 'title' => elgg_echo('likes:see'),
+ 'rel' => 'popup',
+ 'href' => "#likes-$guid"
+ );
+ $list = elgg_view('output/url', $params);
+ $list .= "<div class='elgg-module elgg-module-popup elgg-likes-list hidden clearfix' id='likes-$guid'>";
+ $list .= elgg_list_annotations(array('guid' => $guid, 'annotation_name' => 'likes', 'limit' => 99));
+ $list .= "</div>";
+ echo $list;
+}
diff --git a/mod/likes/views/default/likes/css.php b/mod/likes/views/default/likes/css.php
index cb0334b7c..fabf54e46 100644
--- a/mod/likes/views/default/likes/css.php
+++ b/mod/likes/views/default/likes/css.php
@@ -11,3 +11,7 @@
width: 345px;
position: absolute;
}
+
+.elgg-menu .elgg-menu-item-likes-count {
+ margin-left: 3px;
+}
diff --git a/views/default/river/elements/body.php b/views/default/river/elements/body.php
index 7eebb0c99..6199e0861 100644
--- a/views/default/river/elements/body.php
+++ b/views/default/river/elements/body.php
@@ -7,7 +7,11 @@
$item = $vars['item'];
-$menu = elgg_view_menu('river', array('item' => $item, 'sort_by' => 'priority'));
+$menu = elgg_view_menu('river', array(
+ 'item' => $item,
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+));
// river item header
$timestamp = elgg_get_friendly_time($item->getPostedTime());