Issues (1014)

Themes/default/Recent.template.php (2 issues)

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.0
11
 */
12
13
/**
14
 * Template for showing recent posts
15
 */
16
function template_recent()
17
{
18
	global $context, $txt;
19
20
	echo '
21
	<div id="recent" class="main_section">
22
		<div id="display_head" class="information">
23
			<h2 class="display_title">
24
				<span id="top_subject">', $txt['recent_posts'], '</span>
25
			</h2>
26
		</div>';
27
28
	if (!empty($context['page_index']))
29
		echo '
30
		<div class="pagesection">
31
			<div class="pagelinks">' . $context['page_index'] . '</div>
32
		</div>';
33
34
	if (empty($context['posts']))
35
		echo '
36
		<div class="windowbg">', $txt['no_messages'], '</div>';
37
38
	foreach ($context['posts'] as $post)
39
	{
40
		echo '
41
		<div class="', $post['css_class'], '">
42
			<div class="page_number floatright"> #', $post['counter'], '</div>
43
			<div class="topic_details">
44
				<h5>', $post['board']['link'], ' / ', $post['link'], '</h5>
45
				<span class="smalltext">', $txt['last_poster'], ' <strong>', $post['poster']['link'], ' </strong> - ', $post['time'], '</span>
46
			</div>
47
			<div class="list_posts">', $post['message'], '</div>';
48
49
		// Post options
50
		template_quickbuttons($post['quickbuttons'], 'recent');
51
52
		echo '
53
		</div><!-- $post[css_class] -->';
54
	}
55
56
	echo '
57
		<div class="pagesection">
58
			<div class="pagelinks">', $context['page_index'], '</div>
59
		</div>
60
	</div><!-- #recent -->';
61
}
62
63
/**
64
 * Template for showing unread posts
65
 */
66
function template_unread()
67
{
68
	global $context, $txt, $scripturl, $modSettings, $board_info;
69
70
	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
71
	if (!empty($context['recent_buttons']))
72
		echo '
73
	<div id="mobile_action" class="popup_container">
74
		<div class="popup_window description">
75
			<div class="popup_heading">
76
				', $txt['mobile_action'], '
77
				<a href="javascript:void(0);" class="main_icons hide_popup"></a>
78
			</div>
79
			', template_button_strip($context['recent_buttons']), '
0 ignored issues
show
Are you sure the usage of template_button_strip($context['recent_buttons']) 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...
80
		</div>
81
	</div>';
82
83
	echo '
84
	<div id="recent" class="main_content">
85
		<div id="display_head" class="information">
86
			<h2 class="display_title">
87
				<span>', (!empty($board_info['name']) ? $board_info['name'] . ' - ' : '') . $context['page_title'], '</span>
88
			</h2>
89
		</div>';
90
91
	if ($context['showCheckboxes'])
92
		echo '
93
		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
94
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
95
			<input type="hidden" name="qaction" value="markread">
96
			<input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
97
98
	if (!empty($context['topics']))
99
	{
100
		echo '
101
			<div class="pagesection">
102
				', $context['menu_separator'], '
103
				<div class="pagelinks floatleft">
104
					<a href="#bot" class="button">', $txt['go_down'], '</a>
105
					', $context['page_index'], '
106
				</div>
107
				', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '';
108
109
		// Mobile action (top)
110
		if (!empty($context['recent_buttons']))
111
			echo '
112
				<div class="mobile_buttons floatright">
113
					<a class="button mobile_act">', $txt['mobile_action'], '</a>
114
				</div>';
115
116
		echo '
117
			</div>';
118
119
		echo '
120
			<div id="unread">
121
				<div id="topic_header" class="title_bar">
122
					<div class="board_icon"></div>
123
					<div class="info">
124
						<a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['subject'], $context['sort_by'] == 'subject' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
125
					</div>
126
					<div class="board_stats centertext">
127
						<a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['replies'], $context['sort_by'] == 'replies' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
128
					</div>
129
					<div class="lastpost">
130
						<a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] == 'last_post' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
131
					</div>';
132
133
		// Show a "select all" box for quick moderation?
134
		if ($context['showCheckboxes'])
135
			echo '
136
					<div class="moderation">
137
						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
138
					</div>';
139
140
		echo '
141
				</div><!-- #topic_header -->
142
				<div id="topic_container">';
143
144
		foreach ($context['topics'] as $topic)
145
		{
146
			echo '
147
					<div class="', $topic['css_class'], '">
148
						<div class="board_icon">
149
							<img src="', $topic['first_post']['icon_url'], '" alt="">
150
							', $topic['is_posted_in'] ? '<span class="main_icons profile_sm"></span>' : '', '
151
						</div>
152
						<div class="info">';
153
154
			// Now we handle the icons
155
			echo '
156
							<div class="icons floatright">';
157
158
			if ($topic['is_locked'])
159
				echo '
160
								<span class="main_icons lock"></span>';
161
162
			if ($topic['is_sticky'])
163
				echo '
164
								<span class="main_icons sticky"></span>';
165
166
			if ($topic['is_poll'])
167
				echo '
168
								<span class="main_icons poll"></span>';
169
170
			echo '
171
							</div>';
172
173
			echo '
174
							<div class="recent_title">
175
								<a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '" class="new_posts">' . $txt['new'] . '</a>
176
								', $topic['is_sticky'] ? '<strong>' : '', '<span class="preview" title="', $topic[(empty($modSettings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span></span>', $topic['is_sticky'] ? '</strong>' : '', '
177
							</div>
178
							<p class="floatleft">
179
								', $topic['first_post']['started_by'], '
180
							</p>
181
							', !empty($topic['pages']) ? '<span id="pages' . $topic['first_post']['id'] . '" class="topic_pages">' . $topic['pages'] . '</span>' : '', '
182
						</div><!-- .info -->
183
						<div class="board_stats centertext">
184
							<p>
185
								', $topic['replies'], ' ', $txt['replies'], '
186
								<br>
187
								', $topic['views'], ' ', $txt['views'], '
188
							</p>
189
						</div>
190
						<div class="lastpost">
191
							', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
192
						</div>';
193
194
			if ($context['showCheckboxes'])
195
				echo '
196
						<div class="moderation">
197
							<input type="checkbox" name="topics[]" value="', $topic['id'], '">
198
						</div>';
199
200
			echo '
201
					</div><!-- $topic[css_class] -->';
202
		}
203
204
		if (empty($context['topics']))
205
			echo '
206
					<div style="display: none;"></div>';
207
208
		echo '
209
				</div><!-- #topic_container -->
210
			</div><!-- #unread -->';
211
212
		echo '
213
			<div class="pagesection">
214
				', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '', '
215
				', $context['menu_separator'], '
216
				<div class="pagelinks floatleft">
217
					<a href="#recent" class="button">', $txt['go_up'], '</a>
218
					', $context['page_index'], '
219
				</div>';
220
221
		// Mobile action (bottom)
222
		if (!empty($context['recent_buttons']))
223
		echo '
224
				<div class="mobile_buttons floatright">
225
					<a class="button mobile_act">', $txt['mobile_action'], '</a>
226
				</div>';
227
228
		echo '
229
			</div>';
230
	}
231
	else
232
		echo '
233
			<div class="infobox">
234
				<p class="centertext">
235
					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : sprintf($txt['unread_topics_visit_none'], $scripturl), '
236
				</p>
237
			</div>';
238
239
	if ($context['showCheckboxes'])
240
		echo '
241
		</form>';
242
243
	echo '
244
	</div><!-- #recent -->';
245
246
	if (empty($context['no_topic_listing']))
247
		template_topic_legend();
248
}
249
250
/**
251
 * Template for showing unread replies (eg new replies to topics you've posted in)
252
 */
253
function template_replies()
254
{
255
	global $context, $txt, $scripturl, $modSettings, $board_info;
256
257
	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
258
	if (!empty($context['recent_buttons']))
259
		echo '
260
	<div id="mobile_action" class="popup_container">
261
		<div class="popup_window description">
262
			<div class="popup_heading">
263
				', $txt['mobile_action'], '
264
				<a href="javascript:void(0);" class="main_icons hide_popup"></a>
265
			</div>
266
			', template_button_strip($context['recent_buttons']), '
0 ignored issues
show
Are you sure the usage of template_button_strip($context['recent_buttons']) 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...
267
		</div>
268
	</div>';
269
270
	echo '
271
	<div id="recent">
272
		<div id="display_head" class="information">
273
			<h2 class="display_title">
274
				<span>', (!empty($board_info['name']) ? $board_info['name'] . ' - ' : '') . $context['page_title'], '</span>
275
			</h2>
276
		</div>';
277
278
	if ($context['showCheckboxes'])
279
		echo '
280
		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
281
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
282
			<input type="hidden" name="qaction" value="markread">
283
			<input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
284
285
	if (!empty($context['topics']))
286
	{
287
		echo '
288
			<div class="pagesection">
289
				', $context['menu_separator'], '
290
				<div class="pagelinks floatleft">
291
					<a href="#bot" class="button">', $txt['go_down'], '</a>
292
					', $context['page_index'], '
293
				</div>
294
				', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '';
295
296
		// Mobile action (top)
297
		if (!empty($context['recent_buttons']))
298
			echo '
299
				<div class="mobile_buttons floatright">
300
					<a class="button mobile_act">', $txt['mobile_action'], '</a>
301
				</div>';
302
303
		echo '
304
			</div>';
305
306
		echo '
307
			<div id="unreadreplies">
308
				<div id="topic_header" class="title_bar">
309
					<div class="board_icon"></div>
310
					<div class="info">
311
						<a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=subject', $context['sort_by'] === 'subject' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['subject'], $context['sort_by'] === 'subject' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
312
					</div>
313
					<div class="board_stats centertext">
314
						<a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=replies', $context['sort_by'] === 'replies' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['replies'], $context['sort_by'] === 'replies' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
315
					</div>
316
					<div class="lastpost">
317
						<a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] === 'last_post' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] === 'last_post' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
318
					</div>';
319
320
		// Show a "select all" box for quick moderation?
321
		if ($context['showCheckboxes'])
322
			echo '
323
					<div class="moderation">
324
						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
325
					</div>';
326
327
		echo '
328
				</div><!-- #topic_header -->
329
				<div id="topic_container">';
330
331
		foreach ($context['topics'] as $topic)
332
		{
333
			echo '
334
					<div class="', $topic['css_class'], '">
335
						<div class="board_icon">
336
							<img src="', $topic['first_post']['icon_url'], '" alt="">
337
							', $topic['is_posted_in'] ? '<span class="main_icons profile_sm"></span>' : '', '
338
						</div>
339
						<div class="info">';
340
341
			// Now we handle the icons
342
			echo '
343
							<div class="icons floatright">';
344
345
			if ($topic['is_locked'])
346
				echo '
347
								<span class="main_icons lock"></span>';
348
349
			if ($topic['is_sticky'])
350
				echo '
351
								<span class="main_icons sticky"></span>';
352
353
			if ($topic['is_poll'])
354
				echo '
355
								<span class="main_icons poll"></span>';
356
357
			echo '
358
							</div>';
359
360
			echo '
361
							<div class="recent_title">
362
								<a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '" class="new_posts">' . $txt['new'] . '</a>
363
								', $topic['is_sticky'] ? '<strong>' : '', '<span title="', $topic[(empty($modSettings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
364
							</div>
365
							<p class="floatleft">
366
								', $topic['first_post']['started_by'], '
367
							</p>
368
							', !empty($topic['pages']) ? '<span id="pages' . $topic['first_post']['id'] . '" class="topic_pages">' . $topic['pages'] . '</span>' : '', '
369
						</div><!-- .info -->
370
						<div class="board_stats centertext">
371
							<p>
372
								', $topic['replies'], ' ', $txt['replies'], '
373
								<br>
374
								', $topic['views'], ' ', $txt['views'], '
375
							</p>
376
						</div>
377
						<div class="lastpost">
378
							', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
379
						</div>';
380
381
			if ($context['showCheckboxes'])
382
				echo '
383
						<div class="moderation">
384
							<input type="checkbox" name="topics[]" value="', $topic['id'], '">
385
						</div>';
386
387
			echo '
388
					</div><!-- $topic[css_class] -->';
389
		}
390
391
		echo '
392
				</div><!-- #topic_container -->
393
			</div><!-- #unreadreplies -->
394
			<div class="pagesection">
395
				', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '', '
396
				', $context['menu_separator'], '
397
				<div class="pagelinks floatleft">
398
					<a href="#recent" class="button">', $txt['go_up'], '</a>
399
					', $context['page_index'], '
400
				</div>';
401
402
		// Mobile action (bottom)
403
		if (!empty($context['recent_buttons']))
404
			echo '
405
				<div class="mobile_buttons floatright">
406
					<a class="button mobile_act">', $txt['mobile_action'], '</a>
407
				</div>';
408
409
		echo '
410
			</div>';
411
	}
412
	else
413
		echo '
414
			<div class="infobox">
415
				<p class="centertext">
416
					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['updated_topics_visit_none'], '
417
				</p>
418
			</div>';
419
420
	if ($context['showCheckboxes'])
421
		echo '
422
		</form>';
423
424
	echo '
425
	</div><!-- #recent -->';
426
427
	if (empty($context['no_topic_listing']))
428
		template_topic_legend();
429
}
430
431
?>