template_notes()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 40
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 16
dl 0
loc 40
rs 9.7333
c 0
b 0
f 0
nc 2
nop 0
1
<?php
2
3
/**
4
 * @package   ElkArte Forum
5
 * @copyright ElkArte Forum contributors
6
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
7
 *
8
 * This file contains code covered by:
9
 * copyright: 2011 Simple Machines (http://www.simplemachines.org)
10
 *
11
 * @version 2.0 dev
12
 *
13
 */
14
15
/**
16
 * Someone else did that for us, let's use it.
17
 */
18
function template_ModerationCenter_init()
19
{
20
	theme()->getTemplates()->load('GenericMessages');
21
}
22
23
/**
24
 * Template for the main page of moderation center.
25
 * It shows blocks with information.
26
 */
27
function template_moderation_center()
28
{
29
	global $context;
30
31
	// Show a welcome message to the user.
32
	echo '
33
					<div id="modcenter">
34
						<div id="mod_main_section" >';
35
36
	$alternate = true;
37
38
	// Show all the blocks they want to see.
39
	foreach ($context['mod_blocks'] as $block)
40
	{
41
		$block_function = 'template_' . $block;
42
43
		echo '
44
							<div class="modblock_', $alternate ? 'left' : 'right', '">', function_exists($block_function) ? $block_function() : '', '</div>';
45
46
		$alternate = !$alternate;
0 ignored issues
show
introduced by
The condition $alternate is always true.
Loading history...
47
	}
48
49
	echo '
50
						</div>
51
					</div>';
52
}
53
54
/**
55
 * Template to show latest news.
56
 */
57
function template_latest_news()
58
{
59
	global $txt, $scripturl;
60
61
	echo '
62
								<h2 class="category_header">
63
									<a class="hdicon i-help help" href="', $scripturl, '?action=quickhelp;help=live_news" onclick="return reqOverlayDiv(this.href);" title="', $txt['help'], '"></a> ', $txt['mc_latest_news'], '
64
								</h2>
65
								<div class="content">
66
									<div id="ourAnnouncements" class="smalltext">', $txt['mc_cannot_connect_sm'], '</div>
67
								</div>';
68
69
	// This requires a lot of javascript...
70
	echo '
71
								<span class="hide" id="installedVersion">??</span>
72
								<span class="hide" id="latestVersion">??</span>
73
								<script>
74
						var oAdminCenter = new Elk_AdminIndex({
75
							bLoadAnnouncements: true,
76
							sAnnouncementTemplate: ', JavaScriptEscape('
77
								<dl>
78
									%content%
79
								</dl>
80
							'), ',
81
							sAnnouncementMessageTemplate: ', JavaScriptEscape('
82
								<dt><a href="%href%">%subject%</a> ' . $txt['on'] . ' %time%</dt>
83
								<dd>
84
									%message%
85
								</dd>
86
							'), ',
87
							sAnnouncementContainerId: \'ourAnnouncements\',
88
89
							bLoadVersions: true,
90
							slatestVersionContainerId: \'latestVersion\',
91
							sinstalledVersionContainerId: \'installedVersion\',
92
							sVersionOutdatedTemplate: ', JavaScriptEscape('
93
								<span class="alert">%currentVersion%</span>
94
							'), '
95
						});
96
								</script>';
97
}
98
99
/**
100
 * Show all the group requests the user can see.
101
 */
102
function template_group_requests_block()
103
{
104
	global $context, $txt, $scripturl;
105
106
	echo '
107
								<h2 class="category_header hdicon i-user-plus">
108
									<a href="', $scripturl, '?action=groups;sa=requests">', $txt['mc_group_requests'], '</a>
109
								</h2>
110
								<div class="content modbox">
111
									<ul>';
112
113
	foreach ($context['group_requests'] as $request)
114
	{
115
		echo '
116
										<li class="smalltext">
117
											<a href="', $request['request_href'], '">', $request['group']['name'], '</a> ', $txt['mc_groupr_by'], ' ', $request['member']['link'], '
118
										</li>';
119
	}
120
121
	// Don't have any watched users right now?
122
	if (empty($context['group_requests']))
123
	{
124
		echo '
125
										<li>
126
											<strong class="smalltext">', $txt['mc_group_requests_none'], '</strong>
127
										</li>';
128
	}
129
130
	echo '
131
									</ul>
132
								</div>';
133
}
134
135
/**
136
 * A block to show the current top reported posts.
137
 */
138
function template_reported_posts_block()
139
{
140
	global $context, $txt, $scripturl;
141
142
	echo '
143
								<h2 class="category_header hdicon i-comments">
144
									<a href="', $scripturl, '?action=moderate;area=', $context['admin_area'], '">', $txt['mc_recent_reports'], '</a>
145
								</h2>
146
								<div class="content modbox">
147
									<ul>';
148
149
	foreach ($context['reported_posts'] as $report)
150
	{
151
		echo '
152
										<li class="smalltext">
153
											<a href="', $report['report_href'], '">', $report['subject'], '</a> ', $txt['mc_reportedp_by'], ' ', $report['author']['link'], '
154
										</li>';
155
	}
156
157
	// Don't have any watched users right now?
158
	if (empty($context['reported_posts']))
159
	{
160
		echo '
161
										<li>
162
											<strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong>
163
										</li>';
164
	}
165
166
	echo '
167
									</ul>
168
								</div>';
169
}
170
171
/**
172
 * Template for viewing users on the watch list
173
 */
174
function template_watched_users()
175
{
176
	global $context, $txt, $scripturl;
177
178
	echo '
179
						<h2 class="category_header hdicon i-view">
180
							<a href="', $scripturl, '?action=moderate;area=userwatch">', $txt['mc_watched_users'], '</a>
181
						</h2>
182
						<div class="content modbox">
183
							<ul>';
184
185
	foreach ($context['watched_users'] as $user)
186
	{
187
		echo '
188
								<li>
189
									<span class="smalltext">', sprintf(empty($user['last_login']) ? $txt['mc_seen_never'] : $txt['mc_seen'], $user['link'], $user['last_login']), '</span>
190
								</li>';
191
	}
192
193
	// Don't have any watched users right now?
194
	if (empty($context['watched_users']))
195
	{
196
		echo '
197
								<li>
198
									<strong class="smalltext">', $txt['mc_watched_users_none'], '</strong>
199
								</li>';
200
	}
201
202
	echo '
203
							</ul>
204
						</div>';
205
}
206
207
/**
208
 * Little section for making... notes.
209
 */
210
function template_notes()
211
{
212
	global $context, $txt, $scripturl;
213
214
	echo '
215
						<form action="', $scripturl, '?action=moderate;area=index" method="post">
216
							<h2 class="category_header hdicon i-pencil">', $txt['mc_notes'], '</h2>
217
							<div class="content modbox">
218
								<div class="submitbutton">
219
									<input type="text" name="new_note" placeholder="', $txt['mc_click_add_note'], '" style="width: 89%" class="floatleft input_text" />
220
									<input type="submit" name="makenote" value="', $txt['mc_add_note'], '" />
221
								</div>';
222
223
	if (!empty($context['notes']))
224
	{
225
		echo '
226
								<ul class="moderation_notes">';
227
228
		// Cycle through the notes.
229
		foreach ($context['notes'] as $note)
230
		{
231
			echo '
232
									<li class="smalltext">
233
										<a href="', $note['delete_href'], '">
234
											<i class="icon i-delete"></i>
235
										</a> 
236
										<strong>', $note['author']['link'], ':</strong> ', $note['text'], '
237
									</li>';
238
		}
239
240
		echo '
241
								</ul>
242
								<div class="pagesection notes">
243
									<ul class="pagelinks">', $context['page_index'], '</ul>
244
								</div>';
245
	}
246
247
	echo '
248
							</div>
249
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
250
						</form>';
251
}
252
253
/**
254
 * Template for viewing users on the watch list
255
 */
256
function template_action_required()
257
{
258
	global $context, $txt, $scripturl;
259
260
	echo '
261
						<h2 class="category_header hdicon i-warning">', $txt['mc_required'], ' : ', $context['mc_required'], '</h2>
262
						<div class="content modbox">
263
							<ul>';
264
265
	foreach ($context['required'] as $area => $total)
266
	{
267
		echo '
268
								<li>
269
									<i class="icon ', ($total == 0) ? 'i-check' : 'i-warning ', '"></i>
270
									<a href="', $scripturl, $context['links'][$area], '">
271
										<span class="smalltext">', $txt['mc_' . $area], ' : ', $total, '</span>
272
									</a>
273
								</li>';
274
	}
275
276
	echo '
277
							</ul>
278
						</div>';
279
}
280
281
/**
282
 * Template for viewing posts that have been reported
283
 */
284
function template_reported_posts()
285
{
286
	global $context, $txt, $scripturl, $options;
287
288
	echo '
289
					<form id="reported_posts" action="', $scripturl, '?action=moderate;area=', $context['admin_area'], $context['view_closed'] ? ';sa=closed' : '', ';start=', $context['start'], '" method="post" accept-charset="UTF-8">
290
						<h2 class="category_header">
291
							', $context['view_closed'] ? $txt['mc_reportedp_closed'] : $txt['mc_reportedp_active'], '
292
						</h2>';
293
294
	if (!empty($context['reports']))
295
	{
296
		template_pagesection();
297
	}
298
299
	foreach ($context['reports'] as $report)
300
	{
301
		$report['class'] = 'content';
302
		$report['title'] = '<strong>' . (empty($report['board_name']) ? '' : '<a href="' . $scripturl . '?board=' . $report['board'] . '.0">' . $report['board_name'] . '</a> / ') . '<a href="' . $report['topic_href'] . '">' . $report['subject'] . '</a></strong> ' . $txt['mc_reportedp_by'] . ' <strong>' . $report['author']['link'] . '</strong>';
303
304
		// Prepare the comments...
305
		$comments = array();
306
		foreach ($report['comments'] as $comment)
307
		{
308
			$comments[$comment['member']['id']] = $comment['member']['link'];
309
		}
310
311
		$report['date'] = $txt['mc_reportedp_last_reported'] . ': ' . $report['last_updated'] . '&nbsp;-&nbsp;' . '
312
										' . $txt['mc_reportedp_reported_by'] . ': ' . implode(', ', $comments);
313
314
		template_simple_message($report);
315
	}
316
317
	// Were none found?
318
	if (empty($context['reports']))
319
	{
320
		echo '
321
						<p class="infobox">', $txt['mc_reportedp_none_found'], '</p>';
322
	}
323
	else
324
	{
325
		template_pagesection(false, '', array('extra' => !$context['view_closed'] && !empty($options['display_quick_mod']) ? '<input type="submit" name="close_selected" value="' . $txt['mc_reportedp_close_selected'] . '" class="right_submit" />' : ''));
326
	}
327
328
	echo '
329
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
330
					</form>';
331
}
332
333
/**
334
 * Show a list of all the unapproved posts or topics
335
 * Provides links to approve to remove each
336
 */
337
function template_unapproved_posts()
338
{
339
	global $options, $context, $txt, $scripturl;
340
341
	// Just a big div of it all really...
342
	echo '
343
				<form action="', $scripturl, '?action=moderate;area=postmod;start=', $context['start'], ';sa=', $context['current_view'], '" method="post" accept-charset="UTF-8">
344
					<h2 class="category_header hdicon i-post-text">
345
						', $context['header_title'], '
346
					</h2>';
347
348
	// No posts?
349
	if (empty($context['unapproved_items']))
350
	{
351
		echo '
352
					<div class="content">
353
						<p class="centertext">', $txt['mc_unapproved_' . $context['current_view'] . '_none_found'], '</p>
354
					</div>';
355
	}
356
	else
357
	{
358
		template_pagesection();
359
	}
360
361
	// Loop through and show each unapproved post
362
	foreach ($context['unapproved_items'] as $item)
363
	{
364
		$item['class'] = 'content';
365
		$item['title'] = '<h5><strong>' . $item['category']['link'] . ' / ' . $item['board']['link'] . ' / ' . $item['link'] . '</strong></h5>';
366
		$item['date'] = $txt['mc_unapproved_by'] . ' <strong>' . $item['poster']['link'] . '</strong> : ' . $item['time'];
367
368
		template_simple_message($item);
369
	}
370
371
	// Quick moderation checkbox action selection
372
	$quick_mod = '';
373
	if (!empty($options['display_quick_mod']) && !empty($context['unapproved_items']))
374
	{
375
		$quick_mod = '
376
					<div class="floatright">
377
						<select name="do" onchange="if (this.value != 0 &amp;&amp; confirm(\'' . $txt['mc_unapproved_sure'] . '\')) submit();">
378
							<option value="0">' . $txt['with_selected'] . ':</option>
379
							<option value="0" disabled="disabled">' . str_repeat('&#8212;', strlen($txt['approve'])) . '</option>
380
							<option value="approve">&#10148;&nbsp;' . $txt['approve'] . '</option>
381
							<option value="delete">&#10148;&nbsp;' . $txt['remove'] . '</option>
382
						</select>
383
						<noscript>
384
							<input type="submit" name="mc_go" value="' . $txt['go'] . '" />
385
						</noscript>
386
					</div>';
387
	}
388
389
	if (!empty($context['unapproved_items']))
390
	{
391
		template_pagesection(false, '', array('extra' => $quick_mod));
392
	}
393
394
	echo '
395
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
396
				</form>';
397
}
398
399
/**
400
 * View the details of a moderation report
401
 */
402
function template_viewmodreport()
403
{
404
	global $context, $scripturl, $txt;
405
406
	echo '
407
					<div id="modcenter">
408
						<form action="', $scripturl, '?action=moderate;area=', $context['admin_area'], ';report=', $context['report']['id'], '" method="post" accept-charset="UTF-8">
409
							<h2 class="category_header">
410
								', $context['section_title'], '
411
							</h2>
412
							<div class="content">
413
								<p class="warningbox">', $context['section_descripion'], '</p>
414
								<div class="content">
415
									', $context['report']['body'], '
416
								</div>';
417
418
	template_button_strip($context['mod_buttons'], 'quickbuttons no_js', ['no-class' => true]);
419
420
	echo '
421
							</div>
422
							<h2 class="category_header">', $txt['mc_modreport_whoreported_title'], '</h2>';
423
424
	foreach ($context['report']['comments'] as $comment)
425
	{
426
		echo '
427
							<div class="content">
428
								<p class="smalltext">', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), '</p>
429
								<p>', $comment['message'], '</p>
430
							</div>';
431
	}
432
433
	echo '
434
							<h2 class="category_header">', $txt['mc_modreport_mod_comments'], '</h2>
435
							<div class="content">';
436
437
	if (empty($context['report']['mod_comments']))
438
	{
439
		echo '
440
								<p class="successbox">', $txt['mc_modreport_no_mod_comment'], '</p>';
441
	}
442
443
	foreach ($context['report']['mod_comments'] as $comment)
444
	{
445
		echo
446
		'<p>', $comment['member']['link'], ': ', $comment['message'], ' <em class="smalltext">(', $comment['time'], ')</em></p>';
447
	}
448
449
	echo '
450
								<textarea rows="2" cols="60" style="width: 100%;" name="mod_comment"></textarea>
451
								<div class="submitbutton">
452
									<input type="submit" name="add_comment" value="', $txt['mc_modreport_add_mod_comment'], '" />
453
								</div>
454
							</div>';
455
456
	template_show_list('moderation_actions_list');
457
458
	echo '
459
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
460
						</form>
461
					</div>';
462
}
463
464
/**
465
 * Callback function for showing a watched users post in the table.
466
 *
467
 * @param mixed[] $post
468
 */
469
function template_user_watch_post_callback($post)
470
{
471
	global $scripturl, $context, $txt;
472
473
	$output_html = '
474
					<div class="content">
475
						<div class="counter">' . $post['counter'] . '</div>
476
						<div class="topic_details">
477
							<h5>
478
								<a href="' . $scripturl . '?topic=' . $post['id_topic'] . '.' . $post['id'] . '#msg' . $post['id'] . '">' .
479
									$post['subject'] . '
480
								</a> ' .
481
								$txt['mc_reportedp_by'] . ' <strong>' . $post['author_link'] . '</strong>
482
							</h5>
483
							<span class="smalltext">' . '&#171; ' . $txt['mc_watched_users_posted'] . ': ' . $post['poster_time'] . ' &#187;</span>
484
						</div>
485
						<div class="messageContent">' . $post['body'] . '</div>';
486
487
	if ($post['can_delete'])
488
	{
489
		$output_html .= '
490
						<ul class="quickbuttons">
491
							<li class="listlevel1">
492
								<a class="linklevel1 remove_button" href="' . $scripturl . '?action=moderate;area=userwatch;sa=post;delete=' . $post['id'] . ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(\'' . $txt['mc_watched_users_delete_post'] . '\');">' . $txt['remove'] . '</a>
493
							</li>
494
							<li class="listlevel1 inline_mod_check">
495
								<input type="checkbox" name="delete[]" value="' . $post['id'] . '" />
496
							</li>
497
						</ul>';
498
	}
499
500
	return $output_html . '
501
					</div>';
502
}
503
504
/**
505
 * Moderation settings.
506
 */
507
function template_moderation_settings()
508
{
509
	global $context, $txt, $scripturl;
510
511
	echo '
512
	<div id="modcenter">
513
		<form action="', $scripturl, '?action=moderate;area=settings" method="post" accept-charset="UTF-8">
514
			<div class="content">
515
				<dl class="settings">
516
					<dt>
517
						<label>', $txt['mc_prefs_homepage'], ':</label>
518
					</dt>
519
					<dd>';
520
521
	foreach ($context['homepage_blocks'] as $k => $v)
522
	{
523
		echo '
524
						<label for="mod_homepage_', $k, '"><input type="checkbox" id="mod_homepage_', $k, '" name="mod_homepage[', $k, ']"', in_array($k, $context['mod_settings']['user_blocks']) ? ' checked="checked"' : '', ' /> ', $v, '</label><br />';
525
	}
526
527
	echo '
528
					</dd>';
529
530
	// If they can moderate boards they have more options!
531
	if ($context['can_moderate_boards'])
532
	{
533
		echo '
534
					<dt>
535
						<label for="mod_show_reports">', $txt['mc_prefs_show_reports'], ':</label>
536
					</dt>
537
					<dd>
538
						<input type="checkbox" id="mod_show_reports" name="mod_show_reports" ', $context['mod_settings']['show_reports'] ? 'checked="checked"' : '', ' />
539
					</dd>
540
					<dt>
541
						<label for="mod_notify_report">', $txt['mc_prefs_notify_report'], ':</label>
542
					</dt>
543
					<dd>
544
						<select id="mod_notify_report" name="mod_notify_report">
545
							<option value="0" ', $context['mod_settings']['notify_report'] == 0 ? 'selected="selected"' : '', '>', $txt['mc_prefs_notify_report_never'], '</option>
546
							<option value="1" ', $context['mod_settings']['notify_report'] == 1 ? 'selected="selected"' : '', '>', $txt['mc_prefs_notify_report_moderator'], '</option>
547
							<option value="2" ', $context['mod_settings']['notify_report'] == 2 ? 'selected="selected"' : '', '>', $txt['mc_prefs_notify_report_always'], '</option>
548
						</select>
549
					</dd>';
550
	}
551
552
	if ($context['can_moderate_approvals'])
553
	{
554
		echo '
555
					<dt>
556
						<label for="mod_notify_approval">', $txt['mc_prefs_notify_approval'], ':</label>
557
					</dt>
558
					<dd>
559
						<input type="checkbox" id="mod_notify_approval" name="mod_notify_approval" ', $context['mod_settings']['notify_approval'] ? 'checked="checked"' : '', ' />
560
					</dd>';
561
	}
562
563
	echo '
564
				</dl>
565
				<div class="submitbutton">
566
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
567
					<input type="hidden" name="', $context['mod-set_token_var'], '" value="', $context['mod-set_token'], '" />
568
					<input type="submit" name="save" value="', $txt['save'], '" />
569
				</div>
570
			</div>
571
		</form>
572
	</div>';
573
}
574
575
/**
576
 * Show a notice sent to a user in a new window
577
 */
578
function template_show_notice()
579
{
580
	global $txt, $settings, $context;
581
582
	// We do all the HTML for this one!
583
	echo '<!DOCTYPE html>
584
<html ', $context['right_to_left'] ? 'dir="rtl"' : '', '>
585
	<head>
586
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
587
		<title>', $context['page_title'], '</title>
588
		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index.css', CACHE_STALE, '" />
589
		<link rel="stylesheet" href="', $settings['theme_url'], '/css/', $context['theme_variant_url'], 'index', $context['theme_variant'], '.css', CACHE_STALE, '" />
590
	</head>
591
	<body>
592
		<h2 class="category_header">', $txt['show_notice'], '</h2>
593
		<h2 class="category_header">', $txt['show_notice_subject'], ': ', $context['notice_subject'], '</h2>
594
		<div class="well">
595
			<div class="content">
596
				<dl>
597
					<dt>
598
						<strong>', $txt['show_notice_text'], ':</strong>
599
					</dt>
600
					<dd>
601
						', $context['notice_body'], '
602
					</dd>
603
				</dl>
604
			</div>
605
		</div>
606
	</body>
607
</html>';
608
}
609
610
/**
611
 * Add or edit a warning template.
612
 */
613
function template_warn_template()
614
{
615
	global $context, $txt, $scripturl;
616
617
	echo '
618
	<form action="', $scripturl, '?action=moderate;area=warnings;sa=templateedit;tid=', $context['id_template'], '" method="post" accept-charset="UTF-8">
619
		<h2 class="category_header">', $context['page_title'], '</h2>
620
		<div class="information">
621
			', $txt['mc_warning_template_desc'], '
622
		</div>
623
		<div id="modcenter">
624
			<div class="content">
625
				<div class="errorbox', empty($context['warning_errors']) ? ' hide"' : '"', ' id="errors">
626
					<dl>
627
						<dt>
628
							<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
629
						</dt>
630
						<dd class="error" id="error_list">
631
							', empty($context['warning_errors']) ? '' : implode('<br />', $context['warning_errors']), '
632
						</dd>
633
					</dl>
634
				</div>
635
				<div id="box_preview"', empty($context['template_preview']) ? ' class="hide"' : '', '>
636
					<dl class="settings">
637
						<dt>
638
							<strong>', $txt['preview'], '</strong>
639
						</dt>
640
						<dd id="template_preview">
641
							', empty($context['template_preview']) ? '' : $context['template_preview'], '
642
						</dd>
643
					</dl>
644
				</div>
645
				<dl class="settings">
646
					<dt>
647
						<label for="template_title">', $txt['mc_warning_template_title'], ':</label>
648
					</dt>
649
					<dd>
650
						<input type="text" id="template_title" name="template_title" value="', $context['template_data']['title'], '" size="30" class="input_text" />
651
					</dd>
652
					<dt>
653
						<label for="template_body">', $txt['profile_warning_notify_body'], ':</label><br />
654
						<span class="smalltext">', $txt['mc_warning_template_body_desc'], '</span>
655
					</dt>
656
					<dd>
657
						<textarea id="template_body" name="template_body" rows="10" cols="45" class="smalltext">', $context['template_data']['body'], '</textarea>
658
					</dd>
659
				</dl>';
660
661
	if ($context['template_data']['can_edit_personal'])
662
	{
663
		echo '
664
				<input type="checkbox" name="make_personal" id="make_personal" ', $context['template_data']['personal'] ? 'checked="checked"' : '', ' />
665
				<label for="make_personal">
666
					<strong>', $txt['mc_warning_template_personal'], '</strong>
667
				</label>
668
				<br />
669
				<span class="smalltext">', $txt['mc_warning_template_personal_desc'], '</span>
670
				<br />';
671
	}
672
673
	echo '
674
				<hr />
675
				<div class="submitbutton">
676
					<input type="submit" name="preview" id="preview_button" value="', $txt['preview'], '" />
677
					<input type="submit" name="save" value="', $context['page_title'], '" />
678
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
679
					<input type="hidden" name="', $context['mod-wt_token_var'], '" value="', $context['mod-wt_token'], '" />
680
				</div>
681
			</div>
682
		</div>
683
	</form>
684
685
	<script>
686
		document.addEventListener("DOMContentLoaded", function () {
687
		    let button = document.getElementById("preview_button");
688
		    if (button) 
689
			{
690
		        button.addEventListener("click", function() {
691
		            return ajax_getTemplatePreview();
692
		        });
693
		    }
694
		});
695
	</script>';
696
}
697