blob: 93c4ce983ec972a8796fe4e46d100d2c173bf885 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<?php
/**
* Elgg likes add form
*
* @package Elgg
*
* @uses $vars['entity']
*/
if (isset($vars['entity']) && isloggedin()) {
$guid = $vars['entity']->getGUID();
$url = elgg_get_site_url() . "action/likes/add?guid={$guid}";
//check to see if the user has already liked
if (!elgg_annotation_exists($guid, 'likes') ) {
$params = array(
'href' => $url,
'text' => '<span class="elgg-icon elgg-icon-likes"></span>',
'title' => elgg_echo('likes:likethis'),
'is_action' => true,
);
echo elgg_view('output/url', $params);
$likes_classname = 'elgg-icon-likes';
$likes_titletag = "";
} else {
$likes_classname = 'elgg-icon-liked';
$likes_titletag = elgg_echo('likes:remove');
}
//display the number of likes
$numoflikes = elgg_count_likes($vars['entity']);
if ($numoflikes != 0) {
if ($numoflikes == 1) {
$user_string = elgg_echo('likes:userlikedthis');
} else {
$user_string = elgg_echo('likes:userslikedthis');
}
$params = array(
'href' => $url,
'text' => "<span class=\"elgg-icon $likes_classname\"></span>" . elgg_count_likes($vars['entity']) . " " . $user_string,
'title' => $likes_titletag,
'is_action' => true,
);
echo elgg_view('output/url', $params);
//show the users who liked the object
echo "<div class='likes-list hidden clearfix'>";
echo list_annotations($vars['entity']->getGUID(), 'likes', 99);
echo "</div>";
}
}
|