Passed
Push — development ( e6e944...f737f3 )
by Spuds
01:21 queued 34s
created

template_keyinfo()   B

Complexity

Conditions 9
Paths 2

Size

Total Lines 39
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 18
dl 0
loc 39
rs 8.0555
c 0
b 0
f 0
nc 2
nop 3
1
<?php
2
3
/**
4
 * @package   ElkArte Forum
5
 * @copyright ElkArte Forum contributors
6
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
7
 *
8
 * This file contains code covered by:
9
 * copyright: 2011 Simple Machines (http://www.simplemachines.org)
10
 *
11
 * @version 2.0 dev
12
 *
13
 */
14
15
use ElkArte\Helper\Util;
16
17
/**
18
 * Loads the template of the poster area
19
 */
20
function template_Display_init()
21
{
22
	theme()->getTemplates()->load('GenericMessages');
23
}
24
25
/**
26
 * Show a status block above the report to staff page
27
 */
28
function template_report_sent_above()
29
{
30
	global $txt;
31
32
	// Let them know their report was a success!
33
	echo '
34
		<div class="successbox">
35
			', $txt['report_sent'], '
36
		</div>';
37
}
38
39
/**
40
 * Topic information, descriptions, etc.
41
 */
42
function template_messages_informations_above()
43
{
44
	global $context, $settings, $txt, $scripturl, $modSettings;
45
46
	// Show the topic information - icon, subject, etc.
47
	echo '
48
		<main id="forumposts">
49
			<header class="category_header">
50
				<i class="hdicon ', $context['class'], '"></i>
51
				', $txt['topic'], ': ', $context['subject'], '&nbsp;<span class="views_text">(', $context['num_views_text'], ')</span>
52
				<span class="nextlinks">',
53
					empty($context['links']['go_prev']) ? '' : '<a href="' . $context['links']['go_prev'] . '">' . $txt['previous_next_back'] . '</a>',
54
					empty($context['links']['go_next']) ? '' : ' - <a href="' . $context['links']['go_next'] . '">' . $txt['previous_next_forward'] . '</a>',
55
					empty($context['links']['derived_from']) ? '' : ' - <a href="' . $context['links']['derived_from'] . '">' . sprintf($txt['topic_derived_from'], '<em>' . Util::shorten_text($context['topic_derived_from']['subject'], empty($modSettings['subject_length']) ? 32 : $modSettings['subject_length'])) . '</em></a>',
56
				'</span>
57
			</header>
58
			<section>';
59
60
	if (!empty($settings['display_who_viewing']) || !empty($context['topic_redirected_from']))
61
	{
62
		echo '
63
			<div class="generalinfo">';
64
65
		if (!empty($settings['display_who_viewing']))
66
		{
67
			echo '
68
				<span id="whoisviewing">';
69
70
			// Show just numbers...?
71
			if ($settings['display_who_viewing'] == 1)
72
			{
73
				echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members'];
74
			}
75
			// Or show the actual people viewing the topic?
76
			else
77
			{
78
				echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
79
			}
80
81
			// Now show how many guests are here too.
82
			echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
83
				</span>';
84
		}
85
86
		// Is this topic a redirect?
87
		if (!empty($context['topic_redirected_from']))
88
		{
89
			echo '
90
				<span id="redirectfrom">
91
					' . sprintf($txt['no_redir'], '<a href="' . $context['topic_redirected_from']['redir_href'] . '">' . $context['topic_redirected_from']['subject'] . '</a>'), '
92
				</span>';
93
		}
94
95
		echo '
96
			</div>';
97
	}
98
99
	echo '
100
			<form id="quickModForm" action="', $scripturl, '?action=quickmod2;topic=', $context['current_topic'], '.', $context['start'], '" method="post" accept-charset="UTF-8" name="quickModForm" onsubmit="return oQuickModify.bInEditMode ? oQuickModify.modifySave(\'' . $context['session_id'] . "', '" . $context['session_var'] . '\') : false">';
101
}
102
103
/**
104
 * The main template for displaying a topic, does it all, its the king, the bomb, the real deal
105
 */
106
function template_messages()
107
{
108
	global $context, $settings, $options, $txt, $modSettings;
109
110
	$context['quick_reply_removableMessageIDs'] = [];
111
	$context['quick_reply_ignoredMsgs'] = [];
112
113
	// Get all the messages...
114
	$reset = isset($context['reset_renderer']);
115
	$controller = $context['get_message'][0];
116
	while ($message = $controller->{$context['get_message'][1]}($reset))
117
	{
118
		$reset = false;
119
120
		if ($message['can_remove'])
121
		{
122
			$context['quick_reply_removableMessageIDs'][] = $message['id'];
123
		}
124
125
		// Are we ignoring this message?
126
		if (!empty($message['is_ignored']))
127
		{
128
			$ignoring = true;
129
			$context['quick_reply_ignoredMsgs'][] = $message['id'];
130
		}
131
		else
132
		{
133
			$ignoring = false;
134
		}
135
136
		// Show the message anchor and a "new" separator if this message is the first new.
137
		if (($message['id'] != $context['first_message']) && $message['first_new'])
138
		{
139
			echo '
140
				<a id="new">&nbsp;</a>
141
				<hr class="new_post_separator" />';
142
		}
143
144
		echo $message['id'] != $context['first_message'] ? '
145
					<a class="post_anchor" id="msg' . $message['id'] . '"></a>' : '';
146
147
		echo '
148
				<article class="post_wrapper forumposts', $message['classes'], $message['approved'] ? '' : ' approvebg', '">';
149
150
		if (!empty($settings['show_keyinfo_above']))
151
		{
152
			template_keyinfo($message, $ignoring, true);
153
		}
154
155
		// Showing the sidebar poster area?
156
		if (empty($options['hide_poster_area']))
157
		{
158
			echo '
159
					<aside class="poster">
160
						<ul class="poster no_js">', template_build_poster_div($message, $ignoring), '</ul>
161
					</aside>';
162
		}
163
164
		echo '
165
					<div class="postarea', empty($options['hide_poster_area']) ? '' : '2', '">';
166
167
		if (empty($settings['show_keyinfo_above']))
168
		{
169
			template_keyinfo($message, $ignoring);
170
		}
171
172
		// Ignoring this user? Hide the post.
173
		if ($ignoring)
174
		{
175
			echo '
176
						<details id="msg_', $message['id'], '_ignored_prompt">
177
							', $txt['ignoring_user'], '
178
							<a href="#" id="msg_', $message['id'], '_ignored_link" class="hide linkbutton">', $txt['show_ignore_user_post'], '</a>
179
						</details>';
180
		}
181
182
		// Awaiting moderation?
183
		if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
184
		{
185
			echo '
186
						<div class="approve_post">
187
							', $txt['post_awaiting_approval'], '
188
						</div>';
189
		}
190
191
		// Show the post itself, finally!
192
		echo '
193
						<section id="msg_', $message['id'], '" data-msgid="', $message['id'], '" class="messageContent', $ignoring ? ' hide' : '', !empty($settings['show_keyinfo_above']) ? ' above' : '', '">',
194
							$message['body'], '
195
						</section>
196
						<footer class="post_footer">';
197
198
		// This is the floating Quick Quote button.
199
		echo '
200
							<button id="button_float_qq_', $message['id'], '" type="submit" role="button" class="quick_quote_button hide">', empty($txt['quick_quote']) ? $txt['quote'] : $txt['quick_quote'], '</button>';
201
202
203
		// Assuming there are attachments...
204
		if (!empty($message['attachment']))
205
		{
206
			template_display_attachments($message, $ignoring);
207
		}
208
209
		echo '
210
							<div class="generic_menu">';
211
212
		// Show "Last Edit: Time by Person" if this post was edited.
213
		if (!empty($modSettings['show_modify']))
214
		{
215
			echo '
216
								<span id="modified_', $message['id'], '" class="smalltext modified', empty($message['modified']['name']) ? ' hide"' : '"', '>
217
									', empty($message['modified']['name']) ? '' : $message['modified']['last_edit_text'], '
218
								</span>';
219
		}
220
221
		// Show the quickbuttons, for various operations on posts.
222
		template_button_strip($message['postbuttons'], 'quickbuttons no_js', ['above' => true, 'no-class' => true, 'id' => 'buttons_' . $message['id']]);
223
224
		echo '
225
226
							</div>';
227
228
		// Start of grid-row: signature seen as "<footer> .signature" in css
229
		// This could use some cleanup, but the idea is to prevent multiple borders in this grid area
230
		// It should just have a division line and then likes, custom fields, signature (any or none may be present)
231
		// or no line if there are no items
232
		$has_top_border = ($message['likes_enabled'] && !empty($message['like_counter']))
233
			|| (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
234
			|| (!empty($message['member']['custom_fields']) && empty($options['show_no_signatures']) && $context['signature_enabled']);
235
236
		echo '
237
							<div class="signature' . ($has_top_border ? '' : ' without_top_border') . '">';
238
239
		if ($message['likes_enabled'])
240
		{
241
			echo '
242
								<div id="likes_for_' . $message['id'] . '" class="likes_above_signature' . (empty($message['like_counter']) ? ' hide' : '') . '">';
243
244
			if (!empty($message['like_counter']))
245
			{
246
				echo '
247
									<i class="icon icon-small i-thumbup"></i>',
248
									 $txt['liked_by'], ' ', implode(', ', $context['likes'][$message['id']]['member']);
249
			}
250
251
			echo '
252
								</div>';
253
		}
254
255
		// Are there any custom profile fields for above the signature?
256
		// Show them if signatures are enabled, and you want to see them.
257
		if (!empty($message['member']['custom_fields']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
258
		{
259
			$shown = false;
260
			foreach ($message['member']['custom_fields'] as $custom)
261
			{
262
				if ($custom['placement'] != 2 || empty($custom['value']))
263
				{
264
					continue;
265
				}
266
267
				if (empty($shown))
268
				{
269
					$shown = true;
270
					echo '
271
								<div class="custom_fields_above_signature">
272
									<ul>';
273
				}
274
275
				echo '
276
										<li>', $custom['value'], '</li>';
277
			}
278
279
			if ($shown)
280
			{
281
				echo '
282
									</ul>
283
								</div>';
284
			}
285
		}
286
287
		// Show the member's signature?
288
		if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
289
		{
290
			echo '
291
								<div id="msg_', $message['id'], '_signature" class="', $ignoring ? ' hide"' : '"', '>', $message['member']['signature'], '</div>';
292
		}
293
294
		echo '
295
							</div>
296
						</footer>
297
					</div>
298
				</article>
299
				<hr class="post_separator" />';
300
	}
301
}
302
303
function template_keyinfo($message, $ignoring, $above = false)
304
{
305
	global $context, $settings, $options, $txt;
306
307
	echo '
308
						<header class="keyinfo', ($above ? ' above' : ''), '">
309
						', (empty($options['hide_poster_area']) ? '' : '<ul class="poster poster2">' . template_build_poster_div($message, $ignoring) . '</ul>');
310
311
	if (!empty($context['follow_ups'][$message['id']]))
312
	{
313
		echo '
314
							<ul class="quickbuttons follow_ups no_js">
315
								<li class="listlevel1 subsections" aria-haspopup="true">
316
									<a class="linklevel1">', $txt['follow_ups'], '</a>
317
									<ul class="menulevel2">';
318
319
		foreach ($context['follow_ups'][$message['id']] as $follow_up)
320
		{
321
				echo '
322
										<li class="listlevel2">
323
											<a class="linklevel2" href="', getUrl('topic', ['topic' => $follow_up['follow_up'], 'start' => '0', 'subject' => $follow_up['subject']]), '">', $follow_up['subject'], '</a>
324
										</li>';
325
		}
326
327
		echo '
328
									</ul>
329
								</li>
330
							</ul>';
331
	}
332
333
	echo '
334
							<h2 id="post_subject_', $message['id'], '" class="post_subject">', $message['subject'], '</h2>
335
							<span id="messageicon_', $message['id'], '" class="messageicon', ($message['icon_url'] !== $settings['images_url'] . '/post/xx.png') ? '"' : ' hide"', '>
336
								<img src="', $message['icon_url'] . '" alt=""', $message['can_modify'] ? ' id="msg_icon_' . $message['id'] . '"' : '', ' />
337
							</span>
338
							<h3 id="info_', $message['id'], '">', empty($message['counter']) ? '' : '
339
								<a href="' . $message['href'] . '" rel="nofollow">' . sprintf($txt['reply_number'], $message['counter']) . '</a> &ndash; ', $message['html_time'], '
340
							</h3>
341
							<div id="msg_', $message['id'], '_quick_mod"', $ignoring ? ' class="hide"' : '', '></div>
342
						</header>';
343
344
}
345
346
/**
347
 * Closes the topic information, descriptions, etc. divs and forms
348
 */
349
function template_messages_informations_below()
350
{
351
	echo '
352
			</form>
353
			</section>
354
		</main>';
355
}
356
357
/**
358
 * This is quick reply area below all the message body's
359
 */
360
function template_quickreply_below()
361
{
362
	global $context, $options, $txt, $modSettings;
363
364
	// Using the quick reply box below the messages, and you can reply?
365
	if ($context['can_reply'] && !empty($options['display_quick_reply']))
366
	{
367
		// Wrap the Quick Reply area, making it look like a post / message.
368
		echo '
369
	<a id="quickreply"></a>
370
	<h3 class="category_header category_toggle">
371
		<span>
372
			<a href="javascript:oQuickReply.swap();">
373
				<i id="quickreplyexpand" class="chevricon i-chevron-', empty($context['minmax_preferences']['qreply']) ? 'up' : 'down', '" title="', $txt['hide'], '"></i>
374
			</a>
375
		</span>
376
		<a href="javascript:oQuickReply.swap();">', $txt['quick_reply'], '</a>
377
	</h3>
378
	<div id="quickreplybox">
379
		<section>
380
			<article class="post_wrapper forumposts">';
381
382
		if (empty($options['hide_poster_area']))
383
		{
384
			echo '
385
				<ul class="poster no_js">', template_build_poster_div($context['thisMember'], false), '</ul>';
386
		}
387
388
		// Make a postarea similar to post
389
		echo '
390
				<div class="postarea', empty($options['hide_poster_area']) ? '' : '2', '">
391
					<header class="category_header">
392
						<h4>', $txt['reply'], '</h4>
393
					</header>
394
					<div id="quickReplyOptions">
395
						<form action="', getUrl('action', ['action' => 'post2', 'board' => $context['current_board']]), '" method="post" accept-charset="UTF-8" name="postmodify" id="postmodify" onsubmit="submitonce(this);', (empty($modSettings['mentions_enabled']) ? '' : "revalidateMentions('postmodify', '" . $context['post_box_name'] . "');"), '">
396
							<input type="hidden" name="topic" value="', $context['current_topic'], '" />
397
							<input type="hidden" name="subject" value="', $context['response_prefix'], $context['subject'], '" />
398
							<input type="hidden" name="icon" value="xx" />
399
							<input type="hidden" name="from_qr" value="1" />
400
							<input type="hidden" name="notify" value="', $context['is_marked_notify'] || !empty($options['auto_notify']) ? '1' : '0', '" />
401
							<input type="hidden" name="not_approved" value="', (int) !$context['can_reply_approved'], '" />
402
							<input type="hidden" name="goback" value="', empty($options['return_to_post']) ? '0' : '1', '" />
403
							<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '" />
404
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
405
							<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />';
406
407
		// Guests just need more.
408
		if ($context['user']['is_guest'])
409
		{
410
			echo '
411
							<dl>
412
								<dt>
413
									<label for="guestname">', $txt['name'], ':</label> <input type="text" name="guestname" id="guestname" value="', $context['name'], '" size="25" class="input_text" tabindex="', $context['tabindex']++, '" />
414
								</dd>
415
								<dt>
416
									<label for="email">', $txt['email'], ':</label> <input type="text" name="email" id="email" value="', $context['email'], '" size="25" class="input_text" tabindex="', $context['tabindex']++, '" />
417
								</dd>
418
							</dl>';
419
		}
420
421
		// Is visual verification enabled?
422
		if (!empty($context['require_verification']))
423
		{
424
			template_verification_controls($context['visual_verification_id'], '
425
							<strong>' . $txt['verification'] . ':</strong>', '<br />');
426
		}
427
428
		echo '
429
							', template_control_richedit($context['post_box_name']);
0 ignored issues
show
Bug introduced by
Are you sure template_control_richedi...ntext['post_box_name']) of type void can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

429
							', /** @scrutinizer ignore-type */ template_control_richedit($context['post_box_name']);
Loading history...
Bug introduced by
Are you sure the usage of template_control_richedi...ntext['post_box_name']) 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...
430
431
		echo '
432
							', $context['is_locked'] ? '<p class="warningbox smalltext">' . $txt['quick_reply_warning'] . '</p>' : '',
433
							$context['oldTopicError'] ? '<p class="warningbox smalltext"></i>' . sprintf($txt['error_old_topic'], $modSettings['oldTopicDays']) . '</p>' : '', '
434
							', $context['can_reply_approved'] ? '' : '<p class="infobox">' . $txt['wait_for_approval'] . '</p>';
435
436
		echo '
437
							<div id="post_confirm_buttons" class="submitbutton">
438
								<input type="submit" name="post" value="', $txt['post'], '" onclick="return submitThisOnce(this);" accesskey="s" tabindex="', $context['tabindex']++, '" />
439
								<input type="submit" name="preview" value="', $txt['preview'], '" onclick="return submitThisOnce(this);" accesskey="p" tabindex="', $context['tabindex']++, '" />';
440
441
		// Draft save button?
442
		if (!empty($context['drafts_save']))
443
		{
444
			echo '
445
								<input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '" />
446
								<input type="button" name="save_draft" value="', $txt['draft_save'], '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" tabindex="', $context['tabindex']++, '" />';
447
		}
448
449
		echo '
450
							</div>';
451
452
		// Show the draft last saved on area
453
		if (!empty($context['drafts_save']))
454
		{
455
			echo '
456
							<div class="draftautosave">
457
								<span id="throbber" class="hide"><i class="icon i-oval"></i>&nbsp;</span>
458
								<span id="draft_lastautosave"></span>
459
							</div>';
460
		}
461
462
		echo '
463
						</form>
464
					</div>
465
				</div>
466
			</article>
467
		</section>
468
	</div>';
469
	}
470
471
	// Finally, enable the quick reply quote function
472
	theme()->addInlineJavascript('
473
		let oQuickReply = new QuickReply({
474
			bDefaultCollapsed: ' . (empty($context['minmax_preferences']['qreply']) ? 'false' : 'true') . ',
475
			iTopicId: ' . $context['current_topic'] . ',
476
			iStart: ' . $context['start'] . ',
477
			sScriptUrl: elk_scripturl,
478
			sImagesUrl: elk_images_url,
479
			sContainerId: "quickreplybox",
480
			sClassId: "quickreplyexpand",
481
			sClassCollapsed: "chevricon i-chevron-up",
482
			sTitleCollapsed: ' . JavaScriptEscape($txt['show']) . ',
483
			sClassExpanded: "chevricon i-chevron-down",
484
			sTitleExpanded: ' . JavaScriptEscape($txt['hide']) . ',
485
			sJumpAnchor: "quickreply",
486
			sEditorId: "' . $context['post_box_name'] . '",
487
			oThemeOptions: {
488
				bUseThemeSettings: ' . ($context['user']['is_guest'] ? 'false' : 'true') . ',
489
				sOptionName: "minmax_preferences",
490
				sSessionId: elk_session_id,
491
				sSessionVar: elk_session_var,
492
				sAdditionalVars: ";minmax_key=qreply"
493
			},
494
			oCookieOptions: {
495
				bUseCookie: ' . ($context['user']['is_guest'] ? 'true' : 'false') . ',
496
				sCookieName: "elk_qreply"
497
			}
498
		});', true);
499
500
	// Quick moderation options
501
	if (!empty($options['display_quick_mod']) && $context['can_remove_post'])
502
	{
503
		theme()->addInlineJavascript('
504
			let oInTopicModeration = new InTopicModeration({
505
				sCheckboxContainerMask: "in_topic_mod_check_",
506
				aMessageIds: [' . (implode(', ', $context['quick_reply_removableMessageIDs'])) . '],
507
				sSessionId: elk_session_id,
508
				sSessionVar: elk_session_var,
509
				sButtonStrip: "moderationbuttons",
510
				sButtonStripDisplay: "moderationbuttons_strip",
511
				sButtonStripClass: "menuitem",
512
				bUseImageButton: true,
513
				bCanRemove: ' . ($context['can_remove_post'] ? 'true' : 'false') . ',
514
				sRemoveButtonLabel: "' . $txt['quickmod_delete_selected'] . '",
515
				sRemoveButtonImage: "i-delete",
516
				sRemoveButtonConfirm: "' . $txt['quickmod_confirm'] . '",
517
				bCanRestore: ' . ($context['can_restore_msg'] ? 'true' : 'false') . ',
518
				sRestoreButtonLabel: "' . $txt['quick_mod_restore'] . '",
519
				sRestoreButtonImage: "i-recycle",
520
				sRestoreButtonConfirm: "' . $txt['quickmod_confirm'] . '",
521
				bCanSplit: ' . ($context['can_split'] ? 'true' : 'false') . ',
522
				sSplitButtonLabel: "' . $txt['quickmod_split_selected'] . '",
523
				sSplitButtonImage: "i-split",
524
				sSplitButtonConfirm: "' . $txt['quickmod_confirm'] . '",
525
				sFormId: "quickModForm"
526
			});', true);
527
	}
528
529
	// Quick modify can be used
530
	theme()->addInlineJavascript('
531
		let oQuickModify = new QuickModify({
532
			sIconHide: "xx.png",
533
			sScriptUrl: elk_scripturl,
534
			sClassName: "quick_edit",
535
			sIDSubject: "post_subject_",
536
			sIDInfo: "info_",
537
			bShowModify: ' . (empty($modSettings['show_modify']) ? 'false' : 'true') . ',
538
			iTopicId: ' . $context['current_topic'] . ',
539
			sTemplateBodyEdit: ' . JavaScriptEscape('
540
				<div id="quick_edit_body_container">
541
					<div id="error_box" class="errorbox hide"></div>
542
					<textarea class="editor" name="message" rows="12" tabindex="' . ($context['tabindex']++) . '">%body%</textarea><br />
543
					<div class="submitbutton">
544
						<input type="hidden" name="\' + elk_session_var + \'" value="\' + elk_session_id + \'" />
545
						<input type="hidden" name="topic" value="' . $context['current_topic'] . '" />
546
						<input type="hidden" name="msg" value="%msg_id%" />
547
						<input type="submit" name="post" value="' . $txt['save'] . '" tabindex="' . ($context['tabindex']++) . '" onclick="return oQuickModify.modifySave(\'' . $context['session_id'] . "', '" . $context['session_var'] . '\');" accesskey="s" />
548
						<input type="submit" name="cancel" value="' . $txt['modify_cancel'] . '" tabindex="' . ($context['tabindex']++) . '" onclick="return oQuickModify.modifyCancel();" />
549
					</div>
550
				</div>') . ',
551
			sTemplateBodyNormal: ' . JavaScriptEscape('%body%') . ',
552
			sTemplateSubjectEdit: ' . JavaScriptEscape('<input type="text" style="width: 85%;" name="subject" value="%subject%" size="80" maxlength="80" tabindex="' . ($context['tabindex']++) . '" class="input_text" />') . ',
553
			sTemplateSubjectNormal: ' . JavaScriptEscape('%subject%') .
554
			(($context['can_reply'] && !empty($options['display_quick_reply'])) ? ',
555
			sFormRemoveAccessKeys: "postmodify"' : '') . ',
556
			funcOnAfterCreate: function () {
557
				// Attach AtWho to the quick edit box
558
				add_elk_mention("#quick_edit_body_container textarea");
559
				var i = all_elk_mentions.length - 1;
560
				all_elk_mentions[i].oMention = new elk_mentions(all_elk_mentions[i].oOptions);
561
			}
562
		});
563
564
		aIconLists[aIconLists.length] = new IconList({
565
			sBackReference: "aIconLists[" + aIconLists.length + "]",
566
			sIconIdPrefix: "msg_icon_",
567
			sScriptUrl: elk_scripturl,
568
			bShowModify: ' . (empty($modSettings['show_modify']) ? 'false' : 'true') . ',
569
			iBoardId: ' . $context['current_board'] . ',
570
			iTopicId: ' . $context['current_topic'] . ',
571
			sSessionId: elk_session_id,
572
			sSessionVar: elk_session_var,
573
			sAction: "messageicons;board=' . $context['current_board'] . '" ,
574
			sLabelIconList: "' . $txt['message_icon'] . '",
575
		});', true);
576
577
	// Provide a toggle for any messages that are being ignored.
578
	if (!empty($context['quick_reply_ignoredMsgs']))
579
	{
580
		theme()->addInlineJavascript('
581
			ignore_toggles([' . implode(', ', $context['quick_reply_ignoredMsgs']) . '], ' . JavaScriptEscape($txt['show_ignore_user_post']) . ');', true);
582
	}
583
}
584
585
/**
586
 * Used to display a polls / poll results
587
 */
588
function template_display_poll_above()
589
{
590
	global $context, $txt;
591
592
	echo '
593
			<div id="poll">
594
				<h2 class="category_header">
595
					<i class="icon i-poll', $context['poll']['is_locked'] ? '-locked' : '', '"></i> ', $txt['poll'], '
596
				</h2>
597
				<div id="poll_options" class="content">
598
					<h4 id="pollquestion">
599
						', $context['poll']['question'], '
600
					</h4>';
601
602
	// Are they not allowed to vote but allowed to view the options?
603
	if ($context['poll']['show_results'] || !$context['allow_vote'])
604
	{
605
		echo '
606
					<dl class="stats floatleft">';
607
608
		// Show each option with its corresponding percentage bar.
609
		foreach ($context['poll']['options'] as $option)
610
		{
611
			echo '
612
						<dt', $option['voted_this'] ? ' class="voted"' : '', '>', $option['option'], '</dt>
613
						<dd class="statsbar">';
614
615
			if ($context['allow_poll_view'])
616
			{
617
				echo '
618
							', $option['bar_ndt'], '
619
							<span class="righttext poll-percent', !empty($option['votes']) ? ' voted"' : '"', '>[ ', $option['votes'], ' ] (', $option['percent'], '%)</span>';
620
			}
621
622
			echo '
623
						</dd>';
624
		}
625
626
		echo '
627
					</dl>';
628
629
		if ($context['allow_poll_view'])
630
		{
631
			echo '
632
					<p class="pollvote">
633
						<strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '
634
					</p>';
635
		}
636
	}
637
	// They are allowed to vote! Go to it!
638
	else
639
	{
640
		echo '
641
					<form action="', getUrl('action', ['action' => 'poll', 'sa' => 'vote', 'topic' => $context['current_topic'] . '.' . $context['start'], 'poll' => $context['poll']['id']]), '" method="post" accept-charset="UTF-8">';
642
643
		// Show a warning if they are allowed more than one option.
644
		if ($context['poll']['allowed_warning'])
645
		{
646
			echo '
647
						<p>', $context['poll']['allowed_warning'], '</p>';
648
		}
649
650
		echo '
651
						<ul class="options">';
652
653
		// Show each option with its button - a radio likely.
654
		foreach ($context['poll']['options'] as $option)
655
		{
656
			echo '
657
							<li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
658
		}
659
660
		echo '
661
						</ul>
662
						<div class="pollvote">
663
							<input type="submit" value="', $txt['poll_vote'], '" class="left_submit" />
664
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
665
						</div>
666
					</form>';
667
	}
668
669
	// Is the clock ticking?
670
	if (!empty($context['poll']['expire_time']))
671
	{
672
		echo '
673
					<p>
674
						<strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '
675
					</p>';
676
	}
677
678
	echo '
679
			<div id="pollmoderation">';
680
681
	template_button_strip($context['poll_buttons']);
682
683
	echo '
684
			</div>
685
		</div>
686
	</div>';
687
}
688
689
/**
690
 * Used to display an attached calendar event.
691
 */
692
function template_display_calendar_above()
693
{
694
	global $context, $txt;
695
696
	echo '
697
			<section class="linked_events">
698
				<h2 class="category_header">', $txt['calendar_linked_events'], '</h2>
699
				<div class="content">
700
					<ul>';
701
702
	foreach ($context['linked_calendar_events'] as $event)
703
	{
704
		echo '
705
						<li>
706
							', ($event['can_edit'] ? '<a href="' . $event['modify_href'] . '"><i class="icon i-modify" title="' . $txt['modify'] . '"></i></a> ' : ''), '<strong>', $event['title'], '</strong>: ', $event['start_date'], ($event['start_date'] != $event['end_date'] ? ' - ' . $event['end_date'] : ''), '
707
						</li>';
708
	}
709
710
	echo '
711
					</ul>
712
				</div>
713
			</section>';
714
}
715
716
/**
717
 * Used to display items above the page, like page navigation
718
 */
719
function template_pages_and_buttons_above()
720
{
721
	global $context;
722
723
	// Show the anchor for the top and for the first message. If the first message is new, say so.
724
	echo '
725
			<a id="msg', $context['first_message'], '"></a>', $context['first_new_message'] ? '<a id="new"></a>' : '';
726
727
	// Show the page index... "Pages: [1]".
728
	template_pagesection('normal_buttons');
729
}
730
731
/**
732
 * Used to display items below the page, like page navigation
733
 */
734
function template_pages_and_buttons_below()
735
{
736
	// Show the page index... "Pages: [1]".
737
	template_pagesection('normal_buttons');
738
739
	// Show the lower breadcrumbs.
740
	theme_linktree();
741
}
742
743
/**
744
 * Used to display additonal items below the page, like moderation buttons
745
 */
746
function template_moderation_buttons_below()
747
{
748
	global $context, $txt;
749
750
	// Show the moderation buttons
751
	echo '
752
			<div id="moderationbuttons" class="hide_30 hamburger_30_target">';
753
754
	if (can_see_button_strip($context['mod_buttons']))
755
	{
756
		echo '
757
				<i class="icon icon-lg i-menu hamburger_30" data-id="moderationbuttons"></i>';
758
	}
759
760
	template_button_strip($context['mod_buttons'], '', array('id' => 'moderationbuttons_strip'));
761
762
	// Show the jump-to box, or actually...let Javascript do it.
763
	echo '
764
				<div id="display_jump_to">&nbsp;</div>
765
				<script type="module">
766
					aJumpTo[aJumpTo.length] = new JumpTo({
767
						sContainerId: "display_jump_to",
768
						sJumpToTemplate: "<label class=\"smalltext\" for=\"%select_id%\">', $context['jump_to']['label'], ':<" + "/label> %dropdown_list%",
769
						iCurBoardId: ', $context['current_board'], ',
770
						iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
771
						sCurBoardName: "', $context['jump_to']['board_name'], '",
772
						sBoardChildLevelIndicator: "&#8195;",
773
						sBoardPrefix: "&#10148;",
774
						sCatClass: "jump_to_header",
775
						sCatPrefix: "",
776
						sGoButtonLabel: "', $txt['go'], '"
777
					});
778
				</script>
779
			</div>';
780
}
781
782
/**
783
 * Used to display attachments
784
 *
785
 * @param array $message
786
 * @param bool $ignoring
787
 */
788
function template_display_attachments($message, $ignoring)
789
{
790
	global $context, $txt, $scripturl, $modSettings;
791
792
	echo '
793
							<div id="msg_', $message['id'], '_footer" class="attachments', $ignoring ? ' hide"' : '"', '>';
794
795
	$last_approved_state = 1;
796
797
	foreach ($message['attachment'] as $attachment)
798
	{
799
		// Show a special box for unapproved attachments...
800
		if ($attachment['is_approved'] != $last_approved_state)
801
		{
802
			$last_approved_state = 0;
803
			echo '
804
								<fieldset>
805
									<legend>', $txt['attach_awaiting_approve'];
806
807
			if ($context['can_approve'])
808
			{
809
				echo '
810
										&nbsp;<a class="linkbutton" href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>';
811
			}
812
813
			echo '
814
									</legend>';
815
		}
816
817
		echo '
818
									<div class="attachment_block">';
819
820
		if ($attachment['is_image'])
821
		{
822
			if ($attachment['thumbnail']['has_thumb'])
823
			{
824
				echo '
825
											<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" ', $attachment['thumbnail']['lightbox'], '>
826
												<img class="attachment_image" src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" loading="lazy" />
827
											</a>';
828
			}
829
			else
830
			{
831
				echo '
832
											<img class="attachment_image" src="', $attachment['href'], ';image" alt="" style="max-width:100%; max-height:' . $attachment['height'] . 'px;" loading="lazy"/>';
833
			}
834
		}
835
		elseif (!empty($modSettings['attachmentShowImages']))
836
		{
837
			echo '							<img class="attachment_image" src="', $attachment['href'], ';thumb" alt="" style="max-width:' . $modSettings['attachmentThumbWidth'] . 'px; max-height:' . $modSettings['attachmentThumbHeight'] . 'px;" loading="lazy" />';
838
		}
839
840
		echo '
841
											<a href="', $attachment['href'], '" class="attachment_name">
842
												<i class="icon icon-small i-paperclip"></i>&nbsp;' . $attachment['name'] . '
843
											</a>
844
											<span class="attachment_details">', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . sprintf($txt['attach_viewed'], $attachment['downloads']) : ' ' . sprintf($txt['attach_downloaded'], $attachment['downloads'])) . '</span>';
845
846
		if (!$attachment['is_approved'] && $context['can_approve'])
847
		{
848
			echo '
849
											<a class="linkbutton" href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>&nbsp;|&nbsp;<a class="linkbutton" href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>';
850
		}
851
852
		echo '
853
										</div>';
854
	}
855
856
	// If we had unapproved attachments clean up.
857
	if ($last_approved_state == 0)
0 ignored issues
show
introduced by
The condition $last_approved_state == 0 is always false.
Loading history...
858
	{
859
		echo '
860
								</fieldset>';
861
	}
862
863
	echo '
864
							</div>';
865
}
866