Passed
Pull Request — development (#3800)
by Spuds
20:37
created

template_quickreply_below()   D

Complexity

Conditions 31
Paths 68

Size

Total Lines 209
Code Lines 86

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 31
eloc 86
nc 68
nop 0
dl 0
loc 209
rs 4.1666
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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

436
						', /** @scrutinizer ignore-type */ template_control_richedit($context['post_box_name']);
Loading history...
437
438
		echo '
439
						', $context['is_locked'] ? '<p class="warningbox smalltext">' . $txt['quick_reply_warning'] . '</p>' : '',
440
						$context['oldTopicError'] ? '<p class="warningbox smalltext"></i>' . sprintf($txt['error_old_topic'], $modSettings['oldTopicDays']) . '</p>' : '', '
441
						', $context['can_reply_approved'] ? '' : '<p class="infobox">' . $txt['wait_for_approval'] . '</p>';
442
443
		echo '
444
						<div id="post_confirm_buttons" class="submitbutton">',
445
							template_control_richedit_buttons($context['post_box_name']), '
0 ignored issues
show
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...
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

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