Passed
Push — release-2.1 ( ced0c3...a0ed2c )
by Mathias
08:19
created

Display.template.php ➔ template_quickreply()   F

Complexity

Conditions 15
Paths 256

Size

Total Lines 150

Duplication

Lines 8
Ratio 5.33 %

Importance

Changes 0
Metric Value
cc 15
nc 256
nop 0
dl 8
loc 150
rs 3.5066
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
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines http://www.simplemachines.org
7
 * @copyright 2018 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 Beta 4
11
 */
12
13
/**
14
 * This tempate handles displaying a topic
15
 */
16
function template_main()
0 ignored issues
show
Best Practice introduced by
The function template_main() has been defined more than once; this definition is ignored, only the first definition in Themes/default/BoardIndex.template.php (L54-132) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
17
{
18
	global $context, $settings, $options, $txt, $scripturl, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
19
20
	// Let them know, if their report was a success!
21
	if ($context['report_sent'])
22
		echo '
23
		<div class="infobox">
24
			', $txt['report_sent'], '
25
		</div>';
26
27
	// Let them know why their message became unapproved.
28
	if ($context['becomesUnapproved'])
29
		echo '
30
		<div class="noticebox">
31
			', $txt['post_becomesUnapproved'], '
32
		</div>';
33
34
	// Show new topic info here?
35
	echo '
36
		<div id="display_head" class="information">
37
			<h2 class="display_title">
38
				<span id="top_subject">', $context['subject'], '</span>', ($context['is_locked']) ? ' <span class="generic_icons lock"></span>' : '', ($context['is_sticky']) ? ' <span class="generic_icons sticky"></span>' : '', '
39
			</h2>
40
			<p>',$txt['started_by'], ' ', $context['topic_poster_name'], ', ', $context['topic_started_time'], '</p>';
41
42
	// Next - Prev
43
	echo '
44
			<span class="nextlinks floatright">', $context['previous_next'], '</span>';
45
46 View Code Duplication
	if (!empty($settings['display_who_viewing']))
47
	{
48
		echo '
49
			<p>';
50
51
		// Show just numbers...?
52
		if ($settings['display_who_viewing'] == 1)
53
			echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
54
		// Or show the actual people viewing the topic?
55
		else
56
			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'] . ')');
57
58
		// Now show how many guests are here too.
59
		echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
60
			</p>';
61
	}
62
63
	// Show the anchor for the top and for the first message. If the first message is new, say so.
64
	echo '
65
		</div><!-- #display_head -->
66
		<a id="msg', $context['first_message'], '"></a>', $context['first_new_message'] ? '<a id="new"></a>' : '';
67
68
	// Is this topic also a poll?
69
	if ($context['is_poll'])
70
	{
71
		echo '
72
		<div id="poll">
73
			<div class="cat_bar">
74
				<h3 class="catbg">
75
					<span class="generic_icons poll"></span>', $context['poll']['is_locked'] ? '<span class="generic_icons lock"></span>' : '', ' ', $context['poll']['question'], '
76
				</h3>
77
			</div>
78
			<div class="windowbg noup">
79
				<div id="poll_options">';
80
81
		// Are they not allowed to vote but allowed to view the options?
82
		if ($context['poll']['show_results'] || !$context['allow_vote'])
83
		{
84
			echo '
85
					<dl class="options">';
86
87
			// Show each option with its corresponding percentage bar.
88
			foreach ($context['poll']['options'] as $option)
89
			{
90
				echo '
91
						<dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
92
						<dd class="statsbar generic_bar', $option['voted_this'] ? ' voted' : '', '">';
93
94
				if ($context['allow_results_view'])
95
					echo '
96
							', $option['bar_ndt'], '
97
							<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';
98
99
				echo '
100
						</dd>';
101
			}
102
103
			echo '
104
					</dl>';
105
106
			if ($context['allow_results_view'])
107
				echo '
108
					<p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>';
109
		}
110
		// They are allowed to vote! Go to it!
111
		else
112
		{
113
			echo '
114
					<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">';
115
116
			// Show a warning if they are allowed more than one option.
117
			if ($context['poll']['allowed_warning'])
118
				echo '
119
						<p class="smallpadding">', $context['poll']['allowed_warning'], '</p>';
120
121
			echo '
122
						<ul class="options">';
123
124
			// Show each option with its button - a radio likely.
125
			foreach ($context['poll']['options'] as $option)
126
				echo '
127
							<li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
128
129
			echo '
130
						</ul>
131
						<div class="submitbutton">
132
							<input type="submit" value="', $txt['poll_vote'], '" class="button">
133
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
134
						</div>
135
					</form>';
136
		}
137
138
		// Is the clock ticking?
139
		if (!empty($context['poll']['expire_time']))
140
			echo '
141
					<p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>';
142
143
		echo '
144
				</div><!-- #poll_options -->
145
			</div><!-- .windowbg -->
146
		</div><!-- #poll -->
147
		<div id="pollmoderation">';
148
149
			template_button_strip($context['poll_buttons']);
150
151
		echo '
152
		</div>';
153
	}
154
155
	// Does this topic have some events linked to it?
156 View Code Duplication
	if (!empty($context['linked_calendar_events']))
157
	{
158
		echo '
159
		<div class="title_bar">
160
			<h3 class="titlebg">', $txt['calendar_linked_events'], '</h3>
161
		</div>
162
		<div class="information">
163
			<ul>';
164
165
		foreach ($context['linked_calendar_events'] as $event)
166
		{
167
			echo '
168
				<li>
169
					<strong class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></strong>';
170
171
			if ($event['can_edit'])
172
				echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
173
174
			if ($event['can_export'])
175
				echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
176
177
			echo '
178
					<br>';
179
180
			if (!empty($event['allday']))
181
			{
182
				echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
183
			}
184
			else
185
			{
186
				// Display event info relative to user's local timezone
187
				echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
188
189
				if ($event['start_date_local'] != $event['end_date_local'])
190
					echo trim($event['end_date_local']) . ', ';
191
192
				echo trim($event['end_time_local']);
193
194
				// Display event info relative to original timezone
195
				if ($event['start_date_local'] . $event['start_time_local'] != $event['start_date_orig'] . $event['start_time_orig'])
196
				{
197
					echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
198
199
					if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
200
						echo trim($event['start_date_orig']), ', ';
201
202
					echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
203
204
					if ($event['start_date_orig'] != $event['end_date_orig'])
205
						echo trim($event['end_date_orig']) . ', ';
206
207
					echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
208
				}
209
				// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
210
				else
211
					echo ' ', $event['tz_abbrev'], '</time>';
212
			}
213
214
			if (!empty($event['location']))
215
				echo '
216
					<br>', $event['location'];
217
218
			echo '
219
				</li>';
220
		}
221
		echo '
222
			</ul>
223
		</div><!-- .information -->';
224
	}
225
226
	// Show the page index... "Pages: [1]".
227
	echo '
228
		<div class="pagesection top">
229
			', template_button_strip($context['normal_buttons'], 'right'), '
230
			', $context['menu_separator'], '
231
			<div class="pagelinks floatleft">
232
				<a href="#bot" class="button">', $txt['go_down'], '</a>
233
				', $context['page_index'], '
234
			</div>
235
		</div>';
236
237
	// Mobile action - moderation buttons (top)
238 View Code Duplication
	if (!empty($context['normal_buttons']))
239
	echo '
240
		<div class="mobile_buttons floatright">
241
			<a class="button mobile_act">', $txt['mobile_action'], '</a>
242
			', !empty($context['mod_buttons']) ? '<a class="button mobile_mod">' . $txt['mobile_moderation'] . '</a>' : '', '
243
		</div>';
244
245
	// Show the topic information - icon, subject, etc.
246
	echo '
247
		<div id="forumposts">
248
			<form action="', $scripturl, '?action=quickmod2;topic=', $context['current_topic'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" onsubmit="return oQuickModify.bInEditMode ? oQuickModify.modifySave(\'' . $context['session_id'] . '\', \'' . $context['session_var'] . '\') : false">';
249
250
	$context['ignoredMsgs'] = array();
251
	$context['removableMessageIDs'] = array();
252
253
	// Get all the messages...
254
	while ($message = $context['get_message']())
255
		template_single_post($message);
256
257
	echo '
258
			</form>
259
		</div><!-- #forumposts -->';
260
261
	// Mobile action - moderation buttons (bottom)
262 View Code Duplication
	if (!empty($context['normal_buttons']))
263
	echo '
264
		<div class="mobile_buttons floatright">
265
			<a class="button mobile_act">', $txt['mobile_action'], '</a>
266
			', !empty($context['mod_buttons']) ? '<a class="button mobile_mod">' . $txt['mobile_moderation'] . '</a>' : '', '
267
		</div>';
268
269
	// Show the page index... "Pages: [1]".
270
	echo '
271
		<div class="pagesection">
272
			', template_button_strip($context['normal_buttons'], 'right'), '
273
			', $context['menu_separator'], '
274
			<div class="pagelinks floatleft">
275
				<a href="#main_content_section" class="button" id="bot">', $txt['go_up'], '</a>
276
				', $context['page_index'], '
277
			</div>
278
		</div>';
279
280
	// Show the lower breadcrumbs.
281
	theme_linktree();
282
283
	// Moderation buttons
284
	echo '
285
		<div id="moderationbuttons">
286
			', template_button_strip($context['mod_buttons'], 'bottom', array('id' => 'moderationbuttons_strip')), '
287
		</div>';
288
289
	// Show the jumpto box, or actually...let Javascript do it.
290
	echo '
291
		<div id="display_jump_to"></div>';
292
293
	// Show quickreply
294
	if ($context['can_reply'])
295
		template_quickreply();
296
297
	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
298
	echo '
299
		<div id="mobile_action" class="popup_container">
300
			<div class="popup_window description">
301
				<div class="popup_heading">
302
					', $txt['mobile_action'], '
303
					<a href="javascript:void(0);" class="generic_icons hide_popup"></a>
304
				</div>
305
				', template_button_strip($context['normal_buttons']), '
306
			</div>
307
		</div>';
308
309
	// Show the moderation button & pop (if there is anything to show)
310
	if (!empty($context['mod_buttons']))
311
		echo '
312
		<div id="mobile_moderation" class="popup_container">
313
			<div class="popup_window description">
314
				<div class="popup_heading">
315
					', $txt['mobile_moderation'], '
316
					<a href="javascript:void(0);" class="generic_icons hide_popup"></a>
317
				</div>
318
				<div id="moderationbuttons_mobile">
319
					', template_button_strip($context['mod_buttons'], 'bottom', array('id' => 'moderationbuttons_strip_mobile')), '
320
				</div>
321
			</div>
322
		</div>';
323
324
	echo '
325
		<script>';
326
327
	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $context['can_remove_post'])
328
	{
329
		echo '
330
			var oInTopicModeration = new InTopicModeration({
331
				sSelf: \'oInTopicModeration\',
332
				sCheckboxContainerMask: \'in_topic_mod_check_\',
333
				aMessageIds: [\'', implode('\', \'', $context['removableMessageIDs']), '\'],
334
				sSessionId: smf_session_id,
335
				sSessionVar: smf_session_var,
336
				sButtonStrip: \'moderationbuttons\',
337
				sButtonStripDisplay: \'moderationbuttons_strip\',
338
				bUseImageButton: false,
339
				bCanRemove: ', $context['can_remove_post'] ? 'true' : 'false', ',
340
				sRemoveButtonLabel: \'', $txt['quickmod_delete_selected'], '\',
341
				sRemoveButtonImage: \'delete_selected.png\',
342
				sRemoveButtonConfirm: \'', $txt['quickmod_confirm'], '\',
343
				bCanRestore: ', $context['can_restore_msg'] ? 'true' : 'false', ',
344
				sRestoreButtonLabel: \'', $txt['quick_mod_restore'], '\',
345
				sRestoreButtonImage: \'restore_selected.png\',
346
				sRestoreButtonConfirm: \'', $txt['quickmod_confirm'], '\',
347
				bCanSplit: ', $context['can_split'] ? 'true' : 'false', ',
348
				sSplitButtonLabel: \'', $txt['quickmod_split_selected'], '\',
349
				sSplitButtonImage: \'split_selected.png\',
350
				sSplitButtonConfirm: \'', $txt['quickmod_confirm'], '\',
351
				sFormId: \'quickModForm\'
352
			});';
353
354
		// Add it to the mobile button strip as well
355
		echo '
356
			var oInTopicModerationMobile = new InTopicModeration({
357
				sSelf: \'oInTopicModerationMobile\',
358
				sCheckboxContainerMask: \'in_topic_mod_check_\',
359
				aMessageIds: [\'', implode('\', \'', $context['removableMessageIDs']), '\'],
360
				sSessionId: smf_session_id,
361
				sSessionVar: smf_session_var,
362
				sButtonStrip: \'moderationbuttons_mobile\',
363
				sButtonStripDisplay: \'moderationbuttons_strip_mobile\',
364
				bUseImageButton: false,
365
				bCanRemove: ', $context['can_remove_post'] ? 'true' : 'false', ',
366
				sRemoveButtonLabel: \'', $txt['quickmod_delete_selected'], '\',
367
				sRemoveButtonImage: \'delete_selected.png\',
368
				sRemoveButtonConfirm: \'', $txt['quickmod_confirm'], '\',
369
				bCanRestore: ', $context['can_restore_msg'] ? 'true' : 'false', ',
370
				sRestoreButtonLabel: \'', $txt['quick_mod_restore'], '\',
371
				sRestoreButtonImage: \'restore_selected.png\',
372
				sRestoreButtonConfirm: \'', $txt['quickmod_confirm'], '\',
373
				bCanSplit: ', $context['can_split'] ? 'true' : 'false', ',
374
				sSplitButtonLabel: \'', $txt['quickmod_split_selected'], '\',
375
				sSplitButtonImage: \'split_selected.png\',
376
				sSplitButtonConfirm: \'', $txt['quickmod_confirm'], '\',
377
				sFormId: \'quickModForm\'
378
			});';
379
	}
380
381
	echo '
382
			if (\'XMLHttpRequest\' in window)
383
			{
384
				var oQuickModify = new QuickModify({
385
					sScriptUrl: smf_scripturl,
386
					sClassName: \'quick_edit\',
387
					bShowModify: ', $modSettings['show_modify'] ? 'true' : 'false', ',
388
					iTopicId: ', $context['current_topic'], ',
389
					sTemplateBodyEdit: ', JavaScriptEscape('
390
						<div id="quick_edit_body_container">
391
							<div id="error_box" class="error"></div>
392
							<textarea class="editor" name="message" rows="12" tabindex="' . $context['tabindex']++ . '">%body%</textarea><br>
0 ignored issues
show
Coding Style introduced by
Increment and decrement operators must be bracketed when used in string concatenation
Loading history...
393
							<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
394
							<input type="hidden" name="topic" value="' . $context['current_topic'] . '">
395
							<input type="hidden" name="msg" value="%msg_id%">
396
							<div class="righttext quickModifyMargin">
397
								<input type="submit" name="post" value="' . $txt['save'] . '" tabindex="' . $context['tabindex']++ . '" onclick="return oQuickModify.modifySave(\'' . $context['session_id'] . '\', \'' . $context['session_var'] . '\');" accesskey="s" class="button">' . ($context['show_spellchecking'] ? ' <input type="button" value="' . $txt['spell_check'] . '" tabindex="' . $context['tabindex']++ . '" onclick="spellCheck(\'quickModForm\', \'message\');" class="button">' : '') . ' <input type="submit" name="cancel" value="' . $txt['modify_cancel'] . '" tabindex="' . $context['tabindex']++ . '" onclick="return oQuickModify.modifyCancel();" class="button">
0 ignored issues
show
Coding Style introduced by
Increment and decrement operators must be bracketed when used in string concatenation
Loading history...
398
							</div>
399
						</div>'), ',
400
					sTemplateSubjectEdit: ', JavaScriptEscape('<input type="text" name="subject" value="%subject%" size="80" maxlength="80" tabindex="' . $context['tabindex']++ . '">'), ',
0 ignored issues
show
Coding Style introduced by
Increment and decrement operators must be bracketed when used in string concatenation
Loading history...
401
					sTemplateBodyNormal: ', JavaScriptEscape('%body%'), ',
402
					sTemplateSubjectNormal: ', JavaScriptEscape('<a href="' . $scripturl . '?topic=' . $context['current_topic'] . '.msg%msg_id%#msg%msg_id%" rel="nofollow">%subject%</a>'), ',
403
					sTemplateTopSubject: ', JavaScriptEscape('%subject%'), ',
404
					sTemplateReasonEdit: ', JavaScriptEscape($txt['reason_for_edit'] . ': <input type="text" name="modify_reason" value="%modify_reason%" size="80" maxlength="80" tabindex="' . $context['tabindex']++ . '" class="quickModifyMargin">'), ',
0 ignored issues
show
Coding Style introduced by
Increment and decrement operators must be bracketed when used in string concatenation
Loading history...
405
					sTemplateReasonNormal: ', JavaScriptEscape('%modify_text'), ',
406
					sErrorBorderStyle: ', JavaScriptEscape('1px solid red'), ($context['can_reply']) ? ',
407
					sFormRemoveAccessKeys: \'postmodify\'' : '', '
408
				});
409
410
				aJumpTo[aJumpTo.length] = new JumpTo({
411
					sContainerId: "display_jump_to",
412
					sJumpToTemplate: "<label class=\"smalltext jump_to\" for=\"%select_id%\">', $context['jump_to']['label'], '<" + "/label> %dropdown_list%",
413
					iCurBoardId: ', $context['current_board'], ',
414
					iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
415
					sCurBoardName: "', $context['jump_to']['board_name'], '",
416
					sBoardChildLevelIndicator: "==",
417
					sBoardPrefix: "=> ",
418
					sCatSeparator: "-----------------------------",
419
					sCatPrefix: "",
420
					sGoButtonLabel: "', $txt['go'], '"
421
				});
422
423
				aIconLists[aIconLists.length] = new IconList({
424
					sBackReference: "aIconLists[" + aIconLists.length + "]",
425
					sIconIdPrefix: "msg_icon_",
426
					sScriptUrl: smf_scripturl,
427
					bShowModify: ', !empty($modSettings['show_modify']) ? 'true' : 'false', ',
428
					iBoardId: ', $context['current_board'], ',
429
					iTopicId: ', $context['current_topic'], ',
430
					sSessionId: smf_session_id,
431
					sSessionVar: smf_session_var,
432
					sLabelIconList: "', $txt['message_icon'], '",
433
					sBoxBackground: "transparent",
434
					sBoxBackgroundHover: "#ffffff",
435
					iBoxBorderWidthHover: 1,
436
					sBoxBorderColorHover: "#adadad" ,
437
					sContainerBackground: "#ffffff",
438
					sContainerBorder: "1px solid #adadad",
439
					sItemBorder: "1px solid #ffffff",
440
					sItemBorderHover: "1px dotted gray",
441
					sItemBackground: "transparent",
442
					sItemBackgroundHover: "#e0e0f0"
443
				});
444
			}';
445
446
	if (!empty($context['ignoredMsgs']))
447
		echo '
448
			ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
449
450
	echo '
451
		</script>';
452
}
453
454
/**
455
 * Template for displaying a single post.
456
 *
457
 * @param array $message An array of information about the message to display. Should have 'id' and 'member'. Can also have 'first_new', 'is_ignored' and 'css_class'.
458
 */
459
function template_single_post($message)
460
{
461
	global $context, $settings, $options, $txt, $scripturl, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
462
463
	$ignoring = false;
464
465
	if ($message['can_remove'])
466
		$context['removableMessageIDs'][] = $message['id'];
467
468
	// Are we ignoring this message?
469
	if (!empty($message['is_ignored']))
470
	{
471
		$ignoring = true;
472
		$context['ignoredMsgs'][] = $message['id'];
473
	}
474
475
	// Show the message anchor and a "new" anchor if this message is new.
476
	echo '
477
				<div class="', $message['css_class'], '">
478
					', $message['id'] != $context['first_message'] ? '
479
					<a id="msg' . $message['id'] . '"></a>' . ($message['first_new'] ? '<a id="new"></a>' : '') : '', '
480
					<div class="post_wrapper">';
481
482
	// Show information about the poster of this message.
483
	echo '
484
						<div class="poster">';
485
486
	// Are there any custom fields above the member name?
487 View Code Duplication
	if (!empty($message['custom_fields']['above_member']))
488
	{
489
		echo '
490
							<div class="custom_fields_above_member">
491
								<ul class="nolist">';
492
493
		foreach ($message['custom_fields']['above_member'] as $custom)
494
			echo '
495
									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
496
497
		echo '
498
								</ul>
499
							</div>';
500
	}
501
502
	echo '
503
							<h4>';
504
505
	// Show online and offline buttons?
506
	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
507
		echo '
508
								', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : '';
509
510
	// Custom fields BEFORE the username?
511 View Code Duplication
	if (!empty($message['custom_fields']['before_member']))
512
		foreach ($message['custom_fields']['before_member'] as $custom)
513
			echo '
514
								<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
515
516
	// Show a link to the member's profile.
517
	echo '
518
								', $message['member']['link'];
519
520
	// Custom fields AFTER the username?
521 View Code Duplication
	if (!empty($message['custom_fields']['after_member']))
522
		foreach ($message['custom_fields']['after_member'] as $custom)
523
			echo '
524
								<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
525
526
	// Begin display of user info
527
	echo '
528
							</h4>
529
							<ul class="user_info">';
530
531
	// Show the user's avatar.
532 View Code Duplication
	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
533
		echo '
534
								<li class="avatar">
535
									<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
536
								</li>';
537
538
	// Are there any custom fields below the avatar?
539 View Code Duplication
	if (!empty($message['custom_fields']['below_avatar']))
540
		foreach ($message['custom_fields']['below_avatar'] as $custom)
541
			echo '
542
								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
543
544
	// Show the post group icons, but not for guests.
545
	if (!$message['member']['is_guest'])
546
		echo '
547
								<li class="icons">', $message['member']['group_icons'], '</li>';
548
549
	// Show the member's primary group (like 'Administrator') if they have one.
550
	if (!empty($message['member']['group']))
551
		echo '
552
								<li class="membergroup">', $message['member']['group'], '</li>';
553
554
	// Show the member's custom title, if they have one.
555
	if (!empty($message['member']['title']))
556
		echo '
557
								<li class="title">', $message['member']['title'], '</li>';
558
559
	// Don't show these things for guests.
560
	if (!$message['member']['is_guest'])
561
	{
562
		// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
563
		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group']))
564
			echo '
565
								<li class="postgroup">', $message['member']['post_group'], '</li>';
566
567
		// Show how many posts they have made.
568 View Code Duplication
		if (!isset($context['disabled_fields']['posts']))
569
			echo '
570
								<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
571
572
		// Show their personal text?
573 View Code Duplication
		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb']))
574
			echo '
575
								<li class="blurb">', $message['member']['blurb'], '</li>';
576
577
		// Any custom fields to show as icons?
578 View Code Duplication
		if (!empty($message['custom_fields']['icons']))
579
		{
580
			echo '
581
								<li class="im_icons">
582
									<ol>';
583
584
			foreach ($message['custom_fields']['icons'] as $custom)
585
				echo '
586
										<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
587
588
			echo '
589
									</ol>
590
								</li>';
591
		}
592
593
		// Show the website and email address buttons.
594
		if ($message['member']['show_profile_buttons'])
595
		{
596
			echo '
597
								<li class="profile">
598
									<ol class="profile_icons">';
599
600
			// Don't show an icon if they haven't specified a website.
601 View Code Duplication
			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website']))
602
				echo '
603
										<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
604
605
			// Since we know this person isn't a guest, you *can* message them.
606 View Code Duplication
			if ($context['can_send_pm'])
607
				echo '
608
										<li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
609
610
			// Show the email if necessary
611 View Code Duplication
			if (!empty($message['member']['email']) && $message['member']['show_email'])
612
				echo '
613
										<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
614
615
			echo '
616
									</ol>
617
								</li><!-- .profile -->';
618
		}
619
620
		// Any custom fields for standard placement?
621 View Code Duplication
		if (!empty($message['custom_fields']['standard']))
622
			foreach ($message['custom_fields']['standard'] as $custom)
623
				echo '
624
								<li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>';
625
	}
626
	// Otherwise, show the guest's email.
627 View Code Duplication
	elseif (!empty($message['member']['email']) && $message['member']['show_email'])
628
		echo '
629
								<li class="email">
630
									<a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a>
631
								</li>';
632
633
	// Show the IP to this user for this post - because you can moderate?
634
	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
635
		echo '
636
								<li class="poster_ip">
637
									<a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a>
638
								</li>';
639
640
	// Or, should we show it because this is you?
641
	elseif ($message['can_see_ip'])
642
		echo '
643
								<li class="poster_ip">
644
									<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a>
645
								</li>';
646
647
	// Okay, are you at least logged in? Then we can show something about why IPs are logged...
648
	elseif (!$context['user']['is_guest'])
649
		echo '
650
								<li class="poster_ip">
651
									<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a>
652
								</li>';
653
654
	// Otherwise, you see NOTHING!
655
	else
656
		echo '
657
								<li class="poster_ip">', $txt['logged'], '</li>';
658
659
	// Are we showing the warning status?
660
	// Don't show these things for guests.
661
	if (!$message['member']['is_guest'] && $message['member']['can_see_warning'])
662
		echo '
663
								<li class="warning">
664
									', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span>
665
								</li>';
666
667
	// Are there any custom fields to show at the bottom of the poster info?
668 View Code Duplication
	if (!empty($message['custom_fields']['bottom_poster']))
669
		foreach ($message['custom_fields']['bottom_poster'] as $custom)
670
			echo '
671
								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
672
673
	// Poster info ends.
674
	echo '
675
							</ul>
676
						</div><!-- .poster -->
677
						<div class="postarea">
678
							<div class="keyinfo">';
679
680
	// Some people don't want subject... The div is still required or quick edit breaks.
681
	echo '
682
								<div id="subject_', $message['id'], '" class="subject_title', (empty($modSettings['subject_toggle']) ? ' subject_hidden' : ''), '">
683
									', $message['link'], '
684
								</div>';
685
686
	echo '
687
								<h5>
688
									<span class="messageicon" ', ($message['icon_url'] !== $settings['images_url'] . '/post/xx.png') ? '' : 'style="position: absolute; z-index: -1;"', '>
689
										<img src="', $message['icon_url'] . '" alt=""', $message['can_modify'] ? ' id="msg_icon_' . $message['id'] . '"' : '', '>
690
									</span>
691
									<a href="', $message['href'], '" rel="nofollow" title="', !empty($message['counter']) ? sprintf($txt['reply_number'], $message['counter'], ' - ') : '', $message['subject'], '" class="smalltext">', $message['time'], '</a>
692
									<span class="page_number floatright">
693
										', !empty($message['counter']) ? ' #' . $message['counter'] : '', ' ', '
694
									</span>';
695
696
	// Show "<< Last Edit: Time by Person >>" if this post was edited. But we need the div even if it wasn't modified!
697
	// Because we insert into it through AJAX and we don't want to stop themers moving it around if they so wish so they can put it where they want it.
698
	echo '
699
									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">';
700
701
	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
702
		echo
703
										$message['modified']['last_edit_text'];
704
705
	echo '
706
									</span>
707
								</h5>
708
								<div id="msg_', $message['id'], '_quick_mod"', $ignoring ? ' style="display:none;"' : '', '></div>
709
							</div><!-- .keyinfo -->';
710
711
	// Ignoring this user? Hide the post.
712 View Code Duplication
	if ($ignoring)
713
		echo '
714
							<div id="msg_', $message['id'], '_ignored_prompt">
715
								', $txt['ignoring_user'], '
716
								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
717
							</div>';
718
719
	// Show the post itself, finally!
720
	echo '
721
							<div class="post">';
722
723
	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
724
		echo '
725
								<div class="approve_post">
726
									', $txt['post_awaiting_approval'], '
727
								</div>';
728
	echo '
729
								<div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>
730
									', $message['body'], '
731
								</div>
732
							</div><!-- .post -->';
733
734
	// Assuming there are attachments...
735
	if (!empty($message['attachment']))
736
	{
737
		$last_approved_state = 1;
738
		$attachments_per_line = 5;
739
		$i = 0;
740
		// Don't output the div unless we actually have something to show...
741
		$div_output = false;
742
743
		foreach ($message['attachment'] as $attachment)
744
		{
745
			// Do we want this attachment to not be showed here?
746
			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))
747
				continue;
748
			elseif (!$div_output)
749
			{
750
				$div_output = true;
751
752
				echo '
753
							<div id="msg_', $message['id'], '_footer" class="attachments"', $ignoring ? ' style="display:none;"' : '', '>';
754
			}
755
756
			// Show a special box for unapproved attachments...
757
			if ($attachment['is_approved'] != $last_approved_state)
758
			{
759
				$last_approved_state = 0;
760
				echo '
761
								<fieldset>
762
									<legend>
763
										', $txt['attach_awaiting_approve'];
764
765
				if ($context['can_approve'])
766
					echo '
767
										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
768
769
				echo '
770
									</legend>';
771
			}
772
773
			echo '
774
									<div class="attached">';
775
776
			if ($attachment['is_image'])
777
			{
778
				echo '
779
										<div class="attachments_top">';
780
781
				if ($attachment['thumbnail']['has_thumb'])
782
					echo '
783
											<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>';
784
				else
785
					echo '
786
											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">';
787
788
				echo '
789
										</div><!-- .attachments_top -->';
790
			}
791
792
			echo '
793
										<div class="attachments_bot">
794
											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
795
796
			if (!$attachment['is_approved'] && $context['can_approve'])
797
				echo '
798
											[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
799
			echo '
800
											<br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), '
801
										</div><!-- .attachments_bot -->';
802
803
			echo '
804
									</div><!-- .attached -->';
805
806
			// Next attachment line ?
807
			if (++$i % $attachments_per_line === 0)
0 ignored issues
show
Coding Style introduced by
Increment and decrement operators cannot be used in an arithmetic operation
Loading history...
808
				echo '
809
									<br>';
810
		}
811
812
		// If we had unapproved attachments clean up.
813
		if ($last_approved_state == 0)
814
			echo '
815
								</fieldset>';
816
817
		// Only do this if we output a div above - otherwise it'll break things
818
		if ($div_output)
819
			echo '
820
							</div><!-- #msg_[id]_footer -->';
821
	}
822
823
	// And stuff below the attachments.
824 View Code Duplication
	if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
825
		echo '
826
							<div class="under_message">';
827
828
	// Maybe they want to report this post to the moderator(s)?
829
	if ($context['can_report_moderator'])
830
		echo '
831
								<ul class="floatright smalltext">
832
									<li class="report_link">
833
										<a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a>
834
									</li>
835
								</ul>';
836
837
	// What about likes?
838
	if (!empty($modSettings['enable_likes']))
839
	{
840
		echo '
841
								<ul class="floatleft">';
842
843
		if (!empty($message['likes']['can_like']))
844
		{
845
			echo '
846
									<li class="like_button" id="msg_', $message['id'], '_likes"', $ignoring ? ' style="display:none;"' : '', '>
847
										<a href="', $scripturl, '?action=likes;ltype=msg;sa=like;like=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" class="msg_like"><span class="generic_icons ', $message['likes']['you'] ? 'unlike' : 'like', '"></span> ', $message['likes']['you'] ? $txt['unlike'] : $txt['like'], '</a>
848
									</li>';
849
		}
850
851 View Code Duplication
		if (!empty($message['likes']['count']))
852
		{
853
			$context['some_likes'] = true;
854
			$count = $message['likes']['count'];
855
			$base = 'likes_';
856
857
			if ($message['likes']['you'])
858
			{
859
				$base = 'you_' . $base;
860
				$count--;
861
			}
862
863
			$base .= (isset($txt[$base . $count])) ? $count : 'n';
864
865
			echo '
866
									<li class="like_count smalltext">
867
										', sprintf($txt[$base], $scripturl . '?action=likes;sa=view;ltype=msg;like=' . $message['id'] . ';' . $context['session_var'] . '=' . $context['session_id'], comma_format($count)), '
868
									</li>';
869
		}
870
871
		echo '
872
								</ul>';
873
	}
874
875
	// Show the quickbuttons, for various operations on posts.
876
	if ($message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
877
	{
878
		echo '
879
								<ul class="quickbuttons">';
880
881
		// Can they quote? if so they can select and quote as well!
882
		if ($context['can_quote'])
883
			echo '
884
									<li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>
885
									<li style="display:none;" id="quoteSelected_', $message['id'], '">
886
										<a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a>
887
									</li>';
888
889
		// Can the user modify the contents of this post? Show the modify inline image.
890
		if ($message['can_modify'])
891
			echo '
892
									<li class="quick_edit">
893
										<a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a>
894
									</li>';
895
896 View Code Duplication
		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
897
			echo '
898
									<li class="post_options">', $txt['post_options'];
899
900
		echo '
901
										<ul>';
902
903
		// Can the user modify the contents of this post?
904
		if ($message['can_modify'])
905
			echo '
906
											<li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>';
907
908
		// How about... even... remove it entirely?!
909
		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
910
			echo '
911
											<li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>';
912
913 View Code Duplication
		elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id']))
914
			echo '
915
											<li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
916
917
		// What about splitting it off the rest of the topic?
918
		if ($context['can_split'] && !empty($context['real_num_replies']))
919
			echo '
920
											<li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>';
921
922
		// Can we issue a warning because of this post? Remember, we can't give guests warnings.
923
		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
924
			echo '
925
											<li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>';
926
927
		// Can we restore topics?
928
		if ($context['can_restore_msg'])
929
			echo '
930
											<li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>';
931
932
		// Maybe we can approve it, maybe we should?
933
		if ($message['can_approve'])
934
			echo '
935
											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>';
936
937
		// Maybe we can unapprove it?
938
		if ($message['can_unapprove'])
939
			echo '
940
											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>';
941
942
		echo '
943
										</ul>
944
									</li>';
945
946
		// Show a checkbox for quick moderation?
947 View Code Duplication
		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
948
			echo '
949
									<li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
950
951 View Code Duplication
		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
952
			echo '
953
								</ul><!-- .quickbuttons -->';
954
	}
955
956 View Code Duplication
	if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
957
		echo '
958
							</div><!-- .under_message -->';
959
960
	echo '
961
						</div><!-- .postarea -->
962
						<div class="moderatorbar">';
963
964
	// Are there any custom profile fields for above the signature?
965 View Code Duplication
	if (!empty($message['custom_fields']['above_signature']))
966
	{
967
		echo '
968
							<div class="custom_fields_above_signature">
969
								<ul class="nolist">';
970
971
		foreach ($message['custom_fields']['above_signature'] as $custom)
972
			echo '
973
									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
974
975
		echo '
976
								</ul>
977
							</div>';
978
	}
979
980
	// Show the member's signature?
981
	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
982
		echo '
983
							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>
984
								', $message['member']['signature'], '
985
							</div>';
986
987
988
	// Are there any custom profile fields for below the signature?
989 View Code Duplication
	if (!empty($message['custom_fields']['below_signature']))
990
	{
991
		echo '
992
							<div class="custom_fields_below_signature">
993
								<ul class="nolist">';
994
995
		foreach ($message['custom_fields']['below_signature'] as $custom)
996
			echo '
997
									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
998
999
		echo '
1000
								</ul>
1001
							</div>';
1002
	}
1003
1004
	echo '
1005
						</div><!-- .moderatorbar -->
1006
					</div><!-- .post_wrapper -->
1007
				</div><!-- $message[css_class] -->
1008
				<hr class="post_separator">';
1009
}
1010
1011
/**
1012
 * The template for displaying the quick reply box.
1013
 */
1014
function template_quickreply()
1015
{
1016
	global $context, $modSettings, $scripturl, $options, $txt;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1017
1018
	echo '
1019
		<a id="quickreply"></a>
1020
		<div class="tborder" id="quickreplybox">
1021
			<div class="cat_bar">
1022
				<h3 class="catbg">
1023
					', $txt['quick_reply'], '
1024
				</h3>
1025
			</div>
1026
			<div id="quickReplyOptions">
1027
				<div class="roundframe">';
1028
1029
	// Are we hiding the full editor?
1030
	if (empty($options['use_editor_quick_reply']))
1031
		echo '
1032
					<p class="smalltext lefttext">', $txt['quick_reply_desc'], '</p>';
1033
1034
	// Is the topic locked?
1035
	if ($context['is_locked'])
1036
		echo '
1037
					<p class="alert smalltext">', $txt['quick_reply_warning'], '</p>';
1038
1039
	// Show a warning if the topic is old
1040
	if (!empty($context['oldTopicError']))
1041
		echo '
1042
					<p class="alert smalltext">', sprintf($txt['error_old_topic'], $modSettings['oldTopicDays']), '</p>';
1043
1044
	// Does the post need approval?
1045
	if (!$context['can_reply_approved'])
1046
		echo '
1047
					<p><em>', $txt['wait_for_approval'], '</em></p>';
1048
1049
	echo '
1050
					<form action="', $scripturl, '?board=', $context['current_board'], ';action=post2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" onsubmit="submitonce(this);">
1051
						<input type="hidden" name="topic" value="', $context['current_topic'], '">
1052
						<input type="hidden" name="subject" value="', $context['response_prefix'], $context['subject'], '">
1053
						<input type="hidden" name="icon" value="xx">
1054
						<input type="hidden" name="from_qr" value="1">
1055
						<input type="hidden" name="notify" value="', $context['is_marked_notify'] || !empty($options['auto_notify']) ? '1' : '0', '">
1056
						<input type="hidden" name="not_approved" value="', !$context['can_reply_approved'], '">
1057
						<input type="hidden" name="goback" value="', empty($options['return_to_post']) ? '0' : '1', '">
1058
						<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">
1059
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1060
						<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
1061
1062
	// Guests just need more.
1063
	if ($context['user']['is_guest'])
1064
		echo '
1065
						<dl id="post_header">
1066
							<dt>
1067
								', $txt['name'], ':
1068
							</dt>
1069
							<dd>
1070
								<input type="text" name="guestname" size="25" value="', $context['name'], '" tabindex="', $context['tabindex']++, '">
1071
							</dd>
1072
							<dt>
1073
								', $txt['email'], ':
1074
							</dt>
1075
							<dd>
1076
								<input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" required>
1077
							</dd>
1078
						</dl>';
1079
1080
	echo '
1081
						', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
0 ignored issues
show
Documentation introduced by
'smileyBox_message' is of type string, but the function expects a null|boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
'bbcBox_message' is of type string, but the function expects a null|boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1082
						<script>
1083
							function insertQuoteFast(messageid)
1084
							{
1085
								if (window.XMLHttpRequest)
1086
									getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';xml;pb=', $context['post_box_name'], ';mode=\' + (oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled ? 1 : 0), onDocReceived);
1087
								else
1088
									reqWin(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';pb=', $context['post_box_name'], ';mode=\' + (oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled ? 1 : 0), 240, 90);
1089
								return false;
1090
							}
1091
							function onDocReceived(XMLDoc)
1092
							{
1093
								var text = \'\';
1094
								for (var i = 0, n = XMLDoc.getElementsByTagName(\'quote\')[0].childNodes.length; i < n; i++)
1095
									text += XMLDoc.getElementsByTagName(\'quote\')[0].childNodes[i].nodeValue;
1096
								sceditor.instance($("#', $context['post_box_name'], '").get(0)).InsertText(text);
1097
1098
								ajax_indicator(false);
1099
							}
1100
						</script>';
1101
1102
	// Is visual verification enabled?
1103 View Code Duplication
	if ($context['require_verification'])
1104
		echo '
1105
						<div class="post_verification">
1106
							<strong>', $txt['verification'], ':</strong>
1107
							', template_control_verification($context['visual_verification_id'], 'all'), '
1108
						</div>';
1109
1110
	// Finally, the submit buttons.
1111
	echo '
1112
						<br class="clear_right">
1113
						<span id="post_confirm_buttons" class="floatright">
1114
							', template_control_richedit_buttons($context['post_box_name']), '
1115
						</span>';
1116
	echo '
1117
					</form>
1118
				</div><!-- .roundframe -->
1119
			</div><!-- #quickReplyOptions -->
1120
		</div><!-- #quickreplybox -->
1121
		<br class="clear">';
1122
1123
	// Draft autosave available and the user has it enabled?
1124
	if (!empty($context['drafts_autosave']))
1125
		echo '
1126
		<script>
1127
			var oDraftAutoSave = new smf_DraftAutoSave({
1128
				sSelf: \'oDraftAutoSave\',
1129
				sLastNote: \'draft_lastautosave\',
1130
				sLastID: \'id_draft\',', !empty($context['post_box_name']) ? '
1131
				sSceditorID: \'' . $context['post_box_name'] . '\',' : '', '
1132
				sType: \'', 'quick', '\',
1133
				iBoard: ', (empty($context['current_board']) ? 0 : $context['current_board']), ',
1134
				iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
1135
			});
1136
		</script>';
1137
1138
	if ($context['show_spellchecking'])
1139
		echo '
1140
		<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow">
1141
			<input type="hidden" name="spellstring" value="">
1142
		</form>';
1143
1144
	echo '
1145
		<script>
1146
			var oQuickReply = new QuickReply({
1147
				bDefaultCollapsed: false,
1148
				iTopicId: ', $context['current_topic'], ',
1149
				iStart: ', $context['start'], ',
1150
				sScriptUrl: smf_scripturl,
1151
				sImagesUrl: smf_images_url,
1152
				sContainerId: "quickReplyOptions",
1153
				sImageId: "quickReplyExpand",
1154
				sClassCollapsed: "toggle_up",
1155
				sClassExpanded: "toggle_down",
1156
				sJumpAnchor: "quickreply",
1157
				bIsFull: true
1158
			});
1159
			var oEditorID = "', $context['post_box_name'], '";
1160
			var oEditorObject = oEditorHandle_', $context['post_box_name'], ';
1161
			var oJumpAnchor = "quickreply";
1162
		</script>';
1163
}
1164
1165
?>