aboutsummaryrefslogtreecommitdiff
path: root/mod/likes/views
diff options
context:
space:
mode:
Diffstat (limited to 'mod/likes/views')
-rw-r--r--mod/likes/views/default/annotation/likes.php48
-rw-r--r--mod/likes/views/default/likes/css.php13
-rw-r--r--mod/likes/views/default/likes/display.php67
-rw-r--r--mod/likes/views/default/river/annotation/likes/create.php26
4 files changed, 154 insertions, 0 deletions
diff --git a/mod/likes/views/default/annotation/likes.php b/mod/likes/views/default/annotation/likes.php
new file mode 100644
index 000000000..e1ae20818
--- /dev/null
+++ b/mod/likes/views/default/annotation/likes.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Elgg show the users who liked the object
+ *
+ * @uses $vars['annotation']
+ */
+
+if (!isset($vars['annotation'])) {
+ return true;
+}
+
+$like = $vars['annotation'];
+
+$user = $like->getOwnerEntity();
+if (!$user) {
+ return true;
+}
+
+$user_icon = elgg_view_entity_icon($user, 'tiny');
+$user_link = elgg_view('output/url', array(
+ 'href' => $user->getURL(),
+ 'text' => $user->name,
+));
+
+$likes_string = elgg_echo('likes:this');
+
+$friendlytime = elgg_view_friendly_time($like->time_created);
+
+if ($like->canEdit()) {
+ $delete_button = elgg_view("output/confirmlink",array(
+ 'href' => "action/likes/delete?annotation_id={$like->id}",
+ 'text' => "<span class=\"elgg-icon elgg-icon-delete right\"></span>",
+ 'confirm' => elgg_echo('deleteconfirm'),
+ 'text_encode' => false,
+ ));
+}
+
+$body = <<<HTML
+<p class="mbn">
+ $delete_button
+ $user_link $likes_string
+ <span class="elgg-subtext">
+ $friendlytime
+ </span>
+</p>
+HTML;
+
+echo elgg_view_image_block($user_icon, $body);
diff --git a/mod/likes/views/default/likes/css.php b/mod/likes/views/default/likes/css.php
new file mode 100644
index 000000000..cb0334b7c
--- /dev/null
+++ b/mod/likes/views/default/likes/css.php
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Likes CSS
+ */
+?>
+
+/* ***************************************
+ Likes
+*************************************** */
+.elgg-likes-list {
+ width: 345px;
+ position: absolute;
+}
diff --git a/mod/likes/views/default/likes/display.php b/mod/likes/views/default/likes/display.php
new file mode 100644
index 000000000..00f6c5a34
--- /dev/null
+++ b/mod/likes/views/default/likes/display.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Elgg likes display
+ *
+ * @package Elgg
+ *
+ * @uses $vars['entity']
+ */
+
+if (!isset($vars['entity'])) {
+ return true;
+}
+
+$guid = $vars['entity']->getGUID();
+
+// check to see if the user has already liked this
+if (elgg_is_logged_in() && $vars['entity']->canAnnotate(0, 'likes')) {
+ if (!elgg_annotation_exists($guid, 'likes')) {
+ $url = elgg_get_site_url() . "action/likes/add?guid={$guid}";
+ $params = array(
+ 'href' => $url,
+ 'text' => elgg_view_icon('thumbs-up'),
+ 'title' => elgg_echo('likes:likethis'),
+ 'is_action' => true,
+ );
+ $likes_button = elgg_view('output/url', $params);
+ } else {
+ $options = array(
+ 'guid' => $guid,
+ 'annotation_name' => 'likes',
+ 'owner_guid' => elgg_get_logged_in_user_guid()
+ );
+ $likes = elgg_get_annotations($options);
+ $url = elgg_get_site_url() . "action/likes/delete?annotation_id={$likes[0]->id}";
+ $params = array(
+ 'href' => $url,
+ 'text' => elgg_view_icon('thumbs-up-alt'),
+ 'title' => elgg_echo('likes:remove'),
+ 'is_action' => true,
+ );
+ $likes_button = elgg_view('output/url', $params);
+ }
+}
+
+$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');
+ } else {
+ $likes_string = elgg_echo('likes:userslikedthis');
+ }
+ $params = array(
+ 'text' => "$num_of_likes $likes_string",
+ 'title' => elgg_echo('likes:see'),
+ 'class' => 'elgg-popup-rb-at-lt',
+ 'rel' => 'popup',
+ 'href' => "#$guid-likes"
+ );
+ $list = elgg_view('output/url', $params);
+ $list .= "<div class='elgg-module elgg-module-popup elgg-likes-list hidden clearfix' id='$guid-likes'>";
+ $list .= elgg_list_annotations(array('guid' => $guid, 'annotation_name' => 'likes', 'limit' => 99));
+ $list .= "</div>";
+}
+
+echo elgg_view_image_block($likes_button, $list); \ No newline at end of file
diff --git a/mod/likes/views/default/river/annotation/likes/create.php b/mod/likes/views/default/river/annotation/likes/create.php
new file mode 100644
index 000000000..463fe5049
--- /dev/null
+++ b/mod/likes/views/default/river/annotation/likes/create.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Likes river view
+ *
+ * @todo not finished
+ */
+
+$object = $vars['item']->getObjectEntity();
+$comment = $vars['item']->getAnnotation();
+
+$url = $object->getURL();
+$title = $object->title;
+if (!$title) {
+ $title = elgg_echo('untitled');
+}
+$params = array(
+ 'href' => $object->getURL(),
+ 'text' => $title,
+);
+$object_link = elgg_view('output/url', $params);
+
+$type = $object->getType();
+$subtype = $object->getSubtype();
+
+$type_string = elgg_echo("river:commented:$type:$subtype");
+echo elgg_echo('river:likes', array($type_string, $object_link));