Passed
Pull Request — release-2.1 (#4892)
by Mathias
06:47 queued 57s
created

template_edit_policy()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 83
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 5
eloc 31
c 4
b 0
f 0
nc 4
nop 0
dl 0
loc 83
rs 9.1128

How to fix   Long Method   

Long Method

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

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

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines http://www.simplemachines.org
7
 * @copyright 2018 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 Beta 4
11
 */
12
13
/**
14
 * This 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="generic_icons help" title="', $txt['help'], '"></span></a> ', $txt['live'], '
33
									</h3>
34
								</div>
35
								<div class="windowbg nopadding">
36
									<div id="smfAnnouncements">', $txt['lfyi'], '</div>
37
								</div>
38
							</div>';
39
40
	// Show the user version information from their server.
41
	echo '
42
							<div id="supportVersionsTable" 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><!-- #supportVersionsTable -->
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
		echo '
741
							<div class="information">', $context['settings_message'], '</div>';
742
743
	// Now actually loop through all the variables.
744
	$is_open = false;
745
	foreach ($context['config_vars'] as $config_var)
746
	{
747
		// Is it a title or a description?
748
		if (is_array($config_var) && ($config_var['type'] == 'title' || $config_var['type'] == 'desc'))
749
		{
750
			// Not a list yet?
751
			if ($is_open)
752
			{
753
				$is_open = false;
754
				echo '
755
									</dl>
756
							</div>';
757
			}
758
759
			// A title?
760
			if ($config_var['type'] == 'title')
761
			{
762
				echo '
763
							<div class="cat_bar">
764
								<h3 class="', !empty($config_var['class']) ? $config_var['class'] : 'catbg', '"', !empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '"' : '', '>
765
									', ($config_var['help'] ? '<a href="' . $scripturl . '?action=helpadmin;help=' . $config_var['help'] . '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="' . $txt['help'] . '"></span></a>' : ''), '
766
									', $config_var['label'], '
767
								</h3>
768
							</div>';
769
			}
770
			// A description?
771
			else
772
			{
773
				echo '
774
							<div class="information noup">
775
								', $config_var['label'], '
776
							</div>';
777
			}
778
779
			continue;
780
		}
781
782
		// Not a list yet?
783
		if (!$is_open)
784
		{
785
			$is_open = true;
786
			echo '
787
							<div class="windowbg noup">
788
								<dl class="settings">';
789
		}
790
791
		// Hang about? Are you pulling my leg - a callback?!
792
		if (is_array($config_var) && $config_var['type'] == 'callback')
793
		{
794
			if (function_exists('template_callback_' . $config_var['name']))
795
				call_user_func('template_callback_' . $config_var['name']);
796
797
			continue;
798
		}
799
800
		if (is_array($config_var))
801
		{
802
			// First off, is this a span like a message?
803
			if (in_array($config_var['type'], array('message', 'warning')))
804
			{
805
				echo '
806
									<dd', $config_var['type'] == 'warning' ? ' class="alert"' : '', (!empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '_dd"' : ''), '>
807
										', $config_var['label'], '
808
									</dd>';
809
			}
810
			// Otherwise it's an input box of some kind.
811
			else
812
			{
813
				echo '
814
									<dt', is_array($config_var) && !empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '"' : '', '>';
815
816
				// Some quick helpers...
817
				$javascript = $config_var['javascript'];
818
				$disabled = !empty($config_var['disabled']) ? ' disabled' : '';
819
				$subtext = !empty($config_var['subtext']) ? '<br><span class="smalltext"> ' . $config_var['subtext'] . '</span>' : '';
820
821
				// Various HTML5 input types that are basically enhanced textboxes
822
				$text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time');
823
824
				// Show the [?] button.
825
				if ($config_var['help'])
826
					echo '
827
										<a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ';
828
829
				echo '
830
										<a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span>
831
									</dt>
832
									<dd', (!empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '_dd"' : ''), '>',
833
										$config_var['preinput'];
834
835
				// Show a check box.
836
				if ($config_var['type'] == 'check')
837
					echo '
838
										<input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">';
839
				// Escape (via htmlspecialchars.) the text box.
840
				elseif ($config_var['type'] == 'password')
841
					echo '
842
										<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>
843
										<input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>';
844
				// Show a selection box.
845
				elseif ($config_var['type'] == 'select')
846
				{
847
					echo '
848
										<select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>';
849
850
					foreach ($config_var['data'] as $option)
851
						echo '
852
											<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>';
853
					echo '
854
										</select>';
855
				}
856
				// List of boards? This requires getBoardList() having been run and the results in $context['board_list'].
857
				elseif ($config_var['type'] == 'boards')
858
				{
859
					$first = true;
860
					echo '
861
										<a href="#" class="board_selector">[ ', $txt['select_boards_from_list'], ' ]</a>
862
										<fieldset>
863
											<legend class="board_selector">
864
												<a href="#">', $txt['select_boards_from_list'], '</a>
865
											</legend>';
866
867
					foreach ($context['board_list'] as $id_cat => $cat)
868
					{
869
						if (!$first)
870
							echo '
871
											<hr>';
872
						echo '
873
											<strong>', $cat['name'], '</strong>
874
											<ul>';
875
876
						foreach ($cat['boards'] as $id_board => $brd)
877
							echo '
878
												<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>';
879
880
						echo '
881
											</ul>';
882
						$first = false;
883
					}
884
					echo '
885
										</fieldset>';
886
				}
887
				// Text area?
888
				elseif ($config_var['type'] == 'large_text')
889
					echo '
890
										<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>';
891
				// Permission group?
892
				elseif ($config_var['type'] == 'permissions')
893
					theme_inline_permissions($config_var['name']);
894
895
				// BBC selection?
896
				elseif ($config_var['type'] == 'bbc')
897
				{
898
					echo '
899
										<fieldset id="', $config_var['name'], '">
900
											<legend>', $txt['bbcTagsToUse_select'], '</legend>
901
											<ul>';
902
903
					foreach ($context['bbc_columns'] as $bbcColumn)
904
					{
905
						foreach ($bbcColumn as $bbcTag)
906
							echo '
907
												<li class="list_bbc floatleft">
908
													<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>)' : '', '
909
												</li>';
910
					}
911
					echo '					</ul>
912
											<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['bbcTagsToUse_select_all'], '</em></label>
913
										</fieldset>';
914
				}
915
				// A simple message?
916
				elseif ($config_var['type'] == 'var_message')
917
					echo '
918
										<div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>
919
											', $config_var['var_message'], '
920
										</div>';
921
				// Assume it must be a text box
922
				else
923
				{
924
					// Figure out the exact type - use "number" for "float" and "int".
925
					$type = in_array($config_var['type'], $text_types) ? $config_var['type'] : ($config_var['type'] == 'int' || $config_var['type'] == 'float' ? 'number' : 'text');
926
927
					// Extra options for float/int values - how much to decrease/increase by, the min value and the max value
928
					// The step - only set if incrementing by something other than 1 for int or 0.1 for float
929
					$step = isset($config_var['step']) ? ' step="' . $config_var['step'] . '"' : ($config_var['type'] == 'float' ? ' step="0.1"' : '');
930
931
					// Minimum allowed value for this setting. SMF forces a default of 0 if not specified in the settings
932
					$min = isset($config_var['min']) ? ' min="' . $config_var['min'] . '"' : '';
933
934
					// Maximum allowed value for this setting.
935
					$max = isset($config_var['max']) ? ' max="' . $config_var['max'] . '"' : '';
936
937
					echo '
938
										<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, '>';
939
				}
940
941
				echo isset($config_var['postinput']) ? '
942
											' . $config_var['postinput'] : '','
943
									</dd>';
944
			}
945
		}
946
		else
947
		{
948
			// Just show a separator.
949
			if ($config_var == '')
950
				echo '
951
								</dl>
952
								<hr>
953
								<dl class="settings">';
954
			else
955
				echo '
956
									<dd>
957
										<strong>' . $config_var . '</strong>
958
									</dd>';
959
		}
960
	}
961
962
	if ($is_open)
963
		echo '
964
								</dl>';
965
966
	if (empty($context['settings_save_dont_show']))
967
		echo '
968
								<input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">';
969
970
	if ($is_open)
971
		echo '
972
							</div><!-- .windowbg -->';
973
974
975
	// At least one token has to be used!
976
	if (isset($context['admin-ssc_token']))
977
		echo '
978
							<input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">';
979
980
	if (isset($context['admin-dbsc_token']))
981
		echo '
982
							<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">';
983
984
	if (isset($context['admin-mp_token']))
985
		echo '
986
							<input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">';
987
988
	echo '
989
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
990
						</form>';
991
992
	if (!empty($context['settings_post_javascript']))
993
		echo '
994
					<script>
995
						', $context['settings_post_javascript'], '
996
					</script>';
997
998
	if (!empty($context['settings_insert_below']))
999
		echo $context['settings_insert_below'];
1000
1001
	// We may have added a board listing. If we did, we need to make it work.
1002
	addInlineJavascript('
1003
		$("legend.board_selector").closest("fieldset").hide();
1004
		$("a.board_selector").click(function(e) {
1005
			e.preventDefault();
1006
			$(this).hide().next("fieldset").show();
1007
		});
1008
		$("fieldset legend.board_selector a").click(function(e) {
1009
			e.preventDefault();
1010
			$(this).closest("fieldset").hide().prev("a").show();
1011
		});
1012
	', true);
1013
}
1014
1015
/**
1016
 * Template for showing custom profile fields.
1017
 */
1018
function template_show_custom_profile()
1019
{
1020
	global $context, $txt;
1021
1022
	if (!empty($context['saved_successful']))
1023
		echo '
1024
					<div class="infobox">', $txt['settings_saved'], '</div>';
1025
1026
	// Standard fields.
1027
	template_show_list('standard_profile_fields');
1028
1029
	echo '
1030
					<script>
1031
						var iNumChecks = document.forms.standardProfileFields.length;
1032
						for (var i = 0; i < iNumChecks; i++)
1033
							if (document.forms.standardProfileFields[i].id.indexOf(\'reg_\') == 0)
1034
								document.forms.standardProfileFields[i].disabled = document.forms.standardProfileFields[i].disabled || !document.getElementById(\'active_\' + document.forms.standardProfileFields[i].id.substr(4)).checked;
1035
					</script>
1036
					<br>';
1037
1038
	// Custom fields.
1039
	template_show_list('custom_profile_fields');
1040
}
1041
1042
// Edit a profile field?
1043
function template_edit_profile_field()
1044
{
1045
	global $context, $txt, $scripturl;
1046
1047
	// All the javascript for this page - quite a bit in script.js!
1048
	echo '
1049
					<script>
1050
						var startOptID = ', count($context['field']['options']), ';
1051
					</script>';
1052
1053
	// any errors messages to show?
1054
	if (isset($_GET['msg']))
1055
	{
1056
		loadLanguage('Errors');
1057
1058
		if (isset($txt['custom_option_' . $_GET['msg']]))
1059
			echo '
1060
					<div class="errorbox">',
1061
						$txt['custom_option_' . $_GET['msg']], '
1062
					</div>';
1063
	}
1064
1065
	echo '
1066
						<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'], '">
1067
							<div id="section_header" class="cat_bar">
1068
								<h3 class="catbg">', $context['page_title'], '</h3>
1069
							</div>
1070
							<div class="windowbg">
1071
								<fieldset>
1072
									<legend>', $txt['custom_edit_general'], '</legend>
1073
1074
									<dl class="settings">
1075
										<dt>
1076
											<strong><label for="field_name">', $txt['custom_edit_name'], ':</label></strong>
1077
										</dt>
1078
										<dd>
1079
											<input type="text" name="field_name" id="field_name" value="', $context['field']['name'], '" size="20" maxlength="40">
1080
										</dd>
1081
										<dt>
1082
											<strong><label for="field_desc">', $txt['custom_edit_desc'], ':</label></strong>
1083
										</dt>
1084
										<dd>
1085
											<textarea name="field_desc" id="field_desc" rows="3" cols="40">', $context['field']['desc'], '</textarea>
1086
										</dd>
1087
										<dt>
1088
											<strong><label for="profile_area">', $txt['custom_edit_profile'], ':</label></strong><br>
1089
											<span class="smalltext">', $txt['custom_edit_profile_desc'], '</span>
1090
										</dt>
1091
										<dd>
1092
											<select name="profile_area" id="profile_area">
1093
												<option value="none"', $context['field']['profile_area'] == 'none' ? ' selected' : '', '>', $txt['custom_edit_profile_none'], '</option>
1094
												<option value="account"', $context['field']['profile_area'] == 'account' ? ' selected' : '', '>', $txt['account'], '</option>
1095
												<option value="forumprofile"', $context['field']['profile_area'] == 'forumprofile' ? ' selected' : '', '>', $txt['forumprofile'], '</option>
1096
												<option value="theme"', $context['field']['profile_area'] == 'theme' ? ' selected' : '', '>', $txt['theme'], '</option>
1097
											</select>
1098
										</dd>
1099
										<dt>
1100
											<a id="field_reg_require" href="', $scripturl, '?action=helpadmin;help=field_reg_require" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>
1101
											<strong><label for="reg">', $txt['custom_edit_registration'], ':</label></strong>
1102
										</dt>
1103
										<dd>
1104
											<select name="reg" id="reg">
1105
												<option value="0"', $context['field']['reg'] == 0 ? ' selected' : '', '>', $txt['custom_edit_registration_disable'], '</option>
1106
												<option value="1"', $context['field']['reg'] == 1 ? ' selected' : '', '>', $txt['custom_edit_registration_allow'], '</option>
1107
												<option value="2"', $context['field']['reg'] == 2 ? ' selected' : '', '>', $txt['custom_edit_registration_require'], '</option>
1108
											</select>
1109
										</dd>
1110
										<dt>
1111
											<strong><label for="display">', $txt['custom_edit_display'], ':</label></strong>
1112
										</dt>
1113
										<dd>
1114
											<input type="checkbox" name="display" id="display"', $context['field']['display'] ? ' checked' : '', '>
1115
										</dd>
1116
										<dt>
1117
											<strong><label for="mlist">', $txt['custom_edit_mlist'], ':</label></strong>
1118
										</dt>
1119
										<dd>
1120
											<input type="checkbox" name="mlist" id="show_mlist"', $context['field']['mlist'] ? ' checked' : '', '>
1121
										</dd>
1122
										<dt>
1123
											<strong><label for="placement">', $txt['custom_edit_placement'], ':</label></strong>
1124
										</dt>
1125
										<dd>
1126
											<select name="placement" id="placement">';
1127
1128
	foreach ($context['cust_profile_fields_placement'] as $order => $name)
1129
		echo '
1130
												<option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>';
1131
1132
	echo '
1133
											</select>
1134
										</dd>
1135
										<dt>
1136
											<a id="field_show_enclosed" href="', $scripturl, '?action=helpadmin;help=field_show_enclosed" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>
1137
											<strong><label for="enclose">', $txt['custom_edit_enclose'], ':</label></strong><br>
1138
											<span class="smalltext">', $txt['custom_edit_enclose_desc'], '</span>
1139
										</dt>
1140
										<dd>
1141
											<textarea name="enclose" id="enclose" rows="10" cols="50">', @$context['field']['enclose'], '</textarea>
1142
										</dd>
1143
									</dl>
1144
								</fieldset>
1145
								<fieldset>
1146
									<legend>', $txt['custom_edit_input'], '</legend>
1147
									<dl class="settings">
1148
										<dt>
1149
										<strong><label for="field_type">', $txt['custom_edit_picktype'], ':</label></strong>
1150
										</dt>
1151
										<dd>
1152
											<select name="field_type" id="field_type" onchange="updateInputBoxes();">';
1153
1154
	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type)
1155
		echo '
1156
												<option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>';
1157
1158
	echo '
1159
											</select>
1160
										</dd>
1161
										<dt id="max_length_dt">
1162
											<strong><label for="max_length_dd">', $txt['custom_edit_max_length'], ':</label></strong><br>
1163
											<span class="smalltext">', $txt['custom_edit_max_length_desc'], '</span>
1164
										</dt>
1165
										<dd>
1166
											<input type="text" name="max_length" id="max_length_dd" value="', $context['field']['max_length'], '" size="7" maxlength="6">
1167
										</dd>
1168
										<dt id="dimension_dt">
1169
											<strong><label for="dimension_dd">', $txt['custom_edit_dimension'], ':</label></strong>
1170
										</dt>
1171
										<dd id="dimension_dd">
1172
											<strong>', $txt['custom_edit_dimension_row'], ':</strong> <input type="text" name="rows" value="', $context['field']['rows'], '" size="5" maxlength="3">
1173
											<strong>', $txt['custom_edit_dimension_col'], ':</strong> <input type="text" name="cols" value="', $context['field']['cols'], '" size="5" maxlength="3">
1174
										</dd>
1175
										<dt id="bbc_dt">
1176
											<strong><label for="bbc_dd">', $txt['custom_edit_bbc'], '</label></strong>
1177
										</dt>
1178
										<dd >
1179
											<input type="checkbox" name="bbc" id="bbc_dd"', $context['field']['bbc'] ? ' checked' : '', '>
1180
										</dd>
1181
										<dt id="options_dt">
1182
											<a href="', $scripturl, '?action=helpadmin;help=customoptions" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>
1183
											<strong><label for="options_dd">', $txt['custom_edit_options'], ':</label></strong><br>
1184
											<span class="smalltext">', $txt['custom_edit_options_desc'], '</span>
1185
										</dt>
1186
										<dd id="options_dd">';
1187
1188
	foreach ($context['field']['options'] as $k => $option)
1189
		echo '
1190
											', $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, '">';
1191
1192
	echo '
1193
											<span id="addopt"></span>
1194
											[<a href="" onclick="addOption(); return false;">', $txt['custom_edit_options_more'], '</a>]
1195
										</dd>
1196
										<dt id="default_dt">
1197
											<strong><label for="default_dd">', $txt['custom_edit_default'], ':</label></strong>
1198
										</dt>
1199
										<dd>
1200
											<input type="checkbox" name="default_check" id="default_dd"', $context['field']['default_check'] ? ' checked' : '', '>
1201
										</dd>
1202
									</dl>
1203
								</fieldset>
1204
								<fieldset>
1205
									<legend>', $txt['custom_edit_advanced'], '</legend>
1206
									<dl class="settings">
1207
										<dt id="mask_dt">
1208
											<a id="custom_mask" href="', $scripturl, '?action=helpadmin;help=custom_mask" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>
1209
											<strong><label for="mask">', $txt['custom_edit_mask'], ':</label></strong><br>
1210
											<span class="smalltext">', $txt['custom_edit_mask_desc'], '</span>
1211
										</dt>
1212
										<dd>
1213
											<select name="mask" id="mask" onchange="updateInputBoxes();">
1214
												<option value="nohtml"', $context['field']['mask'] == 'nohtml' ? ' selected' : '', '>', $txt['custom_edit_mask_nohtml'], '</option>
1215
												<option value="email"', $context['field']['mask'] == 'email' ? ' selected' : '', '>', $txt['custom_edit_mask_email'], '</option>
1216
												<option value="number"', $context['field']['mask'] == 'number' ? ' selected' : '', '>', $txt['custom_edit_mask_number'], '</option>
1217
												<option value="regex"', strpos($context['field']['mask'], 'regex') === 0 ? ' selected' : '', '>', $txt['custom_edit_mask_regex'], '</option>
1218
											</select>
1219
											<br>
1220
											<span id="regex_div">
1221
												<input type="text" name="regex" value="', $context['field']['regex'], '" size="30">
1222
											</span>
1223
										</dd>
1224
										<dt>
1225
											<strong><label for="private">', $txt['custom_edit_privacy'], ':</label></strong>
1226
											<span class="smalltext">', $txt['custom_edit_privacy_desc'], '</span>
1227
										</dt>
1228
										<dd>
1229
											<select name="private" id="private" onchange="updateInputBoxes();">
1230
												<option value="0"', $context['field']['private'] == 0 ? ' selected' : '', '>', $txt['custom_edit_privacy_all'], '</option>
1231
												<option value="1"', $context['field']['private'] == 1 ? ' selected' : '', '>', $txt['custom_edit_privacy_see'], '</option>
1232
												<option value="2"', $context['field']['private'] == 2 ? ' selected' : '', '>', $txt['custom_edit_privacy_owner'], '</option>
1233
												<option value="3"', $context['field']['private'] == 3 ? ' selected' : '', '>', $txt['custom_edit_privacy_none'], '</option>
1234
											</select>
1235
										</dd>
1236
										<dt id="can_search_dt">
1237
											<strong><label for="can_search_dd">', $txt['custom_edit_can_search'], ':</label></strong><br>
1238
											<span class="smalltext">', $txt['custom_edit_can_search_desc'], '</span>
1239
										</dt>
1240
										<dd>
1241
											<input type="checkbox" name="can_search" id="can_search_dd"', $context['field']['can_search'] ? ' checked' : '', '>
1242
										</dd>
1243
										<dt>
1244
											<strong><label for="can_search_check">', $txt['custom_edit_active'], ':</label></strong><br>
1245
											<span class="smalltext">', $txt['custom_edit_active_desc'], '</span>
1246
										</dt>
1247
										<dd>
1248
											<input type="checkbox" name="active" id="can_search_check"', $context['field']['active'] ? ' checked' : '', '>
1249
										</dd>
1250
									</dl>
1251
								</fieldset>
1252
								<input type="submit" name="save" value="', $txt['save'], '" class="button">';
1253
1254
	if ($context['fid'])
1255
		echo '
1256
								<input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">';
1257
1258
	echo '
1259
							</div><!-- .windowbg -->
1260
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1261
							<input type="hidden" name="', $context['admin-ecp_token_var'], '" value="', $context['admin-ecp_token'], '">
1262
						</form>';
1263
1264
	// Get the javascript bits right!
1265
	echo '
1266
					<script>
1267
						updateInputBoxes();
1268
					</script>';
1269
}
1270
1271
/**
1272
 * Results page for an admin search.
1273
 */
1274
function template_admin_search_results()
1275
{
1276
	global $context, $txt, $scripturl;
1277
1278
	echo '
1279
						<div id="section_header" class="cat_bar">
1280
							<form action="', $scripturl, '?action=admin;area=search" method="post" accept-charset="', $context['character_set'], '">
1281
								<h3 class="catbg">
1282
									<span id="quick_search" class="floatright">
1283
										<input type="search" name="search_term" value="', $context['search_term'], '">
1284
										<input type="hidden" name="search_type" value="', $context['search_type'], '">
1285
										<input type="submit" name="search_go" value="', $txt['admin_search_results_again'], '" class="button">
1286
									</span>
1287
									<span class="generic_icons filter"></span>
1288
									<span id="quick_search_results">
1289
										', sprintf($txt['admin_search_results_desc'], $context['search_term']), '
1290
									</span>
1291
								</h3>
1292
							</form>
1293
						</div><!-- #section_header -->
1294
						<div class="windowbg generic_list_wrapper">';
1295
1296
	if (empty($context['search_results']))
1297
	{
1298
		echo '
1299
							<p class="centertext">
1300
								<strong>', $txt['admin_search_results_none'], '</strong>
1301
							</p>';
1302
	}
1303
	else
1304
	{
1305
		echo '
1306
							<ol class="search_results">';
1307
1308
		foreach ($context['search_results'] as $result)
1309
		{
1310
			// Is it a result from the online manual?
1311
			if ($context['search_type'] == 'online')
1312
			{
1313
				echo '
1314
								<li>
1315
									<p>
1316
										<a href="', $context['doc_scripturl'], str_replace(' ', '_', $result['title']), '" target="_blank" rel="noopener"><strong>', $result['title'], '</strong></a>
1317
									</p>
1318
									<p class="double_height">
1319
										', $result['snippet'], '
1320
									</p>
1321
								</li>';
1322
			}
1323
			// Otherwise it's... not!
1324
			else
1325
			{
1326
				echo '
1327
								<li>
1328
									<a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']';
1329
1330
				if ($result['help'])
1331
					echo '
1332
									<p class="double_height">', $result['help'], '</p>';
1333
1334
				echo '
1335
								</li>';
1336
			}
1337
		}
1338
		echo '
1339
							</ol>';
1340
	}
1341
1342
	echo '
1343
						</div><!-- .generic_list_wrapper -->';
1344
}
1345
1346
/**
1347
 * This little beauty shows questions and answer from the captcha type feature.
1348
 */
1349
function template_callback_question_answer_list()
1350
{
1351
	global $txt, $context;
1352
1353
	foreach ($context['languages'] as $lang_id => $lang)
1354
	{
1355
		$lang_id = strtr($lang_id, array('-utf8' => ''));
1356
		$lang['name'] = strtr($lang['name'], array('-utf8' => ''));
1357
1358
		echo '
1359
						<dt id="qa_dt_', $lang_id, '" class="qa_link">
1360
							<a href="javascript:void(0);">[ ', $lang['name'], ' ]</a>
1361
						</dt>
1362
						<fieldset id="qa_fs_', $lang_id, '" class="qa_fieldset">
1363
							<legend><a href="javascript:void(0);">', $lang['name'], '</a></legend>
1364
							<dl class="settings">
1365
								<dt>
1366
									<strong>', $txt['setup_verification_question'], '</strong>
1367
								</dt>
1368
								<dd>
1369
									<strong>', $txt['setup_verification_answer'], '</strong>
1370
								</dd>';
1371
1372
		if (!empty($context['qa_by_lang'][$lang_id]))
1373
			foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1374
			{
1375
				$question = $context['question_answers'][$q_id];
1376
1377
				echo '
1378
								<dt>
1379
									<input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="verification_question">
1380
								</dt>
1381
								<dd>';
1382
1383
				foreach ($question['answers'] as $answer)
1384
					echo '
1385
									<input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">';
1386
1387
				echo '
1388
									<div class="qa_add_answer"><a href="javascript:void(0);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div>
1389
								</dd>';
1390
			}
1391
1392
		echo '
1393
								<dt class="qa_add_question"><a href="javascript:void(0);">[ ', $txt['setup_verification_add_more'], ' ]</a></dt>
1394
							</dl>
1395
						</fieldset>';
1396
	}
1397
}
1398
1399
/**
1400
 * Repairing boards.
1401
 */
1402
function template_repair_boards()
1403
{
1404
	global $context, $txt, $scripturl;
1405
1406
	echo '
1407
						<div id="section_header" class="cat_bar">
1408
							<h3 class="catbg">',
1409
								$context['error_search'] ? $txt['errors_list'] : $txt['errors_fixing'], '
1410
							</h3>
1411
						</div>
1412
						<div class="windowbg">';
1413
1414
	// Are we actually fixing them, or is this just a prompt?
1415
	if ($context['error_search'])
1416
	{
1417
		if (!empty($context['to_fix']))
1418
		{
1419
			echo '
1420
							', $txt['errors_found'], ':
1421
							<ul>';
1422
1423
			foreach ($context['repair_errors'] as $error)
1424
				echo '
1425
								<li>
1426
									', $error, '
1427
								</li>';
1428
1429
			echo '
1430
							</ul>
1431
							<p>
1432
								', $txt['errors_fix'], '
1433
							</p>
1434
							<p class="padding">
1435
								<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>
1436
							</p>';
1437
		}
1438
		else
1439
			echo '
1440
							<p>', $txt['maintain_no_errors'], '</p>
1441
							<p class="padding">
1442
								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1443
							</p>';
1444
	}
1445
	else
1446
	{
1447
		if (!empty($context['redirect_to_recount']))
1448
		{
1449
			echo '
1450
							<p>
1451
								', $txt['errors_do_recount'], '
1452
							</p>
1453
							<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=recount" id="recount_form" method="post">
1454
								<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
1455
								<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1456
								<input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '">
1457
							</form>';
1458
		}
1459
		else
1460
		{
1461
			echo '
1462
							<p>', $txt['errors_fixed'], '</p>
1463
							<p class="padding">
1464
								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1465
							</p>';
1466
		}
1467
	}
1468
1469
	echo '
1470
						</div><!-- .windowbg -->';
1471
1472
	if (!empty($context['redirect_to_recount']))
1473
	{
1474
		echo '
1475
					<script>
1476
						var countdown = 5;
1477
						doAutoSubmit();
1478
1479
						function doAutoSubmit()
1480
						{
1481
							if (countdown == 0)
1482
								document.forms.recount_form.submit();
1483
							else if (countdown == -1)
1484
								return;
1485
1486
							document.forms.recount_form.recount_now.value = "', $txt['errors_recount_now'], ' (" + countdown + ")";
1487
							countdown--;
1488
1489
							setTimeout("doAutoSubmit();", 1000);
1490
						}
1491
					</script>';
1492
	}
1493
}
1494
1495
/**
1496
 * Retrieves info from the php_info function, scrubs and preps it for display
1497
 */
1498
function template_php_info()
1499
{
1500
	global $context, $txt;
1501
1502
	echo '
1503
					<div id="admin_form_wrapper">
1504
						<div id="section_header" class="cat_bar">
1505
							<h3 class="catbg">
1506
								', $txt['phpinfo_settings'], '
1507
							</h3>
1508
						</div>';
1509
1510
	// for each php info area
1511
	foreach ($context['pinfo'] as $area => $php_area)
1512
	{
1513
		echo '
1514
						<table id="', str_replace(' ', '_', $area), '" class="table_grid">
1515
							<thead>
1516
								<tr class="title_bar">
1517
									<th class="equal_table" scope="col"></th>
1518
									<th class="centercol equal_table" scope="col"><strong>', $area, '</strong></th>
1519
									<th class="equal_table" scope="col"></th>
1520
								</tr>
1521
							</thead>
1522
							<tbody>';
1523
1524
		$localmaster = true;
1525
1526
		// and for each setting in this category
1527
		foreach ($php_area as $key => $setting)
1528
		{
1529
			// start of a local / master setting (3 col)
1530
			if (is_array($setting))
1531
			{
1532
				if ($localmaster)
1533
				{
1534
					// heading row for the settings section of this categorys settings
1535
					echo '
1536
								<tr class="title_bar">
1537
									<td class="equal_table"><strong>', $txt['phpinfo_itemsettings'], '</strong></td>
1538
									<td class="equal_table"><strong>', $txt['phpinfo_localsettings'], '</strong></td>
1539
									<td class="equal_table"><strong>', $txt['phpinfo_defaultsettings'], '</strong></td>
1540
								</tr>';
1541
1542
					$localmaster = false;
1543
				}
1544
1545
				echo '
1546
								<tr class="windowbg">
1547
									<td class="equal_table">', $key, '</td>';
1548
1549
				foreach ($setting as $key_lm => $value)
1550
					echo '
1551
									<td class="equal_table">', $value, '</td>';
1552
1553
				echo '
1554
								</tr>';
1555
			}
1556
			// just a single setting (2 col)
1557
			else
1558
			{
1559
				echo '
1560
								<tr class="windowbg">
1561
									<td class="equal_table">', $key, '</td>
1562
									<td colspan="2">', $setting, '</td>
1563
								</tr>';
1564
			}
1565
		}
1566
		echo '
1567
							</tbody>
1568
						</table>
1569
						<br>';
1570
	}
1571
1572
	echo '
1573
					</div><!-- #admin_form_wrapper -->';
1574
}
1575
1576
/**
1577
 *
1578
 */
1579
function template_clean_cache_button_above()
1580
{
1581
}
1582
1583
/**
1584
 * Content shown below the clean cache button?
1585
 */
1586
function template_clean_cache_button_below()
1587
{
1588
	global $txt, $scripturl, $context;
1589
1590
	echo '
1591
					<div class="cat_bar">
1592
						<h3 class="catbg">', $txt['maintain_cache'], '</h3>
1593
					</div>
1594
					<div class="windowbg">
1595
						<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=cleancache" method="post" accept-charset="', $context['character_set'], '">
1596
							<p>', $txt['maintain_cache_info'], '</p>
1597
							<span><input type="submit" value="', $txt['maintain_run_now'], '" class="button"></span>
1598
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1599
							<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
1600
						</form>
1601
					</div>';
1602
}
1603
1604
/**
1605
 * This shows the admin search form
1606
 */
1607
function template_admin_quick_search()
1608
{
1609
	global $context, $txt;
1610
1611
	if ($context['user']['is_admin'])
1612
		echo '
1613
								<span class="floatright admin_search">
1614
									<span class="generic_icons filter centericon"></span>
1615
									<input type="search" name="search_term" placeholder="', $txt['admin_search'], '">
1616
									<select name="search_type">
1617
										<option value="internal"', (empty($context['admin_preferences']['sb']) || $context['admin_preferences']['sb'] == 'internal' ? ' selected' : ''), '>', $txt['admin_search_type_internal'], '</option>
1618
										<option value="member"', (!empty($context['admin_preferences']['sb']) && $context['admin_preferences']['sb'] == 'member' ? ' selected' : ''), '>', $txt['admin_search_type_member'], '</option>
1619
										<option value="online"', (!empty($context['admin_preferences']['sb']) && $context['admin_preferences']['sb'] == 'online' ? ' selected' : ''), '>', $txt['admin_search_type_online'], '</option>
1620
									</select>
1621
									<input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button">
1622
								</span>';
1623
}
1624
1625
/**
1626
 * This shows the policy settings
1627
 */
1628
function template_edit_policy()
1629
{
1630
	global $context, $scripturl, $txt, $modSettings;
1631
1632
	if (!empty($context['saved_successful']))
1633
		echo '
1634
					<div class="infobox">', $txt['settings_saved'], '</div>';
1635
1636
	echo '
1637
					<div id="admincenter">
1638
						<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=featuresettings;sa=policy;save" method="post" accept-charset="', $context['character_set'], '">
1639
							<div id="section_header" class="cat_bar">
1640
								<h3 class="catbg">
1641
									', $txt['policy_management'], '
1642
								</h3>
1643
							</div>
1644
							<div class="windowbg">
1645
								<dl class="settings">
1646
									<dt>
1647
										<label for="enable_policy_function">', $txt['policy_enable'], ':</label>
1648
									</dt>
1649
									<dd>
1650
										<input type="checkbox" name="enable_policy_function" value="1" id="enable_policy_function"', empty($modSettings['enable_policy_function']) ? '' : ' checked', '>
1651
									</dd>
1652
								</dl>
1653
								<input type="submit" name="save_setting" value="', $txt['save'], '" class="button">
1654
								<div class="block">
1655
									',template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message') ,'
0 ignored issues
show
Bug introduced by
Are you sure the usage of template_control_richedi...age', 'bbcBox_message') is correct as it seems to always return null.

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

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

}

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

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

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

Loading history...
Bug introduced by
'bbcBox_message' of type string is incompatible with the type boolean|null expected by parameter $bbcContainer of template_control_richedit(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1655
									',template_control_richedit($context['post_box_name'], 'smileyBox_message', /** @scrutinizer ignore-type */ 'bbcBox_message') ,'
Loading history...
Bug introduced by
'smileyBox_message' of type string is incompatible with the type boolean|null expected by parameter $smileyContainer of template_control_richedit(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1655
									',template_control_richedit($context['post_box_name'], /** @scrutinizer ignore-type */ 'smileyBox_message', 'bbcBox_message') ,'
Loading history...
1656
								</div>
1657
								<input type="submit" name="save_new_policy" value="', $txt['policy_save'], '" class="button">
1658
								<input type="submit" name="update_policy" value="', $txt['policy_update'], '" class="button">								
1659
							</div><!-- .windowbg -->
1660
							<div class="cat_bar">
1661
								<h3 class="catbg">
1662
									', $txt['policy_overview'], '
1663
								</h3>
1664
							</div>
1665
							<div class="windowbg">
1666
								<dl class="settings">
1667
									<dt>
1668
										<label for="policy_not_approvals">',$txt['policy_not_approvals'], ':<label>
1669
									</dt>
1670
									<dd>
1671
										<input name="policy_not_approvals" id="policy_not_approvals" readonly value="', $context['policy']['invalid'], '">
1672
									</dd>
1673
									<dt>
1674
										<label for="policy_old_approvals">',$txt['policy_old_approvals'], ':<label>
1675
									</dt>
1676
									<dd>
1677
										<input name="policy_old_approvals" id="policy_old_approvals" readonly value="', $context['policy']['outdated'], '">
1678
									</dd>
1679
									<dt>
1680
										<label for="policy_fresh_approvals">',$txt['policy_fresh_approvals'], ':<label>
1681
									</dt>
1682
									<dd>
1683
										<input name="policy_fresh_approvals" id="policy_fresh_approvals" readonly value="', $context['policy']['fresh'], '">
1684
									</dd>
1685
								</dl>
1686
								<input type="submit" name="enforce_new" value="', $txt['policy_remove_old'], '" class="button">
1687
							</div><!-- .windowbg -->
1688
1689
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1690
							<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">
1691
						</form>
1692
						<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=featuresettings;sa=policy;manage" method="post" accept-charset="', $context['character_set'], '">
1693
							<div id="section_header" class="cat_bar">
1694
								<h3 class="catbg">
1695
									', $txt['policy_management'], '
1696
								</h3>
1697
							</div>
1698
							<div class="windowbg">
1699
								<dl class="settings">';
1700
1701
	foreach ((array) $context['poc']['policy_management'] as $row)
1702
	{
1703
		echo '
1704
									<dt>', ($row['new'] ? $txt['policy_current'] : '<input type="submit" name="delete_policy" value="' . $row['name'] . '" class="button">') , '</dt><dd>', $row['amount'], '</dd>';
1705
	}
1706
	echo '
1707
								</dl>
1708
							</div>
1709
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1710
						<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">
1711
						</form>
1712
					</div><!-- #admincenter -->';
1713
}
1714
1715
?>