-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Likes.template.php
134 lines (116 loc) · 4.1 KB
/
Likes.template.php
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines https://www.simplemachines.org
* @copyright 2022 Simple Machines and individual contributors
* @license https://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.1.3
*/
/**
* This shows the popup that shows who likes a particular post.
*/
function template_popup()
{
global $context, $txt, $settings;
// Since this is a popup of its own we need to start the html, etc.
echo '<!DOCTYPE html>
<html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
<meta charset="', $context['character_set'], '">
<meta name="robots" content="noindex">
<title>', $context['page_title'], '</title>
', template_css(), '
<script src="', $settings['default_theme_url'], '/scripts/script.js', $context['browser_cache'], '"></script>
</head>
<body id="likes_popup">
<div class="windowbg">
<ul id="likes">';
foreach ($context['likers'] as $liker => $like_details)
echo '
<li>
', $like_details['profile']['avatar']['image'], '
<span class="like_profile">
', $like_details['profile']['link_color'], '
<span class="description">', $like_details['profile']['group'], '</span>
</span>
<span class="floatright like_time">', $like_details['time'], '</span>
</li>';
echo '
</ul>
<br class="clear">
<a href="javascript:self.close();">', $txt['close_window'], '</a>
</div><!-- .windowbg -->
</body>
</html>';
}
/**
* Display a like button and info about how many people liked something
*/
function template_like()
{
global $context, $scripturl, $txt;
// Like Count
if (!empty($context['data']['count']))
{
$context['some_likes'] = true;
$count = $context['data']['count'];
$base = 'likes_';
if ($context['data']['already_liked'])
{
$base = 'you_' . $base;
$count--;
}
$base .= (isset($txt[$base . $count])) ? $count : 'n';
}
// Quick like button?
if (isset($_REQUEST['quickbuttonlike']))
{
if (!empty($context['data']['can_like']))
echo '
<li class="post_like_button" id="', $context['data']['type'], '_', $context['data']['id_content'], '_likes"', '>
<a href="', $scripturl, '?action=likes;ltype=', $context['data']['type'], ';sa=like;quickbuttonlike;like=', $context['data']['id_content'], ';', $context['session_var'], '=', $context['session_id'], '" class="', $context['data']['type'], '_quicklike">
<span class="main_icons ', $context['data']['already_liked'] ? 'unlike' : 'like', '"></span>
<span>
', $context['data']['already_liked'] ? $txt['unlike'] : $txt['like'], '
</span>
</a>';
if (!empty($context['some_likes']))
echo '
<span class="amt">
<a class="buttonlike_count" href="' . $scripturl . '?action=likes;sa=view;ltype=' . $context['data']['type'] . ';js=1;like=' . $context['data']['id_content'] . ';' . $context['session_var'] . '=' . $context['session_id'], '">
<em style="display: none;">', $txt['likes'], '</em>
' . $context['data']['count'] . '
</a>
</span>';
echo '
</li>';
}
// Regular like
else
{
echo '
<ul class="floatleft">';
if (!empty($context['data']['can_like']))
echo '
<li class="smflikebutton" id="', $context['data']['type'], '_', $context['data']['id_content'], '_likes"', '>
<a href="', $scripturl, '?action=likes;ltype=', $context['data']['type'], ';sa=like;like=', $context['data']['id_content'], ';', $context['session_var'], '=', $context['session_id'], '" class="', $context['data']['type'], '_like"><span class="main_icons ', $context['data']['already_liked'] ? 'unlike' : 'like', '"></span> ', $context['data']['already_liked'] ? $txt['unlike'] : $txt['like'], '</a>
</li>';
if (!empty($context['some_likes']))
echo '
<li class="like_count smalltext">', sprintf($txt[$base], $scripturl . '?action=likes;sa=view;ltype=' . $context['data']['type'] . ';js=1;like=' . $context['data']['id_content'] . ';' . $context['session_var'] . '=' . $context['session_id'], comma_format($count)), '</li>';
echo '
</ul>';
}
}
/**
* A generic template that outputs any data passed to it...
*/
function template_generic()
{
global $context;
echo $context['data'];
}
?>