Issues (1686)

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

Labels
Severity
1
<?php
2
3
/**
4
 * @package   ElkArte Forum
5
 * @copyright ElkArte Forum contributors
6
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file)
7
 *
8
 * This file contains code covered by:
9
 * copyright: 2011 Simple Machines (http://www.simplemachines.org)
10
 *
11
 * @version 2.0 dev
12
 *
13
 */
14
15
/**
16
 * This is the administration center home.
17
 */
18
function template_admin()
19
{
20
	global $context, $settings, $txt;
21
22
	// Welcome message for the admin.
23
	echo '
24
		<div id="admincenter">';
25
26
	// Is there an update available?
27
	echo '
28
			<div id="update_section"></div>';
29
30
	echo '
31
			<div id="admin_main_section">';
32
33
	// Display the "live news"
34
	echo '
35
				<div id="live_news" class="floatleft">
36
					<h2 class="category_header">
37
						<a href="', getUrl('action', ['action' => 'quickhelp', 'help' => 'live_news']), '" onclick="return reqOverlayDiv(this.href);" class="hdicon i-help help"></a>', $txt['live'], '
38
					</h2>
39
					<div class="content">
40
						<div id="ourAnnouncements">', $txt['lfyi'], '</div>
41
					</div>
42
				</div>';
43
44
	// Show the user version information from their server.
45
	echo '
46
				<div id="supportVersionsTable" class="floatright">
47
					<h2 class="category_header">
48
						<a class="hdicon i-user-plus" href="', getUrl('admin', ['action' => 'admin', 'area' => 'credits']), '">', $txt['support_title'], '</a>
49
					</h2>
50
						<div class="content">
51
						<div id="version_details">
52
							<strong>', $txt['support_versions'], ':</strong><br />
53
							', $txt['support_versions_forum'], ':
54
							<em id="installedVersion">', $context['forum_version'], '</em><br />
55
							', $txt['support_versions_current'], ':
56
							<em id="latestVersion">??</em><br />';
57
58
	// Display all the members who can administrate the forum.
59
	echo '
60
							<br />
61
							<strong>', $txt['administrators'], ':</strong>
62
							', implode(', ', $context['administrators']);
63
64
	// If we have lots of admins... don't show them all.
65
	if (!empty($context['more_admins_link']))
66
	{
67
		echo '
68
							(', $context['more_admins_link'], ')';
69
	}
70
71
	echo '
72
						</div>
73
					</div>
74
				</div>
75
			</div>';
76
77
	echo '
78
			<div class="quick_tasks">
79
				<ul id="quick_tasks" class="flow_hidden">';
80
81
	foreach ($context['quick_admin_tasks'] as $task)
82
	{
83
		echo '
84
					<li>
85
						', empty($task['icon']) ? '' : '<a href="' . $task['href'] . '"><img src="' . $settings['default_images_url'] . '/admin/' . $task['icon'] . '" alt="" class="home_image" /></a>', '
86
						<h5>', $task['link'], '</h5>
87
						<span class="task">', $task['description'], '</span>
88
					</li>';
89
	}
90
91
	echo '
92
				</ul>
93
			</div>
94
		</div>';
95
96
	// This sets the announcements and current versions themselves ;).
97
	echo '
98
		<script>
99
			var oAdminCenter = new Elk_AdminIndex({
100
				bLoadAnnouncements: true,
101
				sAnnouncementTemplate: ', JavaScriptEscape('
102
					<dl>
103
						%content%
104
					</dl>
105
				'), ',
106
				sAnnouncementMessageTemplate: ', JavaScriptEscape('
107
					<dt><a href="%href%">%subject%</a> ' . $txt['on'] . ' %time%</dt>
108
					<dd>
109
						%message%
110
					</dd>
111
				'), ',
112
				sAnnouncementContainerId: \'ourAnnouncements\',
113
114
				bLoadVersions: true,
115
				slatestVersionContainerId: \'latestVersion\',
116
				sinstalledVersionContainerId: \'installedVersion\',
117
				sVersionOutdatedTemplate: ', JavaScriptEscape('
118
					<span class="alert">%currentVersion%</span>
119
				'), ',
120
121
				bLoadUpdateNotification: true,
122
				sUpdateNotificationContainerId: \'update_section\',
123
				sUpdateNotificationDefaultTitle: ', JavaScriptEscape($txt['update_available']), ',
124
				sUpdateNotificationDefaultMessage: ', JavaScriptEscape($txt['update_message']), ',
125
				sUpdateNotificationTemplate: ', JavaScriptEscape('
126
						<h3 id="update_title" class="category_header">
127
							%title%
128
						</h3>
129
						<div class="content">
130
							<div id="update_message" class="smalltext">
131
								%message%
132
							</div>
133
						</div>
134
				'), ',
135
				sUpdateNotificationLink: elk_scripturl + ', JavaScriptEscape('?action=admin;area=packageservers;sa=download;auto;package=%package%;' . $context['session_var'] . '=' . $context['session_id']), '
136
137
			});
138
		</script>';
139
}
140
141
/**
142
 * Show some support information and credits to those who helped make this.
143
 */
144
function template_credits()
145
{
146
	global $context, $settings, $txt;
147
148
	// Show the user version information from their server.
149
	echo '
150
					<div id="admincenter">
151
						<div id="support_credits">
152
							<h2 class="category_header">
153
								', $txt['support_title'], ' <img id="credits_logo" src="', $settings['images_url'], '/', $context['theme_variant_url'], 'logo_elk.png" alt="" />
154
							</h2>
155
							<div class="content">
156
								<strong>', $txt['support_versions'], ':</strong><br />
157
									', $txt['support_versions_forum'], ':
158
								<em id="installedVersion">', $context['forum_version'], '</em><br />
159
									', $txt['support_versions_current'], ':
160
								<em id="latestVersion">??</em><br />';
161
162
	// Display all the variables we have server information for.
163
	foreach ($context['current_versions'] as $version)
164
	{
165
		if (isset($version['header']))
166
		{
167
			echo '
168
								<h3><strong>' . $version['header'] . ':</strong></h3>';
169
			continue;
170
		}
171
172
		echo '
173
									', $version['title'], ':
174
								<em>', $version['version'], '</em>';
175
176
		// More details for this item, show them a link
177
		if ($context['can_admin'] && isset($version['more']))
178
		{
179
			echo
180
			' <a class="linkbutton" href="', getUrl('admin', ['action' => 'admin', 'area' => 'serversettings', 'sa' => 'phpinfo', '{session_data}']), '">', $txt['version_check_more'], '</a>';
181
		}
182
183
		echo '
184
								<br />';
185
	}
186
187
	echo '
188
							</div>';
189
190
	// Display latest important updates
191
	if (!empty($context['latest_updates']))
192
	{
193
		echo '
194
							<h3 id="latest_updates" class="category_header">
195
								', $txt['latest_updates'], '
196
							</h3>
197
							<div class="content">
198
								', $context['latest_updates'], '
199
							</div>';
200
	}
201
202
	// Point the admin to common support resources.
203
	echo '
204
							<div id="support_resources">
205
								<h2 class="category_header">
206
									', $txt['support_resources'], '
207
								</h2>
208
							</div>
209
							<div class="content">
210
								<p>', $txt['support_resources_p1'], '</p>
211
								<p>', $txt['support_resources_p2'], '</p>
212
							</div>';
213
214
	// The most important part - the credits :P.
215
	echo '
216
							<div id="credits_sections">
217
								<h2 class="category_header">
218
									', $txt['admin_credits'], '
219
								</h2>
220
							</div>
221
							<div class="content">';
222
223
	foreach ($context['credits'] as $section)
224
	{
225
		if (isset($section['pretext']))
226
		{
227
			echo '
228
								<p>', $section['pretext'], '</p><hr />';
229
		}
230
231
		echo '
232
								<dl>';
233
234
		foreach ($section['groups'] as $group)
235
		{
236
			if (isset($group['title']))
237
			{
238
				echo '
239
									<dt>
240
										<strong>', $group['title'], ':</strong>
241
									</dt>';
242
			}
243
244
			echo '
245
									<dd>', implode(', ', $group['members']), '</dd>';
246
		}
247
248
		echo '
249
								</dl>';
250
251
		if (isset($section['posttext']))
252
		{
253
			echo '
254
								<hr />
255
								<p>', $section['posttext'], '</p>';
256
		}
257
	}
258
259
	echo '
260
							</div>
261
						</div>
262
					</div>';
263
264
	// This makes all the support information available to the support script...
265
	echo '
266
					<script>
267
						let ourSupportVersions = {};
268
269
						ourSupportVersions.forum = "', $context['forum_version'], '";';
270
271
	// Don't worry, none of this is logged, it's just used to give information that might be of use.
272
	foreach ($context['current_versions'] as $variable => $version)
273
	{
274
		// Skip headers
275
		if (empty($version['version']))
276
		{
277
			continue;
278
		}
279
280
		echo '
281
						ourSupportVersions.', $variable, ' = "', $version['version'], '";';
282
	}
283
284
	echo '
285
					</script>';
286
287
	// This sets the latest support stuff.
288
	echo '
289
					<script>
290
						var oAdminCenter = new Elk_AdminIndex({
291
							bLoadVersions: true,
292
							slatestVersionContainerId: \'latestVersion\',
293
							sinstalledVersionContainerId: \'installedVersion\',
294
							sVersionOutdatedTemplate: ', JavaScriptEscape('
295
								<span class="alert">%currentVersion%</span>
296
							'), '
297
298
						});
299
					</script>';
300
}
301
302
/**
303
 * Form for stopping people using naughty words, etc.
304
 */
305
function template_edit_censored()
306
{
307
	global $context, $txt, $modSettings;
308
309
	// First section is for adding/removing words from the censored list.
310
	echo '
311
	<div id="admincenter" class="admincenter">
312
		<form id="admin_form_wrapper" action="', getUrl('action', ['action'=>'admin', 'area'=>'postsettings', 'sa'=>'censor']), '" method="post" accept-charset="UTF-8">
313
			<h2 class="category_header">
314
				', $txt['admin_censored_words'], '
315
			</h2>
316
			<div class="content">
317
				<div class="information">', $txt['admin_censored_where'], '</div>';
318
319
	// Show text boxes for censoring [bad] => [good].
320
	foreach ($context['censored_words'] as $vulgar => $proper)
321
	{
322
		echo '
323
				<div class="censorWords">
324
					<input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30" /> <i class="icon i-chevron-circle-right"></i>
325
 					<input type="text" name="censor_proper[]" value="', $proper, '" size="30" />
326
				</div>';
327
	}
328
329
	// Now provide a way to censor more words.
330
	echo '
331
				<div class="censorWords">
332
					<input type="text" name="censor_vulgar[]" size="30" class="input_text" />
333
					 <i class="icon i-chevron-circle-right"></i>
334
					 <input type="text" name="censor_proper[]" size="30" class="input_text" />
335
				</div>
336
				<div id="moreCensoredWords"></div>
337
				<div class="censorWords hide" id="moreCensoredWords_link">
338
					<a class="linkbutton floatleft" href="#" onclick="addNewWord(); return false;">', $txt['censor_clickadd'], '</a><br />
339
				</div>
340
				<script>
341
					document.getElementById("moreCensoredWords_link").style.display = "block";
342
				</script>
343
				<hr class="clear" />
344
				<dl class="settings">
345
					<dt>
346
						<label for="censorWholeWord_check">', $txt['censor_whole_words'], '</label>
347
					</dt>
348
					<dd>
349
						<input type="checkbox" name="censorWholeWord" value="1" id="censorWholeWord_check"', empty($modSettings['censorWholeWord']) ? '' : ' checked="checked"', ' />
350
					</dd>
351
					<dt>
352
						<label for="censorIgnoreCase_check">', $txt['censor_case'], '</label>
353
					</dt>
354
					<dd>
355
						<input type="checkbox" name="censorIgnoreCase" value="1" id="censorIgnoreCase_check"', empty($modSettings['censorIgnoreCase']) ? '' : ' checked="checked"', ' />
356
					</dd>
357
					<dt>
358
						<a href="' . getUrl('action', ['action' => 'quickhelp', 'help' => 'allow_no_censored']), '" onclick="return reqOverlayDiv(this.href);" class="helpicon i-help"><s>' . $txt['help'] . '</s></a><label for="allow_no_censored">', $txt['censor_allow'], '</label>
359
					</dt>
360
					<dd>
361
						<input type="checkbox" name="allow_no_censored" value="1" id="allow_no_censored"', empty($modSettings['allow_no_censored']) ? '' : ' checked="checked"', ' />
362
					</dd>
363
				</dl>
364
				<div class="submitbutton">
365
					<input type="submit" name="save_censor" value="', $txt['save'], '" />
366
				</div>
367
			</div>
368
			<br />';
369
370
	// This lets you test out your filters by typing in rude words and seeing what comes out.
371
	echo '
372
			<h2 class="category_header">', $txt['censor_test'], '</h2>
373
			<div class="content">
374
				<div class="centertext">
375
					<p id="censor_result" class="information hide">', empty($context['censor_test']) ? '' : $context['censor_test'], '</p>
376
					<input id="censortest" type="text" name="censortest" value="', empty($context['censor_test']) ? '' : $context['censor_test'], '" class="input_text" />
377
					<input id="preview_button" type="submit" value="', $txt['censor_test_save'], '" />
378
				</div>
379
			</div>
380
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
381
			<input id="token" type="hidden" name="', $context['admin-censor_token_var'], '" value="', $context['admin-censor_token'], '" />
382
		</form>
383
	</div>
384
	<script>
385
		document.addEventListener("DOMContentLoaded", function() {
386
		    document.getElementById("preview_button").addEventListener("click", function() {
387
		        return ajax_getCensorPreview();
388
		    });
389
		});
390
	</script>';
391
}
392
393
/**
394
 * Template to show that a task is in progress (not done yet).
395
 * Maintenance is a lovely thing, isn't it?
396
 */
397
function template_not_done()
398
{
399
	global $context, $txt, $scripturl;
400
401
	echo '
402
	<div id="admincenter">
403
		<h2 class="category_header">', empty($context['not_done_title']) ? $txt['not_done_title'] : $context['not_done_title'], '</h2>
404
		<div class="content">
405
			<div class="infobox">
406
				', $txt['not_done_reason'], '
407
			</div>
408
			<form id="autoSubmit" name="autoSubmit" action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="UTF-8" >';
409
410
	// Show the progress bars
411
	if (!empty($context['continue_percent']))
412
	{
413
		echo '
414
				<div class="progress_bar">
415
					<div class="green_percent" style="width: ', $context['continue_percent'], '%;">', $context['continue_percent'], '%</div>
416
				</div>';
417
	}
418
419
	if (!empty($context['substep_enabled']))
420
	{
421
		echo '
422
				<div class="progress_bar">
423
					<div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;">', $context['substep_title'], ' - ', $context['substep_continue_percent'], '%</div>
424
				</div>';
425
	}
426
427
	echo '
428
				<input type="submit" name="cont" value="', $txt['not_done_continue'], '" class="right_submit" />
429
				', $context['continue_post_data'];
430
	if (!empty($context['admin-maint_token_var']))
431
	{
432
		echo '
433
				<input type="hidden" name="' . $context['admin-maint_token_var'] . '" value="' . $context['admin-maint_token'] . '" />';
434
	}
435
436
	echo '
437
			</form>
438
		</div>
439
	</div>
440
	<script>
441
		doAutoSubmit(', $context['continue_countdown'], ', ', JavaScriptEscape($txt['not_done_continue']), ');
442
	</script>';
443
}
444
445
/**
446
 * Template for showing settings (Of any kind really!)
447
 */
448
function template_show_settings()
449
{
450
	global $context, $txt;
451
452
	echo '
453
	<div id="', $context['current_subaction'] ?? 'admincenter', '" class="admincenter">
454
		<form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="UTF-8"', empty($context['force_form_onsubmit']) ? '' : ' onsubmit="' . $context['force_form_onsubmit'] . '"', '>';
455
456
	// Is there a custom title, maybe even with an icon?
457
	if (isset($context['settings_title']))
458
	{
459
		echo '
460
			<h2 class="category_header', empty($context['settings_icon']) ? '' : ' hdicon ' . $context['settings_icon'], '">', $context['settings_title'], '</h2>';
461
	}
462
463
	// any messages or errors to show?
464
	if (!empty($context['settings_message']))
465
	{
466
		if (!is_array($context['settings_message']))
467
		{
468
			$context['settings_message'] = array($context['settings_message']);
469
		}
470
471
		echo '
472
			<div class="', (empty($context['error_type']) ? 'infobox' : ($context['error_type'] !== 'serious' ? 'warningbox' : 'errorbox')), '" id="errors">
473
				<ul>
474
					<li>', implode('</li><li>', $context['settings_message']), '</li>
475
				</ul>
476
			</div>';
477
	}
478
479
	// Now actually loop through all the variables.
480
	$is_open = false;
481
	foreach ($context['config_vars'] as $config_var)
482
	{
483
		// Is it a title or a description?
484
		if (is_array($config_var) && ($config_var['type'] === 'title' || $config_var['type'] === 'desc'))
485
		{
486
			// Not a list yet?
487
			if ($is_open)
488
			{
489
				$is_open = false;
490
				echo '
491
					</dl>
492
				</div>';
493
			}
494
495
			// A title, maybe even with an icon or a help icon?
496
			if ($config_var['type'] === 'title')
497
			{
498
				echo
499
				(isset($config_var['name']) ? '<a href="#" id="' . $config_var['name'] . '"></a>' : ''), '
500
					<h3 class="', empty($config_var['class']) ? 'category_header' : $config_var['class'], '"', empty($config_var['force_div_id']) ? '' : ' id="' . $config_var['force_div_id'] . '"', '>';
501
502
				if (isset($config_var['helptext']))
503
				{
504
					if (empty($config_var['class']))
505
					{
506
						echo '
507
						<a href="' . getUrl('action', ['action' => 'quickhelp', 'help' => $config_var['helptext']]) . '" onclick="return reqOverlayDiv(this.href);" class="hdicon i-help help" title="' . $txt['help'] . '"></a>';
508
					}
509
					else
510
					{
511
						echo '
512
						<a href="' . getUrl('action', ['action' => 'quickhelp', 'help' => $config_var['helptext']]) . '" onclick="return reqOverlayDiv(this.href);" class="' . $config_var['class'] . ' help"><i class="helpicon i-help icon-lg"><s>', $txt['help'], '</s></i></a>';
513
					}
514
				}
515
				elseif (isset($config_var['icon']))
516
				{
517
					echo
518
						'<span class="hdicon ' . $config_var['icon'] . '"></span>';
519
				}
520
521
				echo
522
				$config_var['label'], '
523
					</h3>';
524
			}
525
			// A description?
526
			else
527
			{
528
				echo '
529
					<div class="description">
530
						', $config_var['label'], '
531
					</div>';
532
			}
533
534
			continue;
535
		}
536
537
		// Not a list yet?
538
		if (!$is_open)
539
		{
540
			$is_open = true;
541
			echo '
542
			<div class="content">
543
				<dl class="settings">';
544
		}
545
546
		// Hang about? Are you pulling my leg - a callback?!
547
		if (is_array($config_var) && $config_var['type'] === 'callback')
548
		{
549
			if (function_exists('template_callback_' . $config_var['name']))
550
			{
551
				call_user_func('template_callback_' . $config_var['name']);
552
			}
553
554
			continue;
555
		}
556
557
		if (is_array($config_var))
558
		{
559
			// First off, is this a span like a message?
560
			if (in_array($config_var['type'], array('message', 'warning')))
561
			{
562
				echo '
563
					<dt></dt>
564
					<dd', $config_var['type'] === 'warning' ? ' class="alert"' : '', (empty($config_var['force_div_id']) ? '' : ' id="' . $config_var['force_div_id'] . '_dd"'), '>
565
						', $config_var['label'], '
566
					</dd>';
567
			}
568
			// Otherwise it's an input box of some kind.
569
			else
570
			{
571
				echo '
572
					<dt', !empty($config_var['force_div_id']) ? ' id="' . $config_var['force_div_id'] . '"' : '', '>';
573
574
				// Some quick helpers...
575
				$preinput = empty($config_var['preinput']) ? '' : $config_var['preinput'];
576
				$javascript = empty($config_var['javascript']) ? '' : $config_var['javascript'];
577
				$disabled = empty($config_var['disabled']) ? '' : ' disabled="disabled"';
578
				$invalid = empty($config_var['invalid']) ? '' : ' class="error"';
579
				$size = !empty($config_var['size']) && is_numeric($config_var['size']) ? ' size="' . $config_var['size'] . '"' : '';
580
				$subtext = empty($config_var['subtext']) ? '' : '<br /><span class="smalltext' . ($disabled !== '' && $disabled !== '0' ? ' disabled' : ($invalid !== '' && $invalid !== '0' ? ' error' : '')) . '"> ' . $config_var['subtext'] . '</span>';
581
582
				// Show the [?] button.
583
				if (isset($config_var['helptext']))
584
				{
585
					echo '
586
						<a id="setting_', $config_var['name'], '" href="', getUrl('action', ['action' => 'quickhelp', 'help' => $config_var['helptext']]), '" onclick="return reqOverlayDiv(this.href);" class="helpicon i-help"><s>', $txt['help'], '</s>';
587
				}
588
				else
589
				{
590
					echo '
591
						<a id="setting_', $config_var['name'], '">';
592
				}
593
594
				echo '
595
						</a>
596
						<label for="', $config_var['name'], '"', ($config_var['disabled'] ? ' class="disabled"' : $invalid), '>', $config_var['label'], '</label>', $subtext, '
597
					</dt>
598
					<dd', (empty($config_var['force_div_id']) ? '' : ' id="' . $config_var['force_div_id'] . '_dd"'), '>',
599
						$preinput;
600
601
				// Show a checkbox.
602
				if ($config_var['type'] === 'check')
603
				{
604
					echo '
605
						<input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked="checked"' : ''), ' value="1" />';
606
				}
607
				// Password and confirm password fields
608
				elseif ($config_var['type'] === 'password')
609
				{
610
					echo '
611
						<input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]" id="', $config_var['name'], '"', $size, ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '_confirm.disabled = false;" class="input_password" />';
612
613
					if (empty($config_var['skip_verify_pass']))
614
					{
615
						echo '
616
					</dd>
617
					<dt ', (empty($config_var['force_div_id']) ? '' : ' id="' . $config_var['force_div_id'] . '_confirm_dt"'), '>
618
						<a id="setting_', $config_var['name'], '_confirm"></a>
619
						<span', ($config_var['disabled'] ? ' class="disabled"' : $invalid), '>
620
							<label for="', $config_var['name'], '_confirm"><em>', $txt['admin_confirm_password'], '</em></label>
621
						</span>
622
					</dt>
623
					<dd ', (empty($config_var['force_div_id']) ? '' : ' id="' . $config_var['force_div_id'] . '_confirm_dd"'), ' >
624
						<input type="password" disabled id="', $config_var['name'], '_confirm" name="', $config_var['name'], '[1]"', $size, ' class="input_password" />';
625
					}
626
				}
627
				// Show a selection box.
628
				elseif ($config_var['type'] === 'select')
629
				{
630
					echo '
631
						<select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (empty($config_var['multiple']) ? '' : ' multiple="multiple" class="select_multiple"'), '>';
632
633
					foreach ($config_var['data'] as $option)
634
					{
635
						if (empty($config_var['multiple']))
636
						{
637
							$selected = $option[0] == $config_var['value'];
638
						}
639
						else
640
						{
641
							$selected = in_array($option[0], $config_var['value']);
642
						}
643
644
						echo '
645
							<option value="', $option[0], '"', $selected ? ' selected' : '', '>', $option[1], '</option>';
646
					}
647
648
					echo '
649
						</select>';
650
				}
651
				// Text area?
652
				elseif ($config_var['type'] === 'large_text')
653
				{
654
					$rows = 4;
655
					$cols = 30;
656
657
					if (!empty($config_var['size']))
658
					{
659
						$rows = $config_var['size'];
660
					}
661
					elseif (!empty($config_var['rows']))
662
					{
663
						$rows = $config_var['rows'];
664
					}
665
666
					if (!empty($config_var['cols']))
667
					{
668
						$cols = $config_var['cols'];
669
					}
670
671
					echo '
672
						<textarea rows="' . $rows . '" cols="' . $cols . '" name="' . $config_var['name'] . '" id="' . $config_var['name'] . '">' . $config_var['value'] . '</textarea>';
673
				}
674
				// Permission group?
675
				elseif ($config_var['type'] === 'permissions')
676
				{
677
					template_inline_permissions($config_var['name'], !empty($config_var['collapsed']));
678
				}
679
				// BBC selection?
680
				elseif ($config_var['type'] === 'bbc')
681
				{
682
					echo '
683
						<fieldset id="', $config_var['name'], '">
684
							<legend>', $txt['bbcTagsToUse_select'], '</legend>
685
							<ul class="list_bbc">';
686
687
					foreach ($config_var['data'] as $bbcTag)
688
					{
689
						echo '
690
								<li>
691
									<label>
692
										<input type="checkbox" name="', $config_var['name'], '_enabledTags[]" value="', $bbcTag['tag'], '"', in_array($bbcTag['tag'], $config_var['disabled_tags']) ? '' : ' checked', ' /> ', $bbcTag['tag'], '
693
									</label>', $bbcTag['show_help'] ? '
694
									<a href="' . getUrl('action', ['action' => 'quickhelp', 'help' => 'tag_' . $bbcTag['tag']]) . '" onclick="return reqOverlayDiv(this.href);" class="helpicon i-help"></a>' : '', '
695
								</li>';
696
					}
697
698
					echo '
699
							</ul>
700
							<label>
701
								<input type="checkbox" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $config_var['all_selected'] ? ' checked' : '', ' />
702
								<em>', $txt['bbcTagsToUse_select_all'], '</em>
703
							</label>
704
						</fieldset>';
705
				}
706
				// A simple message?
707
				elseif ($config_var['type'] === 'var_message')
708
				{
709
					echo '
710
						<div', empty($config_var['name']) ? '' : ' id="' . $config_var['name'] . '"', '>', $config_var['message'], '</div>';
711
				}
712
				// An integer?
713
				elseif ($config_var['type'] === 'int')
714
				{
715
					echo '
716
						<input type="number"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '" value="', $config_var['value'], '"', $size, 'step="', ($config_var['step'] ?? '1'), '" class="input_text" />';
717
				}
718
				// A float
719
				elseif ($config_var['type'] === 'float')
720
				{
721
					echo '
722
						<input type="number"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '" value="', $config_var['value'], '"', $size, 'step="', ($config_var['step'] ?? '0.1'), '" class="input_text" />';
723
				}
724
				// A html5 input
725
				elseif (in_array($config_var['type'], ['url', 'search', 'date', 'email', 'color']))
726
				{
727
					echo '
728
						<input type="', $config_var['type'], '"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '" value="', $config_var['value'], '"', $size, ' class="input_text" />';
729
				}
730
				// Assume it must be a text box.
731
				else
732
				{
733
					echo '
734
						<input type="text"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '" value="', $config_var['value'], '"', $size, ' class="input_text" />';
735
				}
736
737
				echo ($config_var['invalid']) ? '
738
						<i class="icon i-alert"></i>' : '';
739
740
				echo isset($config_var['postinput']) && $config_var['postinput'] !== '' ? '
741
						' . $config_var['postinput'] : '';
742
743
				echo '
744
					</dd>';
745
			}
746
		}
747
		elseif ($config_var === '')
748
		{
749
			// Just show a separator.
750
			echo '
751
			</dl>
752
			<hr class="clear" />
753
			<dl class="settings">';
754
		}
755
		else
756
		{
757
			echo '
758
				<dd>
759
					<strong>' . $config_var . '</strong>
760
				</dd>';
761
		}
762
	}
763
764
	if ($is_open)
765
	{
766
		echo '
767
				</dl>';
768
	}
769
770
	if (empty($context['settings_save_dont_show']))
771
	{
772
		echo '
773
				<div class="submitbutton">
774
					<input type="submit" value="', $txt['save'], '"', (empty($context['save_disabled']) ? '' : ' disabled="disabled"'), (empty($context['settings_save_onclick']) ? '' : ' onclick="' . $context['settings_save_onclick'] . '"'), ' />
775
				</div>';
776
	}
777
778
	if ($is_open)
779
	{
780
		echo '
781
			</div>';
782
	}
783
784
	// At least one token has to be used!
785
	if (isset($context['admin-ssc_token']))
786
	{
787
		echo '
788
			<input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '" />';
789
	}
790
791
	echo '
792
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
793
		</form>
794
	</div>';
795
}
796
797
/**
798
 * Results page for an admin search.
799
 */
800
function template_admin_search_results()
801
{
802
	global $context, $txt;
803
804
	echo '
805
					<h2 class="category_header hdicon i-search">
806
						', sprintf($txt['admin_search_results_desc'], $context['search_term']) . 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...
807
					</h2>
808
					<div class="generic_list_wrapper">
809
						<div class="content">';
810
811
	if (empty($context['search_results']))
812
	{
813
		echo '
814
							<p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>';
815
	}
816
	else
817
	{
818
		echo '
819
							<ol class="search_results">';
820
821
		foreach ($context['search_results'] as $result)
822
		{
823
			// Is it a result from the online manual?
824
			if ($context['search_type'] === 'online')
825
			{
826
				echo '
827
								<li>
828
									<p>
829
										<a href="', $context['doc_scripturl'], str_replace(' ', '_', $result['title']), '" target="_blank" class="new_win"><strong>', $result['title'], '</strong></a>
830
									</p>
831
									<p>
832
										', $result['snippet'], '
833
									</p>
834
								</li>';
835
			}
836
			// Otherwise it's... not!
837
			else
838
			{
839
				echo '
840
								<li>
841
									<a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', $txt['admin_search_section_' . $result['type']] ?? $result['type'], ']';
842
843
				if ($result['help'])
844
				{
845
					echo '
846
									<p>', $result['help'], '</p>';
847
				}
848
849
				echo '
850
								</li>';
851
			}
852
		}
853
854
		echo '
855
							</ol>';
856
	}
857
858
	echo '
859
						</div>
860
					</div>';
861
}
862
863
/**
864
 * This little beauty shows questions and answer from the captcha type feature.
865
 */
866
function template_callback_question_answer_list()
867
{
868
	global $txt, $context;
869
870
	echo '
871
			<dt class="questions">
872
				<strong>', $txt['setup_verification_question'], '</strong>
873
			</dt>
874
			<dd class="questions">
875
				<strong>', $txt['setup_verification_answer'], '</strong>
876
			</dd>';
877
878
	foreach ($context['question_answers'] as $data)
879
	{
880
		echo '
881
			<dt class="questions">
882
				<input type="text" name="question[', $data['id_question'], ']" value="', $data['question'], '" size="40" class="input_text verification_question" />';
883
884
		if (!empty($context['languages']))
885
		{
886
			echo '
887
				<select name="language[', $data['id_question'], ']">';
888
889
			foreach ($context['languages'] as $lang)
890
			{
891
				echo '
892
					<option value="', $lang['filename'], '"', $lang['filename'] == $data['language'] ? ' selected="selected"' : '', '>', $lang['name'], '</option>';
893
			}
894
895
			echo '
896
				</select>';
897
		}
898
899
		echo '
900
			</dt>
901
			<dd class="questions">';
902
903
		$count = count($data['answer']) - 1;
904
		foreach ($data['answer'] as $id => $answer)
905
		{
906
			echo '
907
				<input type="text" name="answer[', $data['id_question'], '][]" value="', $answer, '" size="40" class="input_text verification_answer" />', $id == $count ? '<br />
908
				<a href="#" onclick="addAnotherAnswer(this, ' . $data['id_question'] . '); return false;">&#171; ' . $txt['setup_verification_add_more_answers'] . ' &#187;</a>' : '<br />';
909
		}
910
911
		echo '
912
			</dd>';
913
	}
914
915
	$lang_dropdown = '';
916
	if (!empty($context['languages']))
917
	{
918
		$lang_dropdown .= '
919
			<select name="language[b-%question_last_blank%]">';
920
921
		foreach ($context['languages'] as $lang)
922
		{
923
			$lang_dropdown .= '
924
				<option value="' . $lang['filename'] . '"' . ($lang['selected'] ? ' selected="selected"' : '') . '>' . $lang['name'] . '</option>';
925
		}
926
927
		$lang_dropdown .= '
928
			</select>';
929
	}
930
931
	// Some blank ones.
932
	for ($count = 0; $count < 3; $count++)
933
	{
934
		echo '
935
			<dt class="questions">
936
				<input type="text" name="question[b-', $count, ']" size="40" class="input_text verification_question" />',
937
		str_replace('%question_last_blank%', $count, $lang_dropdown), '
938
			</dt>
939
			<dd class="questions">
940
				<input type="text" name="answer[b-', $count, '][]" size="40" class="input_text verification_answer" /><br />
941
				<a href="#" onclick="addAnotherAnswer(this, \'b-', $count, '\'); return false;">&#171; ', $txt['setup_verification_add_more_answers'], ' &#187;</a>
942
			</dd>';
943
	}
944
945
	echo '
946
		<dt id="add_more_question_placeholder" class="hide"></dt>
947
		<dd></dd>
948
		<dt id="add_more_link_div" class="hide">
949
			<a href="#" onclick="addAnotherQuestion(); return false;">&#171; ', $txt['setup_verification_add_more'], ' &#187;</a>
950
		</dt><dd></dd>';
951
952
	theme()->addInlineJavascript('
953
				document.getElementById(\'add_more_link_div\').style.display = \'block\';
954
				var question_last_blank = ' . $count . ';
955
				var txt_add_another_answer = ' . JavaScriptEscape('&#171; ' . $txt['setup_verification_add_more_answers'] . ' &#187;') . ';
956
				var add_question_template = ' . JavaScriptEscape('
957
			<dt class="questions">
958
				<input type="text" name="question[b-%question_last_blank%]" size="40" class="input_text verification_question" />' .
959
			$lang_dropdown . '
960
			</dt>
961
			<dd class="questions">
962
				<input type="text" name="answer[b-%question_last_blank%][]" size="40" class="input_text verification_answer" /><br />
963
				<a href="#" onclick="addAnotherAnswer(this, \'b-%question_last_blank%\'); return false;">%setup_verification_add_more_answers%</a>
964
			</dd>
965
			<dt id="add_more_question_placeholder" class="hide"></dt>') . ';
966
				var add_answer_template = ' . JavaScriptEscape('
967
				<input type="text" name="answer[%question_last_blank%][]" size="40" class="input_text verification_answer" /><br />
968
				<a href="#" onclick="addAnotherAnswer(this, \'%question_last_blank%\'); return false;">&#171; ' . $txt['setup_verification_add_more_answers'] . ' &#187;</a>') . ';', true);
969
}
970
971
/**
972
 * Repairing boards.
973
 */
974
function template_repair_boards()
975
{
976
	global $context, $txt;
977
978
	echo '
979
	<div id="admincenter">
980
		<h2 class="category_header">', $context['error_search'] ? $txt['errors_list'] : $txt['errors_fixing'], '</h2>
981
		<div class="content">';
982
983
	// Are we actually fixing them, or is this just a prompt?
984
	if ($context['error_search'])
985
	{
986
		if (!empty($context['to_fix']))
987
		{
988
			echo '
989
				', $txt['errors_found'], ':
990
			<ul>';
991
992
			foreach ($context['repair_errors'] as $error)
993
			{
994
				echo '
995
				<li>
996
					', $error, '
997
				</li>';
998
			}
999
1000
			echo '
1001
			</ul>
1002
			<p class="noticebox">
1003
				', $txt['errors_fix'], '
1004
			</p>
1005
			<p>
1006
				<strong><a class="linkbutton" href="', getUrl('admin', ['action' => 'admin', 'area' => 'repairboards', 'fixErrors', '{session_data}']), '">', $txt['yes'], '</a> - <a href="', getUrl('admin', ['action' => 'admin', 'area' => 'maintain']), '">', $txt['no'], '</a></strong>
1007
			</p>';
1008
		}
1009
		else
1010
		{
1011
			echo '
1012
			<p class="infobox">', $txt['maintain_no_errors'], '</p>
1013
			<p>
1014
				<a class="linkbutton" href="', getUrl('admin', ['action' => 'admin', 'area' => 'maintain', 'sa' => 'routine']), '">', $txt['maintain_return'], '</a>
1015
			</p>';
1016
		}
1017
	}
1018
	elseif (!empty($context['redirect_to_recount']))
1019
	{
1020
		echo '
1021
		<p>
1022
			', $txt['errors_do_recount'], '
1023
		</p>
1024
		<form action="', getUrl('admin', ['action' => 'admin', 'area' => 'maintain', 'sa' => 'routine', 'activity' => 'recount']), '" id="recount_form" method="post">
1025
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
1026
			<input type="submit" name="cont" id="cont" value="', $txt['errors_recount_now'], '" />
1027
		</form>';
1028
	}
1029
	else
1030
	{
1031
		echo '
1032
		<p class="successbox">', $txt['errors_fixed'], '</p>
1033
		<p>
1034
			<a class="linkbutton" href="', getUrl('admin', ['action' => 'admin', 'area' => 'maintain', 'sa' => 'routine']), '">', $txt['maintain_return'], '</a>
1035
		</p>';
1036
	}
1037
1038
	echo '
1039
		</div>
1040
	</div>';
1041
1042
	if (!empty($context['redirect_to_recount']))
1043
	{
1044
		echo '
1045
	<script>
1046
		doAutoSubmit(5, ', JavaScriptEscape($txt['errors_recount_now']), ', "recount_form");
1047
	</script>';
1048
	}
1049
}
1050
1051
/**
1052
 * Retrieves info from the php_info function, scrubs and preps it for display
1053
 */
1054
function template_php_info()
1055
{
1056
	global $context, $txt;
1057
1058
	echo '
1059
	<div id="admin_form_wrapper">
1060
		<h2 class="category_header">', $txt['phpinfo_settings'], '</h2>';
1061
1062
	// for each php info area
1063
	foreach ($context['pinfo'] as $area => $php_area)
1064
	{
1065
		echo '
1066
		<table id="', str_replace(' ', '_', $area), '" class="table_grid wordbreak">
1067
			<thead>
1068
			<tr class="table_head">
1069
				<th class="grid33" scope="col"></th>
1070
				<th class="centertext grid33" scope="col"><strong>', $area, '</strong></th>
1071
				<th class="centertext grid33" scope="col"></th>
1072
			</tr>
1073
			</thead>
1074
			<tbody>';
1075
1076
		$localmaster = true;
1077
1078
		// and for each setting in this category
1079
		foreach ($php_area as $key => $setting)
1080
		{
1081
			// start of a local / master setting (3 col)
1082
			if (is_array($setting))
1083
			{
1084
				if ($localmaster)
1085
				{
1086
					// heading row for the settings section of this category's settings
1087
					echo '
1088
			<tr class="secondary_header">
1089
				<td><strong>', $txt['phpinfo_itemsettings'], '</strong></td>
1090
				<td class="centertext"><strong>', $txt['phpinfo_localsettings'], '</strong></td>
1091
				<td class="centertext"><strong>', $txt['phpinfo_defaultsettings'], '</strong></td>
1092
			</tr>';
1093
					$localmaster = false;
1094
				}
1095
1096
				echo '
1097
			<tr>
1098
				<td>', $key, '</td>';
1099
1100
				foreach ($setting as $value)
1101
				{
1102
					echo '
1103
				<td class="centertext">', $value, '</td>';
1104
				}
1105
1106
				echo '
1107
			</tr>';
1108
			}
1109
			// just a single setting (2 col)
1110
			else
1111
			{
1112
				echo '
1113
			<tr>
1114
				<td>', $key, '</td>
1115
				<td colspan="2">', $setting, '</td>
1116
			</tr>';
1117
			}
1118
		}
1119
1120
		echo '
1121
			</tbody>
1122
		</table>
1123
		<br />';
1124
	}
1125
1126
	echo '
1127
	</div>';
1128
}
1129
1130
/**
1131
 * Shows the clean cache button
1132
 */
1133
function template_clean_cache_button_below()
1134
{
1135
	global $txt, $context;
1136
1137
	echo '
1138
	<div class="generic_list_wrapper">
1139
		<h2 class="category_header">', $txt['maintain_cache'], '</h2>
1140
		<div class="content">
1141
			<form action="', getUrl('admin', ['action' => 'admin', 'area' => 'maintain', 'sa' => 'routine', 'activity' => 'cleancache']), '" method="post" accept-charset="UTF-8">
1142
				<p>', $txt['maintain_cache_info'], '</p>
1143
				<input type="submit" value="', $txt['maintain_run_now'], '" class="right_submit" />
1144
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
1145
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '" />
1146
			</form>
1147
		</div>
1148
	</div>';
1149
1150
	// Have some cache status to show?
1151
	if (!empty($context['cache_accelerator_stats']))
1152
	{
1153
		echo '
1154
	<div class="generic_list_wrapper">
1155
		<h2 class="category_header">', $txt['maintain_cache_status'], '</h2>
1156
		<div class="content">
1157
			<dl class="settings">';
1158
1159
		foreach($context['cache_accelerator_stats'] as $area => $value)
1160
		{
1161
			echo '
1162
				<dt>', $txt['maintain_cache_' . $area], '</dt>
1163
 				<dd>', $value, '</dd>';
1164
		}
1165
1166
		echo '
1167
			</dt>
1168
		</div>
1169
	</div>';
1170
	}
1171
}
1172
1173
/**
1174
 * Admin quick search box.
1175
 */
1176
function template_admin_quick_search()
1177
{
1178
	global $context, $txt;
1179
1180
	if ($context['user']['is_admin'])
1181
	{
1182
		echo '
1183
			<form action="', getUrl('admin', ['action' => 'admin', 'area' => 'search']), '" method="post" accept-charset="UTF-8" id="quick_search" class="floatright">
1184
				<input type="search" name="search_term" placeholder="', $txt['admin_search'], '" class="input_text" />
1185
				<select name="sa">
1186
					<option value="internal"', (empty($context['admin_preferences']['sb']) || $context['admin_preferences']['sb'] === 'internal' ? ' selected="selected"' : ''), '>', $txt['admin_search_type_internal'], '</option>
1187
					<option value="member"', (!empty($context['admin_preferences']['sb']) && $context['admin_preferences']['sb'] === 'member' ? ' selected="selected"' : ''), '>', $txt['admin_search_type_member'], '</option>
1188
					<option value="online"', (!empty($context['admin_preferences']['sb']) && $context['admin_preferences']['sb'] === 'online' ? ' selected="selected"' : ''), '>', $txt['admin_search_type_online'], '</option>
1189
				</select>
1190
				<button type="submit" name="search_go" id="search_go" ><i class="icon i-search"></i></button>
1191
			</form>';
1192
	}
1193
}
1194
1195
/**
1196
 * A list of URLs and "words separators" for new search engines in the dropdown
1197
 */
1198
function template_callback_external_search_engines()
1199
{
1200
	global $txt, $context;
1201
1202
	if (!empty($context['search_engines']))
1203
	{
1204
		foreach ($context['search_engines'] as $data)
1205
		{
1206
			echo '
1207
			<dt>
1208
				<label>', $txt['name'], ': <input type="text" name="engine_name[]" value="', $data['name'], '" size="50" class="input_text verification_question" /></label>
1209
			</dt>
1210
			<dd>
1211
				<label>', $txt['url'], ': <input type="text" name="engine_url[]" value="', $data['url'], '" size="35" class="input_text verification_answer" /></label><br />
1212
				<label>', $txt['words_sep'], ': <input type="text" name="engine_separator[]" value="', $data['separator'], '" size="5" class="input_text verification_answer" /></label>
1213
			</dd>';
1214
		}
1215
	}
1216
1217
	echo '
1218
		<dt id="add_more_searches" class="hide"></dt>
1219
		<dd></dd>
1220
		<dt id="add_more_link_div" class="hide">
1221
			<a class="linkbutton" href="#" onclick="addAnotherSearch(', JavaScriptEscape($txt['name']), ', ', JavaScriptEscape($txt['url']), ', ', JavaScriptEscape($txt['words_sep']), '); return false;">', $txt['setup_search_engine_add_more'], '</a>
1222
		</dt>
1223
		<dd></dd>';
1224
1225
	theme()->addInlineJavascript('
1226
				document.getElementById(\'add_more_link_div\').style.display = \'block\';', true);
1227
}
1228
1229
/**
1230
 * Used to show all of the pm message limits each group allows
1231
 */
1232
function template_callback_pm_limits()
1233
{
1234
	global $context;
1235
1236
	foreach ($context['pm_limits'] as $group_id => $group)
1237
	{
1238
		echo '
1239
			<dt>
1240
				<label for="id_group_', $group_id, '">', $group['group_name'], '</label>
1241
			</dt>
1242
			<dd>
1243
				<input type="text" id="id_group_', $group_id, '" name="group[', $group_id, ']" value="', $group['max_messages'], '" size="6" class="input_text" />
1244
			</dd>';
1245
	}
1246
}
1247
1248
/**
1249
 * Template used to show the queries run in the previous page load
1250
 */
1251
function template_viewquery()
1252
{
1253
	global $context;
1254
1255
	foreach ($context['queries_data'] as $q => $query_data)
1256
	{
1257
		echo '
1258
	<div id="qq', $q, '" class="query">
1259
		<a ', $query_data['is_select'] ? 'href="' . getUrl('action', ['action' => 'viewquery', 'qq' => ($q + 1) . '#qq' . $q]) . '"' : '', '>
1260
			', $query_data['text'], '
1261
		</a><br />', $query_data['position_time'], '
1262
	</div>';
1263
1264
		if (!empty($query_data['explain']['is_error']))
1265
		{
1266
			echo '
1267
	<table class="explain">
1268
		<tr><td>', $query_data['explain']['error_text'], '</td></tr>
1269
	</table>';
1270
		}
1271
		elseif (!empty($query_data['explain']['headers']))
1272
		{
1273
			echo '
1274
	<table class="explain">
1275
		<tr>
1276
			<th>' . implode('</th>
1277
			<th>', array_keys($query_data['explain']['headers'])) . '</th>
1278
		</tr>';
1279
1280
			foreach ($query_data['explain']['body'] as $row)
1281
			{
1282
				echo '
1283
		<tr>
1284
			<td>' . implode('</td>
1285
			<td>', $row) . '</td>
1286
		</tr>';
1287
			}
1288
1289
			echo '
1290
	</table>';
1291
		}
1292
	}
1293
}
1294