Issues (1014)

Themes/default/Admin.template.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines https://www.simplemachines.org
7
 * @copyright 2022 Simple Machines and individual contributors
8
 * @license https://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1.0
11
 */
12
13
/**
14
 * This is the administration center home.
15
 */
16
function template_admin()
17
{
18
	global $context, $scripturl, $txt, $modSettings;
19
20
	// Is there an update available?
21
	echo '
22
						<div id="update_section"></div>';
23
24
	echo '
25
						<div id="admin_main_section">';
26
27
	// Display the "live news" from simplemachines.org.
28
	echo '
29
							<div id="live_news" class="floatleft">
30
								<div class="cat_bar">
31
									<h3 class="catbg">
32
										<a href="', $scripturl, '?action=helpadmin;help=live_news" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a> ', $txt['live'], '
33
									</h3>
34
								</div>
35
								<div class="windowbg nopadding">
36
									<div id="smfAnnouncements">', $txt['smf_news_cant_connect'], '</div>
37
								</div>
38
							</div>';
39
40
	// Show the user version information from their server.
41
	echo '
42
							<div id="support_info" class="floatright">
43
								<div class="cat_bar">
44
									<h3 class="catbg">
45
										<a href="', $scripturl, '?action=admin;area=credits">', $txt['support_title'], '</a>
46
									</h3>
47
								</div>
48
								<div class="windowbg nopadding">
49
									<div id="version_details" class="padding">
50
										<strong>', $txt['support_versions'], ':</strong><br>
51
										', $txt['support_versions_forum'], ':
52
										<em id="yourVersion">', $context['forum_version'], '</em><br>
53
										', $txt['support_versions_current'], ':
54
										<em id="smfVersion">??</em><br>
55
										', $context['can_admin'] ? '<a href="' . $scripturl . '?action=admin;area=maintain;sa=routine;activity=version">' . $txt['version_check_more'] . '</a>' : '', '<br>';
56
57
	// Display all the members who can administrate the forum.
58
	echo '
59
										<br>
60
										<strong>', $txt['administrators'], ':</strong>
61
										', implode(', ', $context['administrators']);
62
63
	// If we have lots of admins... don't show them all.
64
	if (!empty($context['more_admins_link']))
65
		echo '
66
										(', $context['more_admins_link'], ')';
67
68
	echo '
69
									</div><!-- #version_details -->
70
								</div><!-- .windowbg -->
71
							</div><!-- #support_info -->
72
						</div><!-- #admin_main_section -->';
73
74
	foreach ($context[$context['admin_menu_name']]['sections'] as $area_id => $area)
75
	{
76
		echo '
77
						<fieldset id="group_', $area_id, '" class="windowbg admin_group">
78
							<legend>', $area['title'], '</legend>';
79
80
		foreach ($area['areas'] as $item_id => $item)
81
		{
82
			// No point showing the 'home' page here, we're already on it!
83
			if ($area_id == 'forum' && $item_id == 'index')
84
				continue;
85
86
			$url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : '');
87
88
			if (!empty($item['icon_file']))
89
				echo '
90
							<a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>';
91
			else
92
				echo '
93
							<a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>';
94
		}
95
96
		echo '
97
						</fieldset>';
98
	}
99
100
	// The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization.
101
	if (empty($modSettings['disable_smf_js']))
102
		echo '
103
					<script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script>
104
					<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
105
106
	// This sets the announcements and current versions themselves ;).
107
	echo '
108
					<script>
109
						var oAdminIndex = new smf_AdminIndex({
110
							sSelf: \'oAdminCenter\',
111
112
							bLoadAnnouncements: true,
113
							sAnnouncementTemplate: ', JavaScriptEscape('
114
								<dl>
115
									%content%
116
								</dl>
117
							'), ',
118
							sAnnouncementMessageTemplate: ', JavaScriptEscape('
119
								<dt><a href="%href%">%subject%</a> ' . $txt['on'] . ' %time%</dt>
120
								<dd>
121
									%message%
122
								</dd>
123
							'), ',
124
							sAnnouncementContainerId: \'smfAnnouncements\',
125
126
							bLoadVersions: true,
127
							sSmfVersionContainerId: \'smfVersion\',
128
							sYourVersionContainerId: \'yourVersion\',
129
							sVersionOutdatedTemplate: ', JavaScriptEscape('
130
								<span class="alert">%currentVersion%</span>
131
							'), ',
132
133
							bLoadUpdateNotification: true,
134
							sUpdateNotificationContainerId: \'update_section\',
135
							sUpdateNotificationDefaultTitle: ', JavaScriptEscape($txt['update_available']), ',
136
							sUpdateNotificationDefaultMessage: ', JavaScriptEscape($txt['update_message']), ',
137
							sUpdateNotificationTemplate: ', JavaScriptEscape('
138
								<h3 id="update_title">
139
									%title%
140
								</h3>
141
								<div id="update_message" class="smalltext">
142
									%message%
143
								</div>
144
							'), ',
145
							sUpdateNotificationLink: smf_scripturl + ', JavaScriptEscape('?action=admin;area=packages;pgdownload;auto;package=%package%;' . $context['session_var'] . '=' . $context['session_id']), '
146
						});
147
					</script>';
148
}
149
150
/**
151
 * Show some support information and credits to those who helped make this.
152
 */
153
function template_credits()
154
{
155
	global $context, $settings, $scripturl, $txt;
156
157
	// Show the user version information from their server.
158
	echo '
159
					<div class="roundframe noup">
160
						<div class="title_bar">
161
							<h3 class="titlebg">
162
								', $txt['support_title'], '
163
							</h3>
164
						</div>
165
						<div class="padding">
166
							<img src="', $settings['images_url'], '/smflogo.svg" class="floatright" alt="">
167
							<strong>', $txt['support_versions'], ':</strong><br>
168
								', $txt['support_versions_forum'], ':
169
							<em id="yourVersion">', $context['forum_version'], '</em>', $context['can_admin'] ? ' <a href="' . $scripturl . '?action=admin;area=maintain;sa=routine;activity=version">' . $txt['version_check_more'] . '</a>' : '', '<br>
170
								', $txt['support_versions_current'], ':
171
							<em id="smfVersion">??</em><br>';
172
173
	// Display all the variables we have server information for.
174
	foreach ($context['current_versions'] as $version)
175
	{
176
		echo '
177
								', $version['title'], ':
178
							<em>', $version['version'], '</em>';
179
180
		// more details for this item, show them a link
181
		if ($context['can_admin'] && isset($version['more']))
182
			echo
183
							' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>';
184
		echo '
185
							<br>';
186
	}
187
188
	echo '
189
						</div><!-- .padding -->';
190
191
	// Point the admin to common support resources.
192
	echo '
193
						<div id="support_resources" class="title_bar">
194
							<h3 class="titlebg">
195
								', $txt['support_resources'], '
196
							</h3>
197
						</div>
198
						<div class="padding">
199
							<p>', $txt['support_resources_p1'], '</p>
200
							<p>', $txt['support_resources_p2'], '</p>
201
						</div>';
202
203
	// The most important part - the credits :P.
204
	echo '
205
						<div id="credits_sections" class="title_bar">
206
							<h3 class="titlebg">
207
								', $txt['admin_credits'], '
208
							</h3>
209
						</div>
210
						<div id="support_credits_list" class="padding">';
211
212
	foreach ($context['credits'] as $section)
213
	{
214
		if (isset($section['pretext']))
215
			echo '
216
							<p>', $section['pretext'], '</p>
217
							<hr>';
218
219
		echo '
220
							<dl>';
221
222
		foreach ($section['groups'] as $group)
223
		{
224
			if (isset($group['title']))
225
				echo '
226
								<dt>
227
									<strong>', $group['title'], ':</strong>
228
								</dt>';
229
230
			echo '
231
								<dd>', implode(', ', $group['members']), '</dd>';
232
		}
233
234
		echo '
235
							</dl>';
236
237
		if (isset($section['posttext']))
238
			echo '
239
							<hr>
240
							<p>', $section['posttext'], '</p>';
241
	}
242
243
	echo '
244
						</div><!-- .padding -->
245
					</div><!-- #support_credits -->';
246
247
	// This makes all the support information available to the support script...
248
	echo '
249
					<script>
250
						var smfSupportVersions = {};
251
252
						smfSupportVersions.forum = "', $context['forum_version'], '";';
253
254
	// Don't worry, none of this is logged, it's just used to give information that might be of use.
255
	foreach ($context['current_versions'] as $variable => $version)
256
		echo '
257
						smfSupportVersions.', $variable, ' = "', $version['version'], '";';
258
259
	// Now we just have to include the script and wait ;).
260
	echo '
261
					</script>
262
					<script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script>
263
					<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
264
265
	// This sets the latest support stuff.
266
	echo '
267
					<script>
268
						function smfCurrentVersion()
269
						{
270
							var smfVer, yourVer;
271
272
							if (!window.smfVersion)
273
								return;
274
275
							smfVer = document.getElementById("smfVersion");
276
							yourVer = document.getElementById("yourVersion");
277
278
							setInnerHTML(smfVer, window.smfVersion);
279
280
							var currentVersion = getInnerHTML(yourVer);
281
							if (currentVersion != window.smfVersion)
282
								setInnerHTML(yourVer, "<span class=\"alert\">" + currentVersion + "</span>");
283
						}
284
						addLoadEvent(smfCurrentVersion)
285
					</script>';
286
}
287
288
/**
289
 * Displays information about file versions installed, and compares them to current version.
290
 */
291
function template_view_versions()
292
{
293
	global $context, $scripturl, $txt;
294
295
	echo '
296
						<div id="section_header" class="cat_bar">
297
							<h3 class="catbg">
298
								', $txt['admin_version_check'], '
299
							</h3>
300
						</div>
301
						<div class="information">', $txt['version_check_desc'], '</div>
302
						<div id="versions">
303
							<table class="table_grid">
304
								<thead>
305
									<tr class="title_bar">
306
										<th class="half_table">
307
											<strong>', $txt['admin_smffile'], '</strong>
308
										</th>
309
										<th class="quarter_table">
310
											<strong>', $txt['dvc_your'], '</strong>
311
										</th>
312
										<th class="quarter_table">
313
											<strong>', $txt['dvc_current'], '</strong>
314
										</th>
315
									</tr>
316
								</thead>
317
								<tbody>';
318
319
	// The current version of the core SMF package.
320
	echo '
321
									<tr class="windowbg">
322
										<td class="half_table">
323
											', $txt['admin_smfpackage'], '
324
										</td>
325
										<td class="quarter_table">
326
											<em id="yourSMF">', $context['forum_version'], '</em>
327
										</td>
328
										<td class="quarter_table">
329
											<em id="currentSMF">??</em>
330
										</td>
331
									</tr>';
332
333
	// Now list all the source file versions, starting with the overall version (if all match!).
334
	echo '
335
									<tr class="windowbg">
336
										<td class="half_table">
337
											<a href="#" id="Sources-link">', $txt['dvc_sources'], '</a>
338
										</td>
339
										<td class="quarter_table">
340
											<em id="yourSources">??</em>
341
										</td>
342
										<td class="quarter_table">
343
											<em id="currentSources">??</em>
344
										</td>
345
									</tr>
346
								</tbody>
347
							</table>
348
349
							<table id="Sources" class="table_grid">
350
								<tbody>';
351
352
	// Loop through every source file displaying its version - using javascript.
353
	foreach ($context['file_versions'] as $filename => $version)
354
		echo '
355
									<tr class="windowbg">
356
										<td class="half_table">
357
											', $filename, '
358
										</td>
359
										<td class="quarter_table">
360
											<em id="yourSources', $filename, '">', $version, '</em>
361
										</td>
362
										<td class="quarter_table">
363
											<em id="currentSources', $filename, '">??</em>
364
										</td>
365
									</tr>';
366
367
	// Default template files.
368
	echo '
369
								</tbody>
370
							</table>
371
372
							<table class="table_grid">
373
								<tbody>
374
									<tr class="windowbg">
375
										<td class="half_table">
376
											<a href="#" id="Default-link">', $txt['dvc_default'], '</a>
377
										</td>
378
										<td class="quarter_table">
379
											<em id="yourDefault">??</em>
380
										</td>
381
										<td class="quarter_table">
382
											<em id="currentDefault">??</em>
383
										</td>
384
									</tr>
385
								</tbody>
386
							</table>
387
388
							<table id="Default" class="table_grid">
389
								<tbody>';
390
391
	foreach ($context['default_template_versions'] as $filename => $version)
392
		echo '
393
									<tr class="windowbg">
394
										<td class="half_table">
395
											', $filename, '
396
										</td>
397
										<td class="quarter_table">
398
											<em id="yourDefault', $filename, '">', $version, '</em>
399
										</td>
400
										<td class="quarter_table">
401
											<em id="currentDefault', $filename, '">??</em>
402
										</td>
403
									</tr>';
404
405
	// Now the language files...
406
	echo '
407
								</tbody>
408
							</table>
409
410
							<table class="table_grid">
411
								<tbody>
412
									<tr class="windowbg">
413
										<td class="half_table">
414
											<a href="#" id="Languages-link">', $txt['dvc_languages'], '</a>
415
										</td>
416
										<td class="quarter_table">
417
											<em id="yourLanguages">??</em>
418
										</td>
419
										<td class="quarter_table">
420
											<em id="currentLanguages">??</em>
421
										</td>
422
									</tr>
423
								</tbody>
424
							</table>
425
426
							<table id="Languages" class="table_grid">
427
								<tbody>';
428
429
	foreach ($context['default_language_versions'] as $language => $files)
430
	{
431
		foreach ($files as $filename => $version)
432
			echo '
433
									<tr class="windowbg">
434
										<td class="half_table">
435
											', $filename, '.<em>', $language, '</em>.php
436
										</td>
437
										<td class="quarter_table">
438
											<em id="your', $filename, '.', $language, '">', $version, '</em>
439
										</td>
440
										<td class="quarter_table">
441
											<em id="current', $filename, '.', $language, '">??</em>
442
										</td>
443
									</tr>';
444
	}
445
446
	echo '
447
								</tbody>
448
							</table>';
449
450
	// Display the version information for the currently selected theme - if it is not the default one.
451
	if (!empty($context['template_versions']))
452
	{
453
		echo '
454
							<table class="table_grid">
455
								<tbody>
456
									<tr class="windowbg">
457
										<td class="half_table">
458
											<a href="#" id="Templates-link">', $txt['dvc_templates'], '</a>
459
										</td>
460
										<td class="quarter_table">
461
											<em id="yourTemplates">??</em>
462
										</td>
463
										<td class="quarter_table">
464
											<em id="currentTemplates">??</em>
465
										</td>
466
									</tr>
467
								</tbody>
468
							</table>
469
470
							<table id="Templates" class="table_grid">
471
								<tbody>';
472
473
		foreach ($context['template_versions'] as $filename => $version)
474
			echo '
475
									<tr class="windowbg">
476
										<td class="half_table">
477
											', $filename, '
478
										</td>
479
										<td class="quarter_table">
480
											<em id="yourTemplates', $filename, '">', $version, '</em>
481
										</td>
482
										<td class="quarter_table">
483
											<em id="currentTemplates', $filename, '">??</em>
484
										</td>
485
									</tr>';
486
487
		echo '
488
								</tbody>
489
							</table>';
490
	}
491
492
	// Display the tasks files version.
493
	if (!empty($context['tasks_versions']))
494
	{
495
		echo '
496
							<table class="table_grid">
497
								<tbody>
498
									<tr class="windowbg">
499
										<td class="half_table">
500
											<a href="#" id="Tasks-link">', $txt['dvc_tasks'], '</a>
501
										</td>
502
										<td class="quarter_table">
503
											<em id="yourTasks">??</em>
504
										</td>
505
										<td class="quarter_table">
506
											<em id="currentTasks">??</em>
507
										</td>
508
									</tr>
509
								</tbody>
510
							</table>
511
512
							<table id="Tasks" class="table_grid">
513
								<tbody>';
514
515
		foreach ($context['tasks_versions'] as $filename => $version)
516
			echo '
517
									<tr class="windowbg">
518
										<td class="half_table">
519
											', $filename, '
520
										</td>
521
										<td class="quarter_table">
522
											<em id="yourTasks', $filename, '">', $version, '</em>
523
										</td>
524
										<td class="quarter_table">
525
											<em id="currentTasks', $filename, '">??</em>
526
										</td>
527
									</tr>';
528
529
		echo '
530
								</tbody>
531
							</table>';
532
	}
533
534
	echo '
535
						</div><!-- #versions -->';
536
537
	/* Below is the hefty javascript for this. Upon opening the page it checks the current file versions with ones
538
	   held at simplemachines.org and works out if they are up to date. If they aren't it colors that files number
539
	   red. It also contains the function, swapOption, that toggles showing the detailed information for each of the
540
	   file categories. (sources, languages, and templates.) */
541
	echo '
542
					<script src="', $scripturl, '?action=viewsmfile;filename=detailed-version.js"></script>
543
					<script>
544
						var oViewVersions = new smf_ViewVersions({
545
							aKnownLanguages: [
546
								\'.', implode('\',
547
								\'.', $context['default_known_languages']), '\'
548
							],
549
							oSectionContainerIds: {
550
								Sources: \'Sources\',
551
								Default: \'Default\',
552
								Languages: \'Languages\',
553
								Templates: \'Templates\',
554
								Tasks: \'Tasks\'
555
							}
556
						});
557
					</script>';
558
559
}
560
561
/**
562
 * Form for stopping people using naughty words, etc.
563
 */
564
function template_edit_censored()
565
{
566
	global $context, $scripturl, $txt, $modSettings;
567
568
	if (!empty($context['saved_successful']))
569
		echo '
570
					<div class="infobox">', $txt['settings_saved'], '</div>';
571
572
	// First section is for adding/removing words from the censored list.
573
	echo '
574
						<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=postsettings;sa=censor" method="post" accept-charset="', $context['character_set'], '">
575
							<div id="section_header" class="cat_bar">
576
								<h3 class="catbg">
577
									', $txt['admin_censored_words'], '
578
								</h3>
579
							</div>
580
							<div class="windowbg">
581
								<p>', $txt['admin_censored_where'], '</p>';
582
583
	// Show text boxes for censoring [bad   ] => [good  ].
584
	foreach ($context['censored_words'] as $vulgar => $proper)
585
		echo '
586
								<div class="block">
587
									<input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> =&gt; <input type="text" name="censor_proper[]" value="', $proper, '" size="30">
588
								</div>';
589
590
	// Now provide a way to censor more words.
591
	echo '
592
								<div class="block">
593
									<input type="text" name="censor_vulgar[]" size="30"> =&gt; <input type="text" name="censor_proper[]" size="30">
594
								</div>
595
								<div id="moreCensoredWords"></div>
596
								<div class="block hidden" id="moreCensoredWords_link">
597
									<a class="button" href="#" onclick="addNewWord(); return false;">', $txt['censor_clickadd'], '</a><br>
598
								</div>
599
								<script>
600
									document.getElementById("moreCensoredWords_link").classList.remove(\'hidden\');
601
								</script>
602
								<hr>
603
								<dl class="settings">
604
									<dt>
605
										<strong><label for="allow_no_censored">', $txt['allow_no_censored'], ':</label></strong>
606
									</dt>
607
									<dd>
608
										<input type="checkbox" name="allow_no_censored" value="1" id="allow_no_censored"', empty($modSettings['allow_no_censored']) ? '' : ' checked', '>
609
									</dd>
610
									<dt>
611
										<strong><label for="censorWholeWord_check">', $txt['censor_whole_words'], ':</label></strong>
612
									</dt>
613
									<dd>
614
										<input type="checkbox" name="censorWholeWord" value="1" id="censorWholeWord_check"', empty($modSettings['censorWholeWord']) ? '' : ' checked', '>
615
									</dd>
616
									<dt>
617
										<strong><label for="censorIgnoreCase_check">', $txt['censor_case'], ':</label></strong>
618
									</dt>
619
									<dd>
620
										<input type="checkbox" name="censorIgnoreCase" value="1" id="censorIgnoreCase_check"', empty($modSettings['censorIgnoreCase']) ? '' : ' checked', '>
621
									</dd>
622
								</dl>
623
								<input type="submit" name="save_censor" value="', $txt['save'], '" class="button">
624
							</div><!-- .windowbg -->';
625
626
	// This table lets you test out your filters by typing in rude words and seeing what comes out.
627
	echo '
628
							<div class="cat_bar">
629
								<h3 class="catbg">
630
									', $txt['censor_test'], '
631
								</h3>
632
							</div>
633
							<div class="windowbg">
634
								<p class="centertext">
635
									<input type="text" name="censortest" value="', empty($context['censor_test']) ? '' : $context['censor_test'], '">
636
									<input type="submit" value="', $txt['censor_test_save'], '" class="button">
637
								</p>
638
							</div>
639
640
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
641
							<input type="hidden" name="', $context['admin-censor_token_var'], '" value="', $context['admin-censor_token'], '">
642
						</form>';
643
}
644
645
/**
646
 * This is the page shown when we've temporarily paused things such as during maintenance tasks, sending newsletters, etc.
647
 */
648
function template_not_done()
649
{
650
	global $context, $txt, $scripturl;
651
652
	echo '
653
						<div id="section_header" class="cat_bar">
654
							<h3 class="catbg">
655
								', $txt['not_done_title'], '
656
							</h3>
657
						</div>
658
						<div class="windowbg">
659
							', $txt['not_done_reason'];
660
661
	if (!empty($context['continue_percent']))
662
		echo '
663
							<div class="progress_bar">
664
								<span>', $context['continue_percent'], '%</span>
665
								<div class="bar" style="width: ', $context['continue_percent'], '%;"></div>
666
							</div>';
667
668
	if (!empty($context['substep_enabled']))
669
		echo '
670
							<div class="progress_bar progress_blue">
671
								<span>', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</span>
672
								<div class="bar" style="width: ', $context['substep_continue_percent'], '%;"></div>
673
							</div>';
674
675
	echo '
676
							<form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">';
677
678
	// Do we have a token?
679
	if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var']))
680
		echo '
681
							<input type="hidden" name="', $context[$context['not_done_token'] . '_token_var'], '" value="', $context[$context['not_done_token'] . '_token'], '">';
682
683
	echo '
684
								<input type="submit" name="cont" value="', $txt['not_done_continue'], '" class="button">
685
								', $context['continue_post_data'], '
686
							</form>
687
						</div><!-- .windowbg -->
688
					<script>
689
						var countdown = ', $context['continue_countdown'], ';
690
						doAutoSubmit();
691
692
						function doAutoSubmit()
693
						{
694
							if (countdown == 0)
695
								document.forms.autoSubmit.submit();
696
							else if (countdown == -1)
697
								return;
698
699
							document.forms.autoSubmit.cont.value = "', $txt['not_done_continue'], ' (" + countdown + ")";
700
							countdown--;
701
702
							setTimeout("doAutoSubmit();", 1000);
703
						}
704
					</script>';
705
}
706
707
/**
708
 * Template for showing settings (Of any kind really!)
709
 */
710
function template_show_settings()
711
{
712
	global $context, $txt, $scripturl;
713
714
	if (!empty($context['saved_successful']))
715
		echo '
716
					<div class="infobox">', $txt['settings_saved'], '</div>';
717
	elseif (!empty($context['saved_failed']))
718
		echo '
719
					<div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>';
720
721
	if (!empty($context['settings_pre_javascript']))
722
		echo '
723
					<script>', $context['settings_pre_javascript'], '</script>';
724
725
	if (!empty($context['settings_insert_above']))
726
		echo $context['settings_insert_above'];
727
728
	echo '
729
						<form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>';
730
731
	// Is there a custom title?
732
	if (isset($context['settings_title']))
733
		echo '
734
							<div class="cat_bar">
735
								<h3 class="catbg">', $context['settings_title'], '</h3>
736
							</div>';
737
738
	// Have we got a message to display?
739
	if (!empty($context['settings_message']))
740
	{
741
		$tag = !empty($context['settings_message']['tag']) ? $context['settings_message']['tag'] : 'span';
742
743
		echo '
744
							<div class="information noup">';
745
746
		if (is_array($context['settings_message']))
747
			echo '
748
								<', $tag, !empty($context['settings_message']['class']) ? ' class="' . $context['settings_message']['class'] . '"' : '', '>
749
									', $context['settings_message']['label'], '
750
								</', $tag, '>';
751
		else
752
			echo $context['settings_message'];
753
754
		echo '
755
							</div>';
756
	}
757
758
	// Filter out any redundant separators before we start the loop
759
	$context['config_vars'] = array_filter(
760
		$context['config_vars'],
761
		function ($v) use ($context)
762
		{
763
			static $config_vars, $prev;
764
765
			$at_start = is_null($config_vars);
766
			$config_vars = $at_start ? $context['config_vars'] : $config_vars;
767
768
			$next = next($config_vars);
769
			$at_end = key($config_vars) === null;
770
771
			if (!$at_start && !$at_end)
772
			{
773
				$div_types = array('title', 'desc');
774
				$at_start = isset($prev['type']) && in_array($prev['type'], $div_types);
775
				$at_end = isset($next['type']) && in_array($next['type'], $div_types);
776
			}
777
778
			$prev = $v;
779
			return ($v === '' && ($at_start || $at_end || $v === $next)) ? false : true;
780
		}
781
	);
782
783
	// Now actually loop through all the variables.
784
	$is_open = false;
785
	foreach ($context['config_vars'] as $config_var)
786
	{
787
		// Is it a title or a description?
788
		if (is_array($config_var) && ($config_var['type'] == 'title' || $config_var['type'] == 'desc'))
789
		{
790
			// Not a list yet?
791
			if ($is_open)
792
			{
793
				$is_open = false;
794
				echo '
795
									</dl>
796
							</div>';
797
			}
798
799
			// A title?
800
			if ($config_var['type'] == 'title')
801
			{
802
				echo '
803
							<div class="cat_bar">
804
								<h3 class="', !empty($config_var['class']) ? $config_var['class'] : 'catbg', '"', !empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '"' : '', '>
805
									', ($config_var['help'] ? '<a href="' . $scripturl . '?action=helpadmin;help=' . $config_var['help'] . '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="' . $txt['help'] . '"></span></a>' : ''), '
806
									', $config_var['label'], '
807
								</h3>
808
							</div>';
809
			}
810
			// A description?
811
			else
812
			{
813
				echo '
814
							<div class="information noup">
815
								', $config_var['label'], '
816
							</div>';
817
			}
818
819
			continue;
820
		}
821
822
		// Not a list yet?
823
		if (!$is_open)
824
		{
825
			$is_open = true;
826
			echo '
827
							<div class="windowbg noup">
828
								<dl class="settings">';
829
		}
830
831
		// Hang about? Are you pulling my leg - a callback?!
832
		if (is_array($config_var) && $config_var['type'] == 'callback')
833
		{
834
			if (function_exists('template_callback_' . $config_var['name']))
835
				call_user_func('template_callback_' . $config_var['name']);
836
837
			continue;
838
		}
839
840
		if (is_array($config_var))
841
		{
842
			// First off, is this a span like a message?
843
			if (in_array($config_var['type'], array('message', 'warning')))
844
			{
845
				echo '
846
									<dd', $config_var['type'] == 'warning' ? ' class="alert"' : '', (!empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '_dd"' : ''), '>
847
										', $config_var['label'], '
848
									</dd>';
849
			}
850
			// Otherwise it's an input box of some kind.
851
			else
852
			{
853
				echo '
854
									<dt', is_array($config_var) && !empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '"' : '', '>';
855
856
				// Some quick helpers...
857
				$javascript = $config_var['javascript'];
858
				$disabled = !empty($config_var['disabled']) ? ' disabled' : '';
859
				$subtext = !empty($config_var['subtext']) ? '<br><span class="smalltext"> ' . $config_var['subtext'] . '</span>' : '';
860
861
				// Various HTML5 input types that are basically enhanced textboxes
862
				$text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time');
863
864
				// Show the [?] button.
865
				if ($config_var['help'])
866
					echo '
867
										<a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="main_icons help" title="', $txt['help'], '"></span></a> ';
868
869
				echo '
870
										<a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label', ($config_var['type'] == 'boards' || $config_var['type'] == 'permissions' ? '' : ' for="' . $config_var['name'] . '"'), '>', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span>
871
									</dt>
872
									<dd', (!empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '_dd"' : ''), '>',
873
										$config_var['preinput'];
874
875
				// Show a check box.
876
				if ($config_var['type'] == 'check')
877
					echo '
878
										<input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">';
879
				// Escape (via htmlspecialchars.) the text box.
880
				elseif ($config_var['type'] == 'password')
881
					echo '
882
										<input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br>
883
										<input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>';
884
				// Show a selection box.
885
				elseif ($config_var['type'] == 'select')
886
				{
887
					echo '
888
										<select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), ' size="', $config_var['size'], '">';
889
890
					foreach ($config_var['data'] as $option)
891
						echo '
892
											<option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>';
893
					echo '
894
										</select>';
895
				}
896
897
				// List of boards? This requires getBoardList() having been run and the results in $context['board_list'].
898
				elseif ($config_var['type'] == 'boards')
899
				{
900
					$first = true;
901
					echo '
902
										<a href="#" class="board_selector">[ ', $txt['select_boards_from_list'], ' ]</a>
903
										<fieldset>
904
											<legend class="board_selector">
905
												<a href="#">', $txt['select_boards_from_list'], '</a>
906
											</legend>';
907
908
					foreach ($context['board_list'] as $id_cat => $cat)
909
					{
910
						if (!$first)
911
							echo '
912
											<hr>';
913
						echo '
914
											<strong>', $cat['name'], '</strong>
915
											<ul>';
916
917
						foreach ($cat['boards'] as $id_board => $brd)
918
							echo '
919
												<li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat('&nbsp; &nbsp;', $brd['child_level']) : '', $brd['name'], '</label></li>';
920
921
						echo '
922
											</ul>';
923
						$first = false;
924
					}
925
					echo '
926
											<hr />
927
											<input type="checkbox" onclick="invertAll(this, this.form, \'' . $config_var['name'] . '[\');">
928
											<span>', $txt['check_all'], '</span>
929
										</fieldset>';
930
				}
931
				// Text area?
932
				elseif ($config_var['type'] == 'large_text')
933
					echo '
934
										<textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>';
935
				// Permission group?
936
				elseif ($config_var['type'] == 'permissions')
937
					theme_inline_permissions($config_var['name']);
938
939
				// BBC selection?
940
				elseif ($config_var['type'] == 'bbc')
941
				{
942
					echo '
943
										<fieldset id="', $config_var['name'], '">
944
											<legend>', $context['bbc_sections'][$config_var['name']]['title'], '</legend>
945
											<ul>';
946
947
					foreach ($context['bbc_sections'][$config_var['name']]['columns'] as $bbcColumn)
948
					{
949
						foreach ($bbcColumn as $bbcTag)
950
							echo '
951
												<li class="list_bbc floatleft">
952
													<input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', '
953
												</li>';
954
					}
955
					echo '					</ul>
956
											<input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['enabled_bbc_select_all'], '</em></label>
957
										</fieldset>';
958
				}
959
				// A simple message?
960
				elseif ($config_var['type'] == 'var_message')
961
					echo '
962
										<div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>
963
											', $config_var['var_message'], '
964
										</div>';
965
				// Assume it must be a text box
966
				else
967
				{
968
					// Figure out the exact type - use "number" for "float" and "int".
969
					$type = in_array($config_var['type'], $text_types) ? $config_var['type'] : ($config_var['type'] == 'int' || $config_var['type'] == 'float' ? 'number' : 'text');
970
971
					// Extra options for float/int values - how much to decrease/increase by, the min value and the max value
972
					// The step - only set if incrementing by something other than 1 for int or 0.1 for float
973
					$step = isset($config_var['step']) ? ' step="' . $config_var['step'] . '"' : ($config_var['type'] == 'float' ? ' step="0.1"' : '');
974
975
					// Minimum allowed value for this setting. SMF forces a default of 0 if not specified in the settings
976
					$min = isset($config_var['min']) ? ' min="' . $config_var['min'] . '"' : '';
977
978
					// Maximum allowed value for this setting.
979
					$max = isset($config_var['max']) ? ' max="' . $config_var['max'] . '"' : '';
980
981
					echo '
982
										<input type="', $type, '"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '" value="', $config_var['value'], '"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '', $min . $max . $step, '>';
983
				}
984
985
				echo isset($config_var['postinput']) ? '
986
											' . $config_var['postinput'] : '', '
987
									</dd>';
988
			}
989
		}
990
		else
991
		{
992
			// Just show a separator.
993
			if ($config_var == '')
994
				echo '
995
								</dl>
996
								<hr>
997
								<dl class="settings">';
998
			else
999
				echo '
1000
									<dt>
1001
										<strong>' . $config_var . '</strong>
1002
									</dt>
1003
									<dd></dd>';
1004
		}
1005
	}
1006
1007
	if ($is_open)
1008
		echo '
1009
								</dl>';
1010
1011
	if (empty($context['settings_save_dont_show']))
1012
		echo '
1013
								<input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">';
1014
1015
	if ($is_open)
1016
		echo '
1017
							</div><!-- .windowbg -->';
1018
1019
	// At least one token has to be used!
1020
	if (isset($context['admin-ssc_token']))
1021
		echo '
1022
							<input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">';
1023
1024
	if (isset($context['admin-dbsc_token']))
1025
		echo '
1026
							<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">';
1027
1028
	if (isset($context['admin-mp_token']))
1029
		echo '
1030
							<input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">';
1031
1032
	echo '
1033
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1034
						</form>';
1035
1036
	if (!empty($context['settings_post_javascript']))
1037
		echo '
1038
					<script>
1039
						', $context['settings_post_javascript'], '
1040
					</script>';
1041
1042
	if (!empty($context['settings_insert_below']))
1043
		echo $context['settings_insert_below'];
1044
1045
	// We may have added a board listing. If we did, we need to make it work.
1046
	addInlineJavascript('
1047
		$("legend.board_selector").closest("fieldset").hide();
1048
		$("a.board_selector").click(function(e) {
1049
			e.preventDefault();
1050
			$(this).hide().next("fieldset").show();
1051
		});
1052
		$("fieldset legend.board_selector a").click(function(e) {
1053
			e.preventDefault();
1054
			$(this).closest("fieldset").hide().prev("a").show();
1055
		});
1056
	', true);
1057
}
1058
1059
/**
1060
 * Template for showing custom profile fields.
1061
 */
1062
function template_show_custom_profile()
1063
{
1064
	global $context, $txt;
1065
1066
	if (!empty($context['saved_successful']))
1067
		echo '
1068
					<div class="infobox">', $txt['settings_saved'], '</div>';
1069
1070
	// Standard fields.
1071
	template_show_list('standard_profile_fields');
1072
1073
	echo '
1074
					<script>
1075
						var iNumChecks = document.forms.standardProfileFields.length;
1076
						for (var i = 0; i < iNumChecks; i++)
1077
							if (document.forms.standardProfileFields[i].id.indexOf(\'reg_\') == 0)
1078
								document.forms.standardProfileFields[i].disabled = document.forms.standardProfileFields[i].disabled || !document.getElementById(\'active_\' + document.forms.standardProfileFields[i].id.substr(4)).checked;
1079
					</script>
1080
					<br>';
1081
1082
	// Custom fields.
1083
	template_show_list('custom_profile_fields');
1084
}
1085
1086
/**
1087
 * Template for editing a custom profile field
1088
 */
1089
function template_edit_profile_field()
1090
{
1091
	global $context, $txt, $scripturl;
1092
1093
	// All the javascript for this page - quite a bit in script.js!
1094
	echo '
1095
					<script>
1096
						var startOptID = ', count($context['field']['options']), ';
1097
					</script>';
1098
1099
	// any errors messages to show?
1100
	if (isset($_GET['msg']))
1101
	{
1102
		loadLanguage('Errors');
1103
1104
		if (isset($txt['custom_option_' . $_GET['msg']]))
1105
			echo '
1106
					<div class="errorbox">',
1107
						$txt['custom_option_' . $_GET['msg']], '
1108
					</div>';
1109
	}
1110
1111
	echo '
1112
						<form action="', $scripturl, '?action=admin;area=featuresettings;sa=profileedit;fid=', $context['fid'], ';', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
1113
							<div id="section_header" class="cat_bar">
1114
								<h3 class="catbg">', $context['page_title'], '</h3>
1115
							</div>
1116
							<div class="windowbg">
1117
								<fieldset>
1118
									<legend>', $txt['custom_edit_general'], '</legend>
1119
1120
									<dl class="settings">
1121
										<dt>
1122
											<a id="field_name_help" href="', $scripturl, '?action=helpadmin;help=translatable_fields" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a>
1123
											<strong><label for="field_name">', $txt['custom_edit_name'], ':</label></strong><br>
1124
											<span class="smalltext">', $txt['custom_edit_name_desc'], '</span>
1125
										</dt>
1126
										<dd>
1127
											<input type="text" name="field_name" id="field_name" value="', $context['field']['name'], '" size="20" maxlength="40">
1128
										</dd>
1129
										<dt>
1130
											<a id="field_desc_help" href="', $scripturl, '?action=helpadmin;help=translatable_fields" onclick="return reqOverlayDiv(this.href);" class="help">
1131
												<span class="main_icons help" title="', $txt['help'], '"></span>
1132
											</a>
1133
											<strong><label for="field_desc">', $txt['custom_edit_desc'], ':</label></strong><br>
1134
											<span class="smalltext">', $txt['custom_edit_name_desc'], '</span>
1135
										</dt>
1136
										<dd>
1137
											<textarea name="field_desc" id="field_desc" rows="3" cols="40">', $context['field']['desc'], '</textarea>
1138
										</dd>
1139
										<dt>
1140
											<strong><label for="profile_area">', $txt['custom_edit_profile'], ':</label></strong><br>
1141
											<span class="smalltext">', $txt['custom_edit_profile_desc'], '</span>
1142
										</dt>
1143
										<dd>
1144
											<select name="profile_area" id="profile_area">
1145
												<option value="none"', $context['field']['profile_area'] == 'none' ? ' selected' : '', '>', $txt['custom_edit_profile_none'], '</option>
1146
												<option value="account"', $context['field']['profile_area'] == 'account' ? ' selected' : '', '>', $txt['account'], '</option>
1147
												<option value="forumprofile"', $context['field']['profile_area'] == 'forumprofile' ? ' selected' : '', '>', $txt['forumprofile'], '</option>
1148
												<option value="theme"', $context['field']['profile_area'] == 'theme' ? ' selected' : '', '>', $txt['theme'], '</option>
1149
											</select>
1150
										</dd>
1151
										<dt>
1152
											<a id="field_reg_require" href="', $scripturl, '?action=helpadmin;help=field_reg_require" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a>
1153
											<strong><label for="reg">', $txt['custom_edit_registration'], ':</label></strong>
1154
										</dt>
1155
										<dd>
1156
											<select name="reg" id="reg">
1157
												<option value="0"', $context['field']['reg'] == 0 ? ' selected' : '', '>', $txt['custom_edit_registration_disable'], '</option>
1158
												<option value="1"', $context['field']['reg'] == 1 ? ' selected' : '', '>', $txt['custom_edit_registration_allow'], '</option>
1159
												<option value="2"', $context['field']['reg'] == 2 ? ' selected' : '', '>', $txt['custom_edit_registration_require'], '</option>
1160
											</select>
1161
										</dd>
1162
										<dt>
1163
											<strong><label for="display">', $txt['custom_edit_display'], ':</label></strong>
1164
										</dt>
1165
										<dd>
1166
											<input type="checkbox" name="display" id="display"', $context['field']['display'] ? ' checked' : '', '>
1167
										</dd>
1168
										<dt>
1169
											<strong><label for="mlist">', $txt['custom_edit_mlist'], ':</label></strong>
1170
										</dt>
1171
										<dd>
1172
											<input type="checkbox" name="mlist" id="show_mlist"', $context['field']['mlist'] ? ' checked' : '', '>
1173
										</dd>
1174
										<dt>
1175
											<strong><label for="placement">', $txt['custom_edit_placement'], ':</label></strong>
1176
										</dt>
1177
										<dd>
1178
											<select name="placement" id="placement">';
1179
1180
	foreach ($context['cust_profile_fields_placement'] as $order => $name)
1181
		echo '
1182
												<option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>';
1183
1184
	echo '
1185
											</select>
1186
										</dd>
1187
										<dt>
1188
											<a id="field_show_enclosed" href="', $scripturl, '?action=helpadmin;help=field_show_enclosed" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a>
1189
											<strong><label for="enclose">', $txt['custom_edit_enclose'], ':</label></strong><br>
1190
											<span class="smalltext">', $txt['custom_edit_enclose_desc'], '</span>
1191
										</dt>
1192
										<dd>
1193
											<textarea name="enclose" id="enclose" rows="10" cols="50">', @$context['field']['enclose'], '</textarea>
1194
										</dd>
1195
									</dl>
1196
								</fieldset>
1197
								<fieldset>
1198
									<legend>', $txt['custom_edit_input'], '</legend>
1199
									<dl class="settings">
1200
										<dt>
1201
											<strong><label for="field_type">', $txt['custom_edit_picktype'], ':</label></strong>
1202
										</dt>
1203
										<dd>
1204
											<select name="field_type" id="field_type" onchange="updateInputBoxes();">';
1205
1206
	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type)
1207
		echo '
1208
												<option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>';
1209
1210
	echo '
1211
											</select>
1212
										</dd>
1213
										<dt id="max_length_dt">
1214
											<strong><label for="max_length_dd">', $txt['custom_edit_max_length'], ':</label></strong><br>
1215
											<span class="smalltext">', $txt['custom_edit_max_length_desc'], '</span>
1216
										</dt>
1217
										<dd>
1218
											<input type="text" name="max_length" id="max_length_dd" value="', $context['field']['max_length'], '" size="7" maxlength="6">
1219
										</dd>
1220
										<dt id="dimension_dt">
1221
											<strong><label for="dimension_dd">', $txt['custom_edit_dimension'], ':</label></strong>
1222
										</dt>
1223
										<dd id="dimension_dd">
1224
											<strong>', $txt['custom_edit_dimension_row'], ':</strong> <input type="text" name="rows" value="', $context['field']['rows'], '" size="5" maxlength="3">
1225
											<strong>', $txt['custom_edit_dimension_col'], ':</strong> <input type="text" name="cols" value="', $context['field']['cols'], '" size="5" maxlength="3">
1226
										</dd>
1227
										<dt id="bbc_dt">
1228
											<strong><label for="bbc_dd">', $txt['custom_edit_bbc'], '</label></strong>
1229
										</dt>
1230
										<dd>
1231
											<input type="checkbox" name="bbc" id="bbc_dd"', $context['field']['bbc'] ? ' checked' : '', '>
1232
										</dd>
1233
										<dt id="options_dt">
1234
											<a href="', $scripturl, '?action=helpadmin;help=customoptions" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a>
1235
											<strong><label for="options_dd">', $txt['custom_edit_options'], ':</label></strong><br>
1236
											<span class="smalltext">', $txt['custom_edit_options_desc'], '</span>
1237
											<br>
1238
											<span>', $txt['custom_edit_name_desc'], '</span>
1239
										</dt>
1240
										<dd id="options_dd">';
1241
1242
	foreach ($context['field']['options'] as $k => $option)
1243
		echo '
1244
											', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">';
1245
1246
	echo '
1247
											<span id="addopt"></span>
1248
											[<a href="" onclick="addOption(); return false;">', $txt['custom_edit_options_more'], '</a>]
1249
										</dd>
1250
										<dt id="default_dt">
1251
											<strong><label for="default_dd">', $txt['custom_edit_default'], ':</label></strong>
1252
										</dt>
1253
										<dd>
1254
											<input type="checkbox" name="default_check" id="default_dd"', $context['field']['default_check'] ? ' checked' : '', '>
1255
										</dd>
1256
									</dl>
1257
								</fieldset>
1258
								<fieldset>
1259
									<legend>', $txt['custom_edit_advanced'], '</legend>
1260
									<dl class="settings">
1261
										<dt id="mask_dt">
1262
											<a id="custom_mask" href="', $scripturl, '?action=helpadmin;help=custom_mask" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a>
1263
											<strong><label for="mask">', $txt['custom_edit_mask'], ':</label></strong><br>
1264
											<span class="smalltext">', $txt['custom_edit_mask_desc'], '</span>
1265
										</dt>
1266
										<dd>
1267
											<select name="mask" id="mask" onchange="updateInputBoxes();">
1268
												<option value="nohtml"', $context['field']['mask'] == 'nohtml' ? ' selected' : '', '>', $txt['custom_edit_mask_nohtml'], '</option>
1269
												<option value="email"', $context['field']['mask'] == 'email' ? ' selected' : '', '>', $txt['custom_edit_mask_email'], '</option>
1270
												<option value="number"', $context['field']['mask'] == 'number' ? ' selected' : '', '>', $txt['custom_edit_mask_number'], '</option>
1271
												<option value="regex"', strpos($context['field']['mask'], 'regex') === 0 ? ' selected' : '', '>', $txt['custom_edit_mask_regex'], '</option>
1272
											</select>
1273
											<br>
1274
											<span id="regex_div">
1275
												<input type="text" name="regex" value="', $context['field']['regex'], '" size="30">
1276
											</span>
1277
										</dd>
1278
										<dt>
1279
											<strong><label for="private">', $txt['custom_edit_privacy'], ':</label></strong><br>
1280
											<span class="smalltext">', $txt['custom_edit_privacy_desc'], '</span>
1281
										</dt>
1282
										<dd>
1283
											<select name="private" id="private" onchange="updateInputBoxes();">
1284
												<option value="0"', $context['field']['private'] == 0 ? ' selected' : '', '>', $txt['custom_edit_privacy_all'], '</option>
1285
												<option value="1"', $context['field']['private'] == 1 ? ' selected' : '', '>', $txt['custom_edit_privacy_see'], '</option>
1286
												<option value="2"', $context['field']['private'] == 2 ? ' selected' : '', '>', $txt['custom_edit_privacy_owner'], '</option>
1287
												<option value="3"', $context['field']['private'] == 3 ? ' selected' : '', '>', $txt['custom_edit_privacy_none'], '</option>
1288
											</select>
1289
										</dd>
1290
										<dt id="can_search_dt">
1291
											<strong><label for="can_search_dd">', $txt['custom_edit_can_search'], ':</label></strong><br>
1292
											<span class="smalltext">', $txt['custom_edit_can_search_desc'], '</span>
1293
										</dt>
1294
										<dd>
1295
											<input type="checkbox" name="can_search" id="can_search_dd"', $context['field']['can_search'] ? ' checked' : '', '>
1296
										</dd>
1297
										<dt>
1298
											<strong><label for="can_search_check">', $txt['custom_edit_active'], ':</label></strong><br>
1299
											<span class="smalltext">', $txt['custom_edit_active_desc'], '</span>
1300
										</dt>
1301
										<dd>
1302
											<input type="checkbox" name="active" id="can_search_check"', $context['field']['active'] ? ' checked' : '', '>
1303
										</dd>
1304
									</dl>
1305
								</fieldset>
1306
								<input type="submit" name="save" value="', $txt['save'], '" class="button">';
1307
1308
	if ($context['fid'])
1309
		echo '
1310
								<input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">';
1311
1312
	echo '
1313
							</div><!-- .windowbg -->
1314
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1315
							<input type="hidden" name="', $context['admin-ecp_token_var'], '" value="', $context['admin-ecp_token'], '">
1316
						</form>';
1317
1318
	// Get the javascript bits right!
1319
	echo '
1320
					<script>
1321
						updateInputBoxes();
1322
					</script>';
1323
}
1324
1325
/**
1326
 * Results page for an admin search.
1327
 */
1328
function template_admin_search_results()
1329
{
1330
	global $context, $txt;
1331
1332
	echo '
1333
						<div id="section_header" class="cat_bar">
1334
							', template_admin_quick_search(), '
0 ignored issues
show
Are you sure the usage of template_admin_quick_search() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
1335
							<h3 class="catbg">
1336
								<span id="quick_search_results">
1337
									', sprintf($txt['admin_search_results_desc'], $context['search_term']), '
1338
								</span>
1339
							</h3>
1340
						</div><!-- #section_header -->
1341
						<div class="windowbg generic_list_wrapper">';
1342
1343
	if (empty($context['search_results']))
1344
	{
1345
		echo '
1346
							<p class="centertext">
1347
								<strong>', $txt['admin_search_results_none'], '</strong>
1348
							</p>';
1349
	}
1350
	else
1351
	{
1352
		echo '
1353
							<ol class="search_results">';
1354
1355
		foreach ($context['search_results'] as $result)
1356
		{
1357
			// Is it a result from the online manual?
1358
			if ($context['search_type'] == 'online')
1359
			{
1360
				echo '
1361
								<li>
1362
									<p>
1363
										<a href="', $context['doc_scripturl'], str_replace(' ', '_', $result['title']), '" target="_blank" rel="noopener"><strong>', $result['title'], '</strong></a>
1364
									</p>
1365
									<p class="double_height">
1366
										', $result['snippet'], '
1367
									</p>
1368
								</li>';
1369
			}
1370
			// Otherwise it's... not!
1371
			else
1372
			{
1373
				echo '
1374
								<li>
1375
									<a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']';
1376
1377
				if ($result['help'])
1378
					echo '
1379
									<p class="double_height">', $result['help'], '</p>';
1380
1381
				echo '
1382
								</li>';
1383
			}
1384
		}
1385
		echo '
1386
							</ol>';
1387
	}
1388
1389
	echo '
1390
						</div><!-- .generic_list_wrapper -->';
1391
}
1392
1393
/**
1394
 * This little beauty shows questions and answer from the captcha type feature.
1395
 */
1396
function template_callback_question_answer_list()
1397
{
1398
	global $txt, $context;
1399
1400
	foreach ($context['languages'] as $lang_id => $lang)
1401
	{
1402
		$lang_id = strtr($lang_id, array('-utf8' => ''));
1403
		$lang['name'] = strtr($lang['name'], array('-utf8' => ''));
1404
1405
		echo '
1406
						<dt id="qa_dt_', $lang_id, '" class="qa_link">
1407
							<a href="javascript:void(0);">[ ', $lang['name'], ' ]</a>
1408
						</dt>
1409
						<fieldset id="qa_fs_', $lang_id, '" class="qa_fieldset">
1410
							<legend><a href="javascript:void(0);">', $lang['name'], '</a></legend>
1411
							<dl class="settings">
1412
								<dt>
1413
									<strong>', $txt['setup_verification_question'], '</strong>
1414
								</dt>
1415
								<dd>
1416
									<strong>', $txt['setup_verification_answer'], '</strong>
1417
								</dd>';
1418
1419
		if (!empty($context['qa_by_lang'][$lang_id]))
1420
			foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1421
			{
1422
				$question = $context['question_answers'][$q_id];
1423
1424
				echo '
1425
								<dt>
1426
									<input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="verification_question">
1427
								</dt>
1428
								<dd>';
1429
1430
				foreach ($question['answers'] as $answer)
1431
					echo '
1432
									<input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">';
1433
1434
				echo '
1435
									<div class="qa_add_answer"><a href="javascript:void(0);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div>
1436
								</dd>';
1437
			}
1438
1439
		echo '
1440
								<dt class="qa_add_question"><a href="javascript:void(0);">[ ', $txt['setup_verification_add_more'], ' ]</a></dt>
1441
							</dl>
1442
						</fieldset>';
1443
	}
1444
}
1445
1446
/**
1447
 * Repairing boards.
1448
 */
1449
function template_repair_boards()
1450
{
1451
	global $context, $txt, $scripturl;
1452
1453
	echo '
1454
						<div id="section_header" class="cat_bar">
1455
							<h3 class="catbg">',
1456
								$context['error_search'] ? $txt['errors_list'] : $txt['errors_fixing'], '
1457
							</h3>
1458
						</div>
1459
						<div class="windowbg">';
1460
1461
	// Are we actually fixing them, or is this just a prompt?
1462
	if ($context['error_search'])
1463
	{
1464
		if (!empty($context['to_fix']))
1465
		{
1466
			echo '
1467
							', $txt['errors_found'], ':
1468
							<ul>';
1469
1470
			foreach ($context['repair_errors'] as $error)
1471
				echo '
1472
								<li>
1473
									', $error, '
1474
								</li>';
1475
1476
			echo '
1477
							</ul>
1478
							<p>
1479
								', $txt['errors_fix'], '
1480
							</p>
1481
							<p class="padding">
1482
								<strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-repairboards_token_var'], '=', $context['admin-repairboards_token'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong>
1483
							</p>';
1484
		}
1485
		else
1486
			echo '
1487
							<p>', $txt['maintain_no_errors'], '</p>
1488
							<p class="padding">
1489
								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1490
							</p>';
1491
	}
1492
	else
1493
	{
1494
		if (!empty($context['redirect_to_recount']))
1495
		{
1496
			echo '
1497
							<p>
1498
								', $txt['errors_do_recount'], '
1499
							</p>
1500
							<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=recount" id="recount_form" method="post">
1501
								<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
1502
								<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1503
								<input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '">
1504
							</form>';
1505
		}
1506
		else
1507
		{
1508
			echo '
1509
							<p>', $txt['errors_fixed'], '</p>
1510
							<p class="padding">
1511
								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1512
							</p>';
1513
		}
1514
	}
1515
1516
	echo '
1517
						</div><!-- .windowbg -->';
1518
1519
	if (!empty($context['redirect_to_recount']))
1520
	{
1521
		echo '
1522
					<script>
1523
						var countdown = 5;
1524
						doAutoSubmit();
1525
1526
						function doAutoSubmit()
1527
						{
1528
							if (countdown == 0)
1529
								document.forms.recount_form.submit();
1530
							else if (countdown == -1)
1531
								return;
1532
1533
							document.forms.recount_form.recount_now.value = "', $txt['errors_recount_now'], ' (" + countdown + ")";
1534
							countdown--;
1535
1536
							setTimeout("doAutoSubmit();", 1000);
1537
						}
1538
					</script>';
1539
	}
1540
}
1541
1542
/**
1543
 * Retrieves info from the php_info function, scrubs and preps it for display
1544
 */
1545
function template_php_info()
1546
{
1547
	global $context, $txt;
1548
1549
	echo '
1550
					<div id="admin_form_wrapper">
1551
						<div id="section_header" class="cat_bar">
1552
							<h3 class="catbg">
1553
								', $txt['phpinfo_settings'], '
1554
							</h3>
1555
						</div>';
1556
1557
	// for each php info area
1558
	foreach ($context['pinfo'] as $area => $php_area)
1559
	{
1560
		echo '
1561
						<table id="', str_replace(' ', '_', $area), '" class="table_grid">
1562
							<thead>
1563
								<tr class="title_bar">
1564
									<th class="equal_table" scope="col"></th>
1565
									<th class="centercol equal_table" scope="col"><strong>', $area, '</strong></th>
1566
									<th class="equal_table" scope="col"></th>
1567
								</tr>
1568
							</thead>
1569
							<tbody>';
1570
1571
		$localmaster = true;
1572
1573
		// and for each setting in this category
1574
		foreach ($php_area as $key => $setting)
1575
		{
1576
			// start of a local / master setting (3 col)
1577
			if (is_array($setting))
1578
			{
1579
				if ($localmaster)
1580
				{
1581
					// heading row for the settings section of this category's settings
1582
					echo '
1583
								<tr class="title_bar">
1584
									<td class="equal_table"><strong>', $txt['phpinfo_itemsettings'], '</strong></td>
1585
									<td class="equal_table"><strong>', $txt['phpinfo_localsettings'], '</strong></td>
1586
									<td class="equal_table"><strong>', $txt['phpinfo_defaultsettings'], '</strong></td>
1587
								</tr>';
1588
1589
					$localmaster = false;
1590
				}
1591
1592
				echo '
1593
								<tr class="windowbg">
1594
									<td class="equal_table">', $key, '</td>';
1595
1596
				foreach ($setting as $key_lm => $value)
1597
					echo '
1598
									<td class="equal_table">', $value, '</td>';
1599
1600
				echo '
1601
								</tr>';
1602
			}
1603
			// just a single setting (2 col)
1604
			else
1605
			{
1606
				echo '
1607
								<tr class="windowbg">
1608
									<td class="equal_table">', $key, '</td>
1609
									<td colspan="2">', str_replace(',', ', ', $setting), '</td>
1610
								</tr>';
1611
			}
1612
		}
1613
		echo '
1614
							</tbody>
1615
						</table>
1616
						<br>';
1617
	}
1618
1619
	echo '
1620
					</div><!-- #admin_form_wrapper -->';
1621
}
1622
1623
/**
1624
 * Content shown above the clean cache button
1625
 */
1626
function template_clean_cache_button_above()
1627
{
1628
}
1629
1630
/**
1631
 * Content shown below the clean cache button?
1632
 */
1633
function template_clean_cache_button_below()
1634
{
1635
	global $txt, $scripturl, $context;
1636
1637
	echo '
1638
					<div class="cat_bar">
1639
						<h3 class="catbg">', $txt['maintain_cache'], '</h3>
1640
					</div>
1641
					<div class="windowbg">
1642
						<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=cleancache" method="post" accept-charset="', $context['character_set'], '">
1643
							<p>', $txt['maintain_cache_info'], '</p>
1644
							<span><input type="submit" value="', $txt['maintain_run_now'], '" class="button"></span>
1645
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1646
							<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
1647
						</form>
1648
					</div>';
1649
}
1650
1651
/**
1652
 * This shows the admin search form
1653
 */
1654
function template_admin_quick_search()
1655
{
1656
	global $context, $txt, $scripturl;
1657
1658
	if ($context['user']['is_admin'])
1659
		echo '
1660
								<form action="' . $scripturl . '?action=admin;area=search" method="post" accept-charset="' . $context['character_set'] . '" class="admin_search">
1661
									<span class="main_icons filter centericon"></span>
1662
									<input type="search" name="search_term" placeholder="', $txt['admin_search'], '"', isset($context['search_term']) ? ' value="' . $context['search_term'] . '"' : '','>
1663
									<select name="search_type">
1664
										<option value="internal"', (empty($context['admin_preferences']['sb']) || $context['admin_preferences']['sb'] == 'internal' ? ' selected' : ''), '>', $txt['admin_search_type_internal'], '</option>
1665
										<option value="member"', (!empty($context['admin_preferences']['sb']) && $context['admin_preferences']['sb'] == 'member' ? ' selected' : ''), '>', $txt['admin_search_type_member'], '</option>
1666
										<option value="online"', (!empty($context['admin_preferences']['sb']) && $context['admin_preferences']['sb'] == 'online' ? ' selected' : ''), '>', $txt['admin_search_type_online'], '</option>
1667
									</select>
1668
									<input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button">
1669
								</form>';
1670
}
1671
1672
?>