Completed
Pull Request — patch_1-1-4 (#3210)
by Emanuele
12:56
created

Post.template.php ➔ template_post_page()   B

Complexity

Conditions 8
Paths 8

Size

Total Lines 40

Duplication

Lines 3
Ratio 7.5 %

Importance

Changes 0
Metric Value
cc 8
nc 8
nop 0
dl 3
loc 40
rs 8.0355
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @name      ElkArte Forum
5
 * @copyright ElkArte Forum contributors
6
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
7
 *
8
 * This file contains code covered by:
9
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
10
 * license:  	BSD, See included LICENSE.TXT for terms and conditions.
11
 *
12
 * @version 1.1.2
13
 *
14
 */
15
16
/**
17
 * Load in the generic templates for use
18
 */
19
function template_Post_init()
20
{
21
	loadTemplate('GenericHelpers');
22
}
23
24
/**
25
 * The area above the post box,
26
 * Typically holds subject, preview, info messages, message icons, etc
27
 */
28
function template_postarea_above()
29
{
30
	global $context, $scripturl, $txt, $modSettings;
31
32
	// Start the javascript...
33
	echo '
34
		<script>';
35
36
	// When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
37
	if (isBrowser('is_firefox'))
38
		echo '
39
			window.addEventListener("pageshow", reActivate, false);';
40
41
	// Start with message icons - and any missing from this theme.
42
	echo '
43
			var icon_urls = {';
44 View Code Duplication
	foreach ($context['icons'] as $icon)
45
		echo '
46
				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
47
	echo '
48
			};';
49
50
	// End of the javascript
51
	echo '
52
		</script>';
53
54
	// Start the form and display the link tree.
55
	echo '
56
		<form id="postmodify" action="', $scripturl, '?action=', $context['destination'], ';', empty($context['current_board']) ? '' : 'board=' . $context['current_board'], '" method="post" accept-charset="UTF-8" name="postmodify" class="flow_hidden" onsubmit="', ($context['becomes_approved'] ? '' : 'alert(\'' . $txt['js_post_will_require_approval'] . '\');'), 'submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'', $context['post_box_name'], '\', \'guestname\', \'evtitle\', \'question\'], \'options\');revalidateMentions(\'postmodify\', \'', $context['post_box_name'], '\');" enctype="multipart/form-data">';
57
58
	// If the user wants to see how their message looks - the preview section is where it's at!
59
	echo '
60
			<div id="preview_section"', isset($context['preview_message']) ? '' : ' class="hide"', '>
61
				<h2 class="category_header">
62
					<span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
63
				</h2>
64
				<div id="preview_body">
65
					', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
66
				</div>
67
			</div>';
68
69
	// Start the main table.
70
	echo '
71
			<div id="forumposts">', isset($context['current_topic']) ? '<input type="hidden" name="topic" value="' . $context['current_topic'] . '" />' : '', '
72
				<h2 class="category_header">', $context['page_title'], '</h2>
73
				<div class="forumposts">
74
					<div class="editor_wrapper">';
75
76
	// If an error occurred, explain what happened.
77
	template_show_error('post_error');
78
	if (!empty($context['attachment_error_keys']))
79
		template_attachment_errors();
80
81
	// If this won't be approved let them know!
82
	// @todo why not use the template_show_error above?
83
	if (!$context['becomes_approved'])
84
	{
85
		echo '
86
						<div class="successbox">
87
							', $txt['wait_for_approval'], '
88
							<input type="hidden" name="not_approved" value="1" />
89
						</div>';
90
	}
91
92
	// If it's locked, show a message to warn the replyer.
93
	// @todo why not output it only for locked topics and why not use the template_show_error above?
94
	echo '
95
						<p id="lock_warning" class="information', $context['locked'] ? '"' : ' hide"', '>
96
							', $txt['topic_locked_no_reply'], '
97
						</p>';
98
99
	if (!empty($context['drafts_autosave']))
100
		echo '
101
						<div id="draft_section" class="successbox', isset($context['draft_saved']) ? '"' : ' hide"', '>
102
							', sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
103
						</div>';
104
105
	// The post header... important stuff
106
	echo '
107
						<dl id="post_header">';
108
109
	// Guests have to put in their name and email...
110
	if (isset($context['name']) && isset($context['email']))
111
	{
112
		echo '
113
							<dt>
114
								<label for="guestname"', isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '', ' id="caption_guestname">', $txt['name'], ':</label>
115
							</dt>
116
							<dd>
117
								<input type="text" id="guestname" name="guestname" size="25" value="', $context['name'], '" tabindex="', $context['tabindex']++, '" class="input_text" required="required" />
118
							</dd>';
119
120
		if (empty($modSettings['guest_post_no_email']))
121
			echo '
122
							<dt>
123
								<label for="email"', isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '', ' id="caption_email">', $txt['email'], ':</label>
124
							</dt>
125
							<dd>
126
								<input type="email" id="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required="required" />
127
							</dd>';
128
	}
129
130
	// Now show the subject box for this post.
131
	echo '
132
							<dt class="clear">
133
								<label for="post_subject"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</label>
134
							</dt>
135
							<dd>
136
								<input id="post_subject" type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', ' placeholder="', $txt['subject'], '" required="required" />
137
							</dd>
138
							<dt class="clear_left">
139
								<label for="icon">', $txt['message_icon'], '</label>:
140
							</dt>
141
							<dd>
142
								<select name="icon" id="icon" onchange="showimage()">';
143
144
	// Loop through each message icon allowed, adding it to the drop down list.
145 View Code Duplication
	foreach ($context['icons'] as $icon)
146
		echo '
147
									<option value="', $icon['value'], '"', $icon['value'] == $context['icon'] ? ' selected="selected"' : '', '>', $icon['name'], '</option>';
148
149
	echo '
150
								</select>
151
								<img src="', $context['icon_url'], '" id="icons" alt="" />
152
							</dd>';
153
154
	if (!empty($context['show_boards_dropdown']))
155
		echo '
156
							<dt class="clear_left">
157
								<label for="post_in_board">', $txt['post_in_board'], '</label>:
158
							</dt>
159
							<dd>', template_select_boards('post_in_board'), '
160
							</dd>';
161
162
	echo '
163
						</dl>';
164
}
165
166
/**
167
 * Area above the poll edit
168
 */
169
function template_poll_edit_above()
170
{
171
	echo '
172
						<div class="separator"></div>
173
						<div id="edit_poll">';
174
175
	template_poll_edit();
176
177
	echo '
178
						</div>';
179
}
180
181
/**
182
 * Area above the event box
183
 */
184
function template_make_event_above()
185
{
186
	global $context, $txt, $modSettings;
187
188
	// Are you posting a calendar event?
189
	echo '
190
						<hr class="clear" />
191
						<div id="post_event">
192
							<fieldset id="event_main">
193
								<legend>', $txt['calendar_event_options'], '</legend>
194
								<label for="evtitle"', isset($context['post_error']['no_event']) ? ' class="error"' : '', ' id="caption_evtitle">', $txt['calendar_event_title'], ':</label>
195
								<input type="text" id="evtitle" name="evtitle" maxlength="255" size="55" value="', $context['event']['title'], '" tabindex="', $context['tabindex']++, '" class="input_text" />
196
								<div id="datepicker">
197
									<input type="hidden" name="calendar" value="1" /><label for="year">', $txt['calendar_year'], '</label>
198
									<select name="year" id="year" tabindex="', $context['tabindex']++, '" onchange="generateDays();">';
199
200
	// Show a list of all the years we allow...
201 View Code Duplication
	for ($year = $context['cal_minyear']; $year <= $context['cal_maxyear']; $year++)
202
		echo '
203
										<option value="', $year, '"', $year == $context['event']['year'] ? ' selected="selected"' : '', '>', $year, '&nbsp;</option>';
204
205
	echo '
206
									</select>
207
									<label for="month">', $txt['calendar_month'], '</label>
208
									<select name="month" id="month" onchange="generateDays();">';
209
210
	// There are 12 months per year - ensure that they all get listed.
211
	for ($month = 1; $month <= 12; $month++)
212
		echo '
213
										<option value="', $month, '"', $month == $context['event']['month'] ? ' selected="selected"' : '', '>', $txt['months'][$month], '&nbsp;</option>';
214
215
	echo '
216
									</select>
217
									<label for="day">', $txt['calendar_day'], '</label>
218
									<select name="day" id="day">';
219
220
	// This prints out all the days in the current month - this changes dynamically as we switch months.
221
	for ($day = 1; $day <= $context['event']['last_day']; $day++)
222
		echo '
223
										<option value="', $day, '"', $day == $context['event']['day'] ? ' selected="selected"' : '', '>', $day, '&nbsp;</option>';
224
225
	echo '
226
									</select>
227
								</div>';
228
229
	if (!empty($modSettings['cal_allowspan']) || ($context['event']['new'] && $context['is_new_post']))
230
	{
231
		echo '
232
								<ul class="event_options">';
233
234
		// If events can span more than one day then allow the user to select how long it should last.
235 View Code Duplication
		if (!empty($modSettings['cal_allowspan']))
236
		{
237
			echo '
238
									<li>
239
										<label for="span">', $txt['calendar_numb_days'], '</label>
240
										<select id="span" name="span">';
241
242
			for ($days = 1; $days <= $modSettings['cal_maxspan']; $days++)
243
				echo '
244
											<option value="', $days, '"', $days == $context['event']['span'] ? ' selected="selected"' : '', '>', $days, '&nbsp;</option>';
245
246
			echo '
247
										</select>
248
									</li>';
249
		}
250
251
		// If this is a new event let the user specify which board they want the linked post to be put into.
252 View Code Duplication
		if ($context['event']['new'] && $context['is_new_post'])
253
		{
254
			echo '
255
									<li>
256
										', template_select_boards('board', $txt['calendar_post_in']), '
257
									</li>';
258
		}
259
260
		echo '
261
								</ul>';
262
	}
263
264 View Code Duplication
	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
265
		echo '
266
								<input type="hidden" name="eventid" value="', $context['event']['id'], '" />';
267
268
	echo '
269
							</fieldset>
270
						</div>';
271
}
272
273
/**
274
 * The main template for the post page.
275
 */
276
function template_post_page()
277
{
278
	global $context, $txt;
279
280
	// Show the actual posting area...
281
	echo '
282
					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
283
284
	// A placeholder for our mention box if needed
285
	if (!empty($context['member_ids']))
286
	{
287
		echo '
288
							<div id="mentioned" class="hide">';
289
290
		foreach ($context['member_ids'] as $id)
291
			echo '
292
								<input type="hidden" name="uid[]" value="', $id, '" />';
293
294
		echo '
295
							</div>';
296
	}
297
298
	// Show our submit buttons before any more options
299
	echo '
300
						<div id="post_confirm_buttons" class="submitbutton">
301
							', template_control_richedit_buttons($context['post_box_name']);
302
303
	// Option to delete an event if user is editing one.
304 View Code Duplication
	if (!empty($context['make_event']) && !$context['event']['new'])
305
		echo '
306
							<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" onclick="return confirm(\'', $txt['event_delete_confirm'], '\');" />';
307
308
	// Option to add a poll (javascript if enabled, otherwise preview with poll)
309
	if (empty($context['make_poll']) && $context['can_add_poll'])
310
		echo '
311
							<input type="submit" name="poll" aria-label="', $txt['add_poll'], '" value="', $txt['add_poll'], '" onclick="return loadAddNewPoll(this, ', empty($context['current_board']) ? '0' : $context['current_board'], ', \'postmodify\');" />';
312
313
	echo '
314
						</div>';
315
}
316
317
/**
318
 * Show the additional options section, allowing locking, sticky, adding of attachments, etc
319
 */
320
function template_additional_options_below()
321
{
322
	global $context, $settings, $options, $txt;
323
324
	// If the admin has enabled the hiding of the additional options - show a link and image for it.
325
	if (!empty($settings['additional_options_collapsible']))
326
		echo '
327
					<h3 id="postAdditionalOptionsHeader" class="category_header panel_toggle">
328
							<i id="postMoreExpand" class="chevricon i-chevron-', empty($context['minmax_preferences']['post']) ? 'up' : 'down', ' hide" title="', $txt['hide'], '"></i>
329
						<a href="#" id="postMoreExpandLink">', !empty($context['attachments']) && $context['attachments']['can']['post'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a>
330
					</h3>';
331
332
	echo '
333
					<div id="', empty($settings['additional_options_collapsible']) ? 'postAdditionalOptionsNC"' : 'postAdditionalOptions"', empty($settings['additional_options_collapsible']) || empty($context['minmax_preferences']['post']) ? '' : ' class="hide"', '>';
334
335
	// Is the user allowed to post or if this post already has attachments on it give them the boxes.
336
	if (!empty($context['attachments']) && ($context['attachments']['can']['post'] || !empty($context['attachments']['current'])))
337
		$context['attachments']['template']();
338
339
	// Display the check boxes for all the standard options - if they are available to the user!
340
	echo '
341
						<div id="postMoreOptions" class="smalltext">
342
							<ul class="post_options">
343
								', $context['can_notify'] ? '<li><input type="hidden" name="notify" value="0" /><label for="check_notify"><input type="checkbox" name="notify" id="check_notify"' . ($context['notify'] || !empty($options['auto_notify']) ? ' checked="checked"' : '') . ' value="1" /> ' . $txt['notify_replies'] . '</label></li>' : '', '
344
								', $context['can_lock'] ? '<li><input type="hidden" name="lock" value="0" /><label for="check_lock"><input type="checkbox" name="lock" id="check_lock"' . ($context['locked'] ? ' checked="checked"' : '') . ' value="1" /> ' . $txt['lock_topic'] . '</label></li>' : '', '
345
								<li><label for="check_back"><input type="checkbox" name="goback" id="check_back"' . ($context['back_to_topic'] || !empty($options['return_to_post']) ? ' checked="checked"' : '') . ' value="1" /> ' . $txt['back_to_topic'] . '</label></li>
346
								', $context['can_sticky'] ? '<li><input type="hidden" name="sticky" value="0" /><label for="check_sticky"><input type="checkbox" name="sticky" id="check_sticky"' . ($context['sticky'] ? ' checked="checked"' : '') . ' value="1" /> ' . $txt['sticky_after'] . '</label></li>' : '', '
347
								<li><label for="check_smileys"><input type="checkbox" name="ns" id="check_smileys"', $context['use_smileys'] ? '' : ' checked="checked"', ' value="NS" /> ', $txt['dont_use_smileys'], '</label></li>', '
348
								', $context['can_move'] ? '<li><input type="hidden" name="move" value="0" /><label for="check_move"><input type="checkbox" name="move" id="check_move" value="1" ' . (!empty($context['move']) ? 'checked="checked" ' : '') . '/> ' . $txt['move_after2'] . '</label></li>' : '', '
349
								', $context['can_announce'] && $context['is_first_post'] ? '<li><label for="check_announce"><input type="checkbox" name="announce_topic" id="check_announce" value="1" ' . (!empty($context['announce']) ? 'checked="checked" ' : '') . '/> ' . $txt['announce_topic'] . '</label></li>' : '', '
350
								', $context['show_approval'] ? '<li><label for="approve"><input type="checkbox" name="approve" id="approve" value="2" ' . ($context['show_approval'] === 2 ? 'checked="checked"' : '') . ' /> ' . $txt['approve_this_post'] . '</label></li>' : '', '
351
							</ul>
352
						</div>';
353
354
	echo '
355
					</div>';
356
}
357
358
/**
359
 * Creates the interface to upload attachments
360
 */
361
function template_add_new_attachments()
362
{
363
	global $context, $txt, $modSettings;
364
365
	echo '
366
						<span id="postAttachment"></span>
367
						<dl id="postAttachment2">';
368
369
	// Show the box even if they reached the limit, maybe they want to remove one!
370
	if (empty($context['dont_show_them']))
371
	{
372
		echo '
373
							<dt class="drop_area">
374
								<i class="icon i-upload"></i>
375
								<span class="desktop">', $txt['attach_drop_files'], '</span>
376
								<span class="mobile">', $txt['attach_drop_files_mobile'], '</span>
377
								<input id="attachment_click" class="drop_area_fileselect input_file" type="file" multiple="multiple" name="attachment_click[]" />
378
							</dt>
379
							<dd class="progress_tracker"></dd>
380
							<dd class="drop_attachments_error"></dd>
381
							<dt class="drop_attachments_no_js">
382
								', $txt['attach'], ':
383
							</dt>
384
							<dd class="smalltext drop_attachments_no_js">
385
								', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1028 . '" />'), '
386
								<input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
387
388
		// Show more boxes if they aren't approaching that limit.
389
		if ($context['attachments']['num_allowed'] > 1)
390
			echo '
391
								<script>
392
									var allowed_attachments = ', $context['attachments']['num_allowed'], ',
393
										current_attachment = 1,
394
										txt_more_attachments_error = "', $txt['more_attachments_error'], '",
395
										txt_more_attachments = "', $txt['more_attachments'], '",
396
										txt_clean_attach = "', $txt['clean_attach'], '";
397
								</script>
398
							</dd>
399
							<dd class="smalltext drop_attachments_no_js" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a></dd>';
400
		else
401
			echo '
402
							</dd>';
403
	}
404
405
	foreach ($context['attachments']['current'] as $attachment)
406
	{
407
		$label = $attachment['name'];
408
		if (empty($attachment['approved']))
409
			$label .= ' (' . $txt['awaiting_approval'] . ')';
410
		if (!empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']))
411
			$label .= sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1028) / 1028), 0));
412
413
		echo '
414
							<dd class="smalltext">
415
								<label for="attachment_', $attachment['id'], '">
416
									<input type="checkbox" id="attachment_', $attachment['id'], '" name="attach_del[]" value="', $attachment['id'], '"', empty($attachment['unchecked']) ? ' checked="checked"' : '', ' class="input_check inline_insert" data-attachid="', $attachment['id'], '" data-size="', $attachment['size'], '"/> ', $label, '
417
								</label>
418
							</dd>';
419
	}
420
421
	echo '
422
							<dd class="smalltext">';
423
424
	// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
425
	if (!empty($context['attachments']['allowed_extensions']))
426
		echo '
427
								', $txt['allowed_types'], ': ', $context['attachments']['allowed_extensions'], '<br />';
428
429
	if (!empty($context['attachments']['restrictions']))
430
		echo '
431
								', $txt['attach_restrictions'], ' ', implode(', ', $context['attachments']['restrictions']), '<br />';
432
433
	if ($context['attachments']['num_allowed'] == 0)
434
		echo '
435
								', $txt['attach_limit_nag'], '<br />';
436
437
	if (!$context['attachments']['can']['post_unapproved'])
438
		echo '
439
								<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br />';
440
441
	echo '
442
							</dd>
443
						</dl>';
444
445
	if (!empty($context['attachments']['ila_enabled']))
446
	{
447
		addInlineJavascript('
448
		var IlaDropEvents = {
449
			UploadSuccess: function($button, data) {
450
				var inlineAttach = ElkInlineAttachments(\'#postAttachment2,#postAttachment\', \'' . $context['post_box_name'] . '\', {
451
					trigger: $(\'<div class="share icon i-share" />\'),
452
					template: ' . JavaScriptEscape('<div class="insertoverlay">
453
						<input type="button" class="button" value="insert">
454
						<ul data-group="tabs" class="tabs">
455
							<li data-tab="size">' . $txt['ila_opt_size'] . '</li><li data-tab="align">' . $txt['ila_opt_align'] . '</li>
456
						</ul>
457
						<div class="container" data-visual="size">
458
							<label><input data-size="thumb" type="radio" name="imgmode">' . $txt['ila_opt_size_thumb'] . '</label>
459
							<label><input data-size="full" type="radio" name="imgmode">' . $txt['ila_opt_size_full'] . '</label>
460
							<label><input data-size="cust" type="radio" name="imgmode">' . $txt['ila_opt_size_cust'] . '</label>
461
							<div class="customsize">
462
								<input type="range" class="range" min="100" max="500"><input type="text" class="visualizesize" disabled="disabled">
463
							</div>
464
						</div>
465
						<div class="container" data-visual="align">
466
							<label><input data-align="none" type="radio" name="align">' . $txt['ila_opt_align_none'] . '</label>
467
							<label><input data-align="left" type="radio" name="align">' . $txt['ila_opt_align_left'] . '</label>
468
							<label><input data-align="center" type="radio" name="align">' . $txt['ila_opt_align_center'] . '</label>
469
							<label><input data-align="right" type="radio" name="align">' . $txt['ila_opt_align_right'] . '</label>
470
						</div>
471
					</div>') . '
472
				});
473
				inlineAttach.addInterface($button, data.attachid);
474
			},
475
			RemoveSuccess: function(attachid) {
476
				var inlineAttach = ElkInlineAttachments(\'#postAttachment2,#postAttachment\', \'' . $context['post_box_name'] . '\', {
477
					trigger: $(\'<div class="share icon i-share" />\')
478
				});
479
				inlineAttach.removeAttach(attachid);
480
			}
481
		};', true);
482
	}
483
	else
484
	{
485
		addInlineJavascript('
486
		var IlaDropEvents = {};', true);
487
	}
488
489
	// Load up the drag and drop attachment magic
490
	addInlineJavascript('
491
	var dropAttach = new dragDropAttachment({
492
		board: ' . $context['current_board'] . ',
493
		allowedExtensions: ' . JavaScriptEscape($context['attachments']['allowed_extensions']) . ',
494
		totalSizeAllowed: ' . JavaScriptEscape(empty($modSettings['attachmentPostLimit']) ? '' : $modSettings['attachmentPostLimit']) . ',
495
		individualSizeAllowed: ' . JavaScriptEscape(empty($modSettings['attachmentSizeLimit']) ? '' : $modSettings['attachmentSizeLimit']) . ',
496
		numOfAttachmentAllowed: ' . $context['attachments']['num_allowed'] . ',
497
		totalAttachSizeUploaded: ' . (isset($context['attachments']['total_size']) && !empty($context['attachments']['total_size']) ? $context['attachments']['total_size'] : 0) . ',
498
		numAttachUploaded: ' . (isset($context['attachments']['quantity']) && !empty($context['attachments']['quantity']) ? $context['attachments']['quantity'] : 0) . ',
499
		fileDisplayTemplate: \'<div class="statusbar"><div class="info"></div><div class="progressBar"><div></div></div><div class="control icon i-close"></div></div>\',
500
		oTxt: {
501
			allowedExtensions : ' . JavaScriptEscape(sprintf($txt['cant_upload_type'], $context['attachments']['allowed_extensions'])) . ',
502
			totalSizeAllowed : ' . JavaScriptEscape($txt['attach_max_total_file_size']) . ',
503
			individualSizeAllowed : ' . JavaScriptEscape(sprintf($txt['file_too_big'], comma_format($modSettings['attachmentSizeLimit'], 0))) . ',
504
			numOfAttachmentAllowed : ' . JavaScriptEscape(sprintf($txt['attachments_limit_per_post'], $modSettings['attachmentNumPerPostLimit'])) . ',
505
			postUploadError : ' . JavaScriptEscape($txt['post_upload_error']) . ',
506
			areYouSure: ' . JavaScriptEscape($txt['ila_confirm_removal']) . '
507
		},
508
		existingSelector: \'.inline_insert\',
509
		events: IlaDropEvents' . (isset($context['current_topic']) ? ',
510
			topic: ' . $context['current_topic'] : '') . '
511
	});', true);
512
}
513
514
/**
515
 * Shows the draft selection box
516
 */
517
function template_load_drafts_below()
518
{
519
	global $context, $txt;
520
521
	// Show a draft selection box
522
	echo '
523
					<h3 id="postDraftOptionsHeader" class="category_header panel_toggle">
524
							<i id="postDraftExpand" class="chevricon i-chevron-', empty($context['minmax_preferences']['draft']) ? 'up' : 'down', ' hide" title="', $txt['hide'], '"></i>
525
						<a href="#" id="postDraftExpandLink">', $txt['draft_load'], '</a>
526
					</h3>
527
					<div id="postDraftOptions"', empty($context['minmax_preferences']['draft']) ? '' : ' class="hide"', '>
528
						<dl class="settings">
529
							<dt>
530
								<strong>', $txt['subject'], '</strong>
531
							</dt>
532
							<dd>
533
								<strong>', $txt['draft_saved_on'], '</strong>
534
							</dd>';
535
536
	foreach ($context['drafts'] as $draft)
537
		echo '
538
							<dt>', $draft['link'], '</dt>
539
							<dd>', $draft['poster_time'], '</dd>';
540
541
	echo '
542
						</dl>
543
					</div>';
544
545
	// Code for showing and hiding drafts
546
	addInlineJavascript('
547
			var oSwapDraftOptions = new elk_Toggle({
548
				bToggleEnabled: true,
549
				bCurrentlyCollapsed: ' . (empty($context['minmax_preferences']['draft']) ? 'false' : 'true') . ',
550
				aSwappableContainers: [
551
					\'postDraftOptions\',
552
				],
553
				aSwapClasses: [
554
					{
555
						sId: \'postDraftExpand\',
556
						classExpanded: \'chevricon i-chevron-up\',
557
						titleExpanded: ' . JavaScriptEscape($txt['hide']) . ',
558
						classCollapsed: \'chevricon i-chevron-down\',
559
						titleCollapsed: ' . JavaScriptEscape($txt['show']) . '
560
					}
561
				],
562
				aSwapLinks: [
563
					{
564
						sId: \'postDraftExpandLink\',
565
						msgExpanded: ' . JavaScriptEscape($txt['draft_hide']) . ',
566
						msgCollapsed: ' . JavaScriptEscape($txt['draft_load']) . '
567
					}
568
				],
569
				oThemeOptions: {
570
					bUseThemeSettings: ' . ($context['user']['is_guest'] ? 'false' : 'true') . ',
571
					sOptionName: \'minmax_preferences\',
572
					sSessionId: elk_session_id,
573
					sSessionVar: elk_session_var,
574
					sAdditionalVars: \';minmax_key=draft\'
575
				},
576
			});
577
		', true);
578
}
579
580
/**
581
 * Show the topic replies below the post box
582
 */
583
function template_topic_replies_below()
584
{
585
	global $context, $txt;
586
587
	// If the user is replying to a topic show the previous posts.
588
	if (isset($context['previous_posts']) && count($context['previous_posts']) > 0)
589
	{
590
		echo '
591
		<div id="topic_summary">
592
			<h2 class="category_header">', $txt['topic_summary'], '</h2>
593
			<span id="new_replies"></span>';
594
595
		$ignored_posts = array();
596
		foreach ($context['previous_posts'] as $post)
597
		{
598
			$ignoring = false;
599
			if (!empty($post['is_ignored']))
600
				$ignored_posts[] = $ignoring = $post['id'];
601
602
			echo '
603
			<div class="content forumposts">
604
				<div class="postarea2" id="msg', $post['id'], '">
605
					<div class="keyinfo">
606
						<h5 class="floatleft">
607
							<span>', $txt['posted_by'], '</span>&nbsp;', $post['poster'], '&nbsp;-&nbsp;', $post['time'], '
608
						</h5>';
609
610
			if ($context['can_quote'])
611
				echo '
612
						<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
613
							<li class="listlevel1"><a href="#postmodify" onmousedown="return insertQuoteFast(', $post['id'], ');" class="linklevel1 quote_button">', $txt['bbc_quote'], '</a></li>
614
						</ul>';
615
616
			echo '
617
					</div>';
618
619 View Code Duplication
			if ($ignoring)
620
				echo '
621
					<div id="msg_', $post['id'], '_ignored_prompt">
622
						', $txt['ignoring_user'], '
623
						<a href="#" id="msg_', $post['id'], '_ignored_link" class="hide">', $txt['show_ignore_user_post'], '</a>
624
					</div>';
625
626
			echo '
627
					<div class="inner" id="msg_', $post['id'], '_body">', $post['body'], '</div>
628
				</div>
629
			</div>';
630
		}
631
632
		echo '
633
		</div>
634
		<script>
635
			var aIgnoreToggles = [];';
636
637
		foreach ($ignored_posts as $post_id)
638
		{
639
			echo '
640
			aIgnoreToggles[', $post_id, '] = new elk_Toggle({
641
				bToggleEnabled: true,
642
				bCurrentlyCollapsed: true,
643
				aSwappableContainers: [
644
					\'msg_', $post_id, '_body\',
645
					\'msg_', $post_id, '_quote\',
646
				],
647
				aSwapLinks: [
648
					{
649
						sId: \'msg_', $post_id, '_ignored_link\',
650
						msgExpanded: \'\',
651
						msgCollapsed: ', JavaScriptEscape($txt['show_ignore_user_post']), '
652
					}
653
				]
654
			});';
655
		}
656
657
		echo '
658
		</script>';
659
	}
660
}
661
662
/**
663
 * The area below the postbox
664
 * Typically holds our action buttons, save, preivew, drafts, etc
665
 * Oh and lots of JS ;)
666
 */
667
function template_postarea_below()
668
{
669
	global $context, $txt, $counter, $settings;
670
671
	// Is visual verification enabled?
672
	if (!empty($context['require_verification']))
673
	{
674
		template_verification_controls($context['visual_verification_id'], '
675
						<div class="post_verification">
676
							<span' . (!empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '') . '>
677
								<strong>' . $txt['verification'] . ':</strong>
678
							</span>
679
							', '
680
						</div>');
681
	}
682
683
	echo '
684
						</div>
685
					</div>
686
				</div>';
687
688
	// Assuming this isn't a new topic pass across the last message id.
689
	if (isset($context['topic_last_message']))
690
	{
691
		echo '
692
			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '" />';
693
	}
694
695
	// Better remember the draft id when passing from a page to another.
696
	if (isset($context['id_draft']))
697
	{
698
		echo '
699
			<input type="hidden" name="id_draft" value="', $context['id_draft'], '" />';
700
	}
701
702
	// If we are starting a new topic starting from another one, here is the place to remember some details
703
	if (!empty($context['original_post']))
704
		echo '
705
			<input type="hidden" name="followup" value="' . $context['original_post'] . '" />';
706
707
	echo '
708
			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '" />
709
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
710
			<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
711
		</form>';
712
713
	// The variables used to preview a post without loading a new page.
714
	echo '
715
		<script>
716
			var form_name = "postmodify",
717
				preview_area = "post",
718
				current_board = ', empty($context['current_board']) ? 'null' : $context['current_board'], ',
719
				txt_preview_title = "', $txt['preview_title'], '",
720
				txt_preview_fetch = "', $txt['preview_fetch'], '",
721
				make_poll = ', $context['make_poll'] ? 'true' : 'false', ',
722
				new_replies = new Array(),
723
				reply_counter = ', empty($counter) ? 0 : $counter, ',
724
				can_quote = ', $context['can_quote'] ? 'true' : 'false', ',
725
				show_ignore_user_post = "', $txt['show_ignore_user_post'], '",
726
				txt_bbc_quote = "', $txt['bbc_quote'], '",
727
				txt_ignoring_user = "', $txt['ignoring_user'], '",
728
				txt_new = "', $txt['new'], '",
729
				txt_posted_by = "', $txt['posted_by'], '",
730
				txt_on = "', $txt['on'], '";
731
		</script>';
732
733
	// Code for showing and hiding additional options.
734
	if (!empty($settings['additional_options_collapsible']))
735
		addInlineJavascript('
736
			var oSwapAdditionalOptions = new elk_Toggle({
737
				bToggleEnabled: true,
738
				bCurrentlyCollapsed: ' . (empty($context['minmax_preferences']['post']) ? 'false' : 'true') . ',
739
				funcOnBeforeCollapse: function () {
740
					document.getElementById(\'additional_options\').value = \'0\';
741
				},
742
				funcOnBeforeExpand: function () {
743
					document.getElementById(\'additional_options\').value = \'1\';
744
				},
745
				aSwappableContainers: [
746
					\'postAdditionalOptions\',
747
				],
748
				aSwapClasses: [
749
					{
750
						sId: \'postMoreExpand\',
751
						classExpanded: \'chevricon i-chevron-up\',
752
						titleExpanded: ' . JavaScriptEscape($txt['hide']) . ',
753
						classCollapsed: \'chevricon i-chevron-down\',
754
						titleCollapsed: ' . JavaScriptEscape($txt['show']) . '
755
					}
756
				],
757
				aSwapLinks: [
758
					{
759
						sId: \'postMoreExpandLink\',
760
						msgExpanded: ' . JavaScriptEscape(!empty($context['attachments']) && $context['attachments']['can']['post'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt']) . ',
761
						msgCollapsed: ' . JavaScriptEscape(!empty($context['attachments']) && $context['attachments']['can']['post'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt']) . '
762
					}
763
				],
764
				oThemeOptions: {
765
					bUseThemeSettings: ' . ($context['user']['is_guest'] ? 'false' : 'true') . ',
766
					sOptionName: \'minmax_preferences\',
767
					sSessionId: elk_session_id,
768
					sSessionVar: elk_session_var,
769
					sAdditionalVars: \';minmax_key=post\'
770
				},
771
			});', true);
772
773
	template_topic_replies_below();
774
}
775
776
/**
777
 * The template for the spellchecker.
778
 */
779
function template_spellcheck()
780
{
781
	global $context, $settings, $txt;
782
783
	// The style information that makes the spellchecker look... like the forum hopefully!
784
	echo '<!DOCTYPE html>
785
<html ', $context['right_to_left'] ? 'dir="rtl"' : '', '>
786
	<head>
787
		<title>', $txt['spell_check'], '</title>
788
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
789
		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index.css', CACHE_STALE, '" />
790
		<link rel="stylesheet" href="', $settings['theme_url'], '/css/', $context['theme_variant_url'], 'index', $context['theme_variant'], '.css', CACHE_STALE, '" />
791
		<style>
792
			body, td {
793
				font-size: small;
794
				margin: 0;
795
				background: #f0f0f0;
796
				color: #000;
797
				padding: 10px 10px 0 10px;
798
			}
799
			.highlight {
800
				color: red;
801
				font-weight: bold;
802
			}
803
			#spellview {
804
				border: 1px inset black;
805
				padding: 5px;
806
				height: 300px;
807
				overflow: auto;
808
				background: #ffffff;
809
			}
810
			select {
811
				height: auto;
812
				max-height: none;
813
			}
814
		</style>';
815
816
	// As you may expect - we need a lot of javascript for this... load it from the separate files.
817
	echo '
818
		<script>
819
			var spell_formname = window.opener.spell_formname,
820
				spell_fieldname = window.opener.spell_fieldname,
821
				spell_full = window.opener.spell_full;
822
		</script>
823
		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js"></script>
824
		<script src="', $settings['default_theme_url'], '/scripts/script.js"></script>
825
		<script>
826
			', $context['spell_js'], '
827
		</script>
828
	</head>
829
	<body onload="nextWord(false);">
830
		<form action="#" method="post" accept-charset="UTF-8" name="spellingForm" id="spellingForm" onsubmit="return false;" style="margin: 0;">
831
			<div id="spellview">&nbsp;</div>
832
			<table class="table_grid">
833
				<tr>
834
					<td style="width: 50%;vertical-align: top;">
835
						<label for="changeto">', $txt['spellcheck_change_to'], '</label><br />
836
						<input type="text" id="changeto" name="changeto" style="width: 98%;" class="input_text" />
837
					</td>
838
					<td style="width: 50%;">
839
						', $txt['spellcheck_suggest'], '<br />
840
							<select name="suggestions" style="width: 98%;" size="5" onclick="if (this.selectedIndex != -1) this.form.changeto.value = this.options[this.selectedIndex].text;" ondblclick="replaceWord();">
841
							</select>
842
					</td>
843
				</tr>
844
			</table>
845
			<div class="submitbutton">
846
				<input type="button" name="change" value="', $txt['spellcheck_change'], '" onclick="replaceWord();" />
847
				<input type="button" name="changeall" value="', $txt['spellcheck_change_all'], '" onclick="replaceAll();" />
848
				<input type="button" name="ignore" value="', $txt['spellcheck_ignore'], '" onclick="nextWord(false);" />
849
				<input type="button" name="ignoreall" value="', $txt['spellcheck_ignore_all'], '" onclick="nextWord(true);" />
850
			</div>
851
		</form>
852
	</body>
853
</html>';
854
}
855