Issues (1065)

Themes/default/Likes.template.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines https://www.simplemachines.org
7
 * @copyright 2022 Simple Machines and individual contributors
8
 * @license https://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1.3
11
 */
12
13
/**
14
 * This shows the popup that shows who likes a particular post.
15
 */
16
function template_popup()
17
{
18
	global $context, $settings, $txt, $modSettings;
19
20
	// Since this is a popup of its own we need to start the html, etc.
21
	echo '<!DOCTYPE html>
22
<html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
23
	<head>
24
		<meta charset="', $context['character_set'], '">
25
		<meta name="robots" content="noindex">
26
		<title>', $context['page_title'], '</title>
27
		', template_css(), '
0 ignored issues
show
Are you sure the usage of template_css() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
28
		<script src="', $settings['default_theme_url'], '/scripts/script.js', $context['browser_cache'], '"></script>
29
	</head>
30
	<body id="likes_popup">
31
		<div class="windowbg">
32
			<ul id="likes">';
33
34
	foreach ($context['likers'] as $liker => $like_details)
35
		echo '
36
				<li>
37
					', $like_details['profile']['avatar']['image'], '
38
					<span class="like_profile">
39
						', $like_details['profile']['link_color'], '
40
						<span class="description">', $like_details['profile']['group'], '</span>
41
					</span>
42
					<span class="floatright like_time">', $like_details['time'], '</span>
43
				</li>';
44
45
	echo '
46
			</ul>
47
			<br class="clear">
48
			<a href="javascript:self.close();">', $txt['close_window'], '</a>
49
		</div><!-- .windowbg -->
50
	</body>
51
</html>';
52
}
53
54
/**
55
 * Display a like button and info about how many people liked something
56
 */
57
function template_like()
58
{
59
	global $context, $scripturl, $txt;
60
61
	echo '
62
	<ul class="floatleft">';
63
64
	if (!empty($context['data']['can_like']))
65
		echo '
66
		<li class="smflikebutton" id="', $context['data']['type'], '_', $context['data']['id_content'], '_likes"', '>
67
			<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>
68
		</li>';
69
70
	if (!empty($context['data']['count']))
71
	{
72
		$context['some_likes'] = true;
73
		$count = $context['data']['count'];
74
		$base = 'likes_';
75
76
		if ($context['data']['already_liked'])
77
		{
78
			$base = 'you_' . $base;
79
			$count--;
80
		}
81
82
		$base .= (isset($txt[$base . $count])) ? $count : 'n';
83
84
		echo '
85
		<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>';
86
	}
87
88
	echo '
89
	</ul>';
90
}
91
92
/**
93
 * A generic template that outputs any data passed to it...
94
 */
95
function template_generic()
96
{
97
	global $context;
98
99
	echo $context['data'];
100
}
101
102
?>