From 3c083f6c4ff4d354a546e03477e7a4acbb16d4a9 Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 29 Dec 2010 18:16:54 +0000 Subject: rewrote the display of likes git-svn-id: http://code.elgg.org/elgg/trunk@7748 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/core/likes/display.php | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 views/default/core/likes/display.php (limited to 'views/default/core/likes/display.php') diff --git a/views/default/core/likes/display.php b/views/default/core/likes/display.php new file mode 100644 index 000000000..bd0a8fa95 --- /dev/null +++ b/views/default/core/likes/display.php @@ -0,0 +1,61 @@ +getGUID(); + +// check to see if the user has already liked this +if (!elgg_annotation_exists($guid, 'likes')) { + $url = elgg_get_site_url() . "action/likes/add?guid={$guid}"; + $params = array( + 'href' => $url, + 'text' => '', + 'title' => elgg_echo('likes:likethis'), + 'is_action' => true, + 'encode_text' => false, + ); + $likes_button = elgg_view('output/url', $params); +} else { + $likes = get_annotations($guid, '', '', 'likes', '', get_loggedin_userid()); + $url = elgg_get_site_url() . "action/likes/delete?annotation_id={$likes[0]->id}"; + $params = array( + 'href' => $url, + 'text' => "", + 'title' => elgg_echo('likes:remove'), + 'is_action' => true, + 'encode_text' => false, + ); + $likes_button = elgg_view('output/url', $params); +} + +$list = ''; +$num_of_likes = elgg_count_likes($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-like-toggle', + ); + $list = elgg_view('output/url', $params); + $list .= ""; +} + +echo $likes_button; +echo $list; -- cgit v1.2.3