Passed
Pull Request — release-2.1 (#6409)
by
unknown
06:46
created

template_maintain_database()   B

Complexity

Conditions 6
Paths 16

Size

Total Lines 74
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 37
nc 16
nop 0
dl 0
loc 74
rs 8.7057
c 0
b 0
f 0

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 https://www.simplemachines.org
7
 * @copyright 2022 Simple Machines and individual contributors
8
 * @license https://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1.0
11
 */
12
13
/**
14
 * Template for the database maintenance tasks.
15
 */
16
function template_maintain_database()
17
{
18
	global $context, $txt, $scripturl, $modSettings;
19
20
	// If maintenance has finished tell the user.
21
	if (!empty($context['maintenance_finished']))
22
		echo '
23
	<div class="infobox">
24
		', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
25
	</div>';
26
27
	echo '
28
	<div id="manage_maintenance">
29
		<div class="cat_bar">
30
			<h3 class="catbg">', $txt['maintain_optimize'], '</h3>
31
		</div>
32
		<div class="windowbg">
33
			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=optimize" method="post" accept-charset="', $context['character_set'], '">
34
				<p>', $txt['maintain_optimize_info'], '</p>
35
				<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
36
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
37
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
38
			</form>
39
		</div>';
40
41
	// Show an option to convert to UTF8MB4 if we're not on UTF8MB4 yet.
42
	if ($context['convert_utf8mb4'])
43
	{
44
		echo '
45
		<div class="cat_bar">
46
			<h3 class="catbg">', $txt['utf8_title'], '</h3>
47
		</div>
48
		<div class="windowbg">
49
			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertutf8mb4" method="post" accept-charset="', $context['character_set'], '">
50
				<p>', $txt['utf8_introduction'], '</p>
51
				<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
52
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
53
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
54
			</form>
55
		</div>';
56
	}
57
58
	// Show an option to convert the body column of the post table to MEDIUMTEXT or TEXT
59
	if (isset($context['convert_to']))
60
		echo '
61
		<div class="cat_bar">
62
			<h3 class="catbg">', $txt[$context['convert_to'] . '_title'], '</h3>
63
		</div>
64
		<div class="windowbg">
65
			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '">
66
				<p>', $txt['mediumtext_introduction'], '</p>',
67
				$context['convert_to_suggest'] ? '<p class="infobox">' . $txt['convert_to_suggest_text'] . '</p>' : '', '
68
				<input type="submit" name="evaluate_conversion" value="', $txt['maintain_run_now'], '" class="button">
69
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
70
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
71
			</form>
72
		</div>';
73
74
	// We might want to convert entities if we're on UTF-8.
75
	if ($context['convert_entities'])
76
		echo '
77
		<div class="cat_bar">
78
			<h3 class="catbg">', $txt['entity_convert_title'], '</h3>
79
		</div>
80
		<div class="windowbg">
81
			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertentities" method="post" accept-charset="', $context['character_set'], '">
82
				<p>', $txt['entity_convert_introduction'], '</p>
83
				<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
84
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
85
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
86
			</form>
87
		</div>';
88
89
	echo '
90
	</div><!-- #manage_maintenance -->';
91
}
92
93
/**
94
 * Template for the routine maintenance tasks.
95
 */
96
function template_maintain_routine()
97
{
98
	global $context, $txt, $scripturl;
99
100
	// Starts off with general maintenance procedures.
101
	echo '
102
	<div id="manage_maintenance">';
103
104
	// If maintenance has finished tell the user.
105
	if (!empty($context['maintenance_finished']))
106
		echo '
107
		<div class="infobox">
108
			', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
109
		</div>';
110
111
	echo '
112
		<div class="cat_bar">
113
			<h3 class="catbg">', $txt['maintain_version'], '</h3>
114
		</div>
115
		<div class="windowbg">
116
			<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=version" method="post" accept-charset="', $context['character_set'], '">
117
				<p>
118
					', $txt['maintain_version_info'], '
119
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
120
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
121
				</p>
122
			</form>
123
		</div>
124
		<div class="cat_bar">
125
			<h3 class="catbg">', $txt['maintain_errors'], '</h3>
126
		</div>
127
		<div class="windowbg">
128
			<form action="', $scripturl, '?action=admin;area=repairboards" method="post" accept-charset="', $context['character_set'], '">
129
				<p>
130
					', $txt['maintain_errors_info'], '
131
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
132
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
133
					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
134
				</p>
135
			</form>
136
		</div>
137
		<div class="cat_bar">
138
			<h3 class="catbg">', $txt['maintain_recount'], '</h3>
139
		</div>
140
		<div class="windowbg">
141
			<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=recount" method="post" accept-charset="', $context['character_set'], '">
142
				<p>
143
					', $txt['maintain_recount_info'], '
144
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
145
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
146
					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
147
				</p>
148
			</form>
149
		</div>
150
		<div class="cat_bar">
151
			<h3 class="catbg">', $txt['maintain_rebuild_settings'], '</h3>
152
		</div>
153
		<div class="windowbg">
154
			<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=rebuild_settings" method="post" accept-charset="', $context['character_set'], '">
155
				<p>
156
					', $txt['maintain_rebuild_settings_info'], '
157
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
158
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
159
				</p>
160
			</form>
161
		</div>
162
		<div class="cat_bar">
163
			<h3 class="catbg">', $txt['maintain_logs'], '</h3>
164
		</div>
165
		<div class="windowbg">
166
			<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=logs" method="post" accept-charset="', $context['character_set'], '">
167
				<p>
168
					', $txt['maintain_logs_info'], '
169
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
170
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
171
					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
172
				</p>
173
			</form>
174
		</div>
175
		<div class="cat_bar">
176
			<h3 class="catbg">', $txt['maintain_cache'], '</h3>
177
		</div>
178
		<div class="windowbg">
179
			<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=cleancache" method="post" accept-charset="', $context['character_set'], '">
180
				<p>
181
					', $txt['maintain_cache_info'], '
182
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
183
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
184
					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
185
				</p>
186
			</form>
187
		</div>
188
	</div><!-- #manage_maintenance -->';
189
}
190
191
/**
192
 * Template for the member maintenance tasks.
193
 */
194
function template_maintain_members()
195
{
196
	global $context, $settings, $txt, $scripturl;
197
198
	echo '
199
	<script>
200
		var warningMessage = \'\';
201
		var membersSwap = false;
202
203
		function swapMembers()
204
		{
205
			membersSwap = !membersSwap;
206
			var membersForm = document.getElementById(\'membersForm\');
207
208
			$("#membersPanel").slideToggle(300);
209
210
			document.getElementById("membersIcon").src = smf_images_url + (membersSwap ? "/selected_open.png" : "/selected.png");
211
			setInnerHTML(document.getElementById("membersText"), membersSwap ? "', $txt['maintain_members_choose'], '" : "', $txt['maintain_members_all'], '");
212
213
			for (var i = 0; i < membersForm.length; i++)
214
			{
215
				if (membersForm.elements[i].type.toLowerCase() == "checkbox")
216
					membersForm.elements[i].checked = !membersSwap;
217
			}
218
		}
219
220
		function checkAttributeValidity()
221
		{
222
			origText = \'', $txt['reattribute_confirm'], '\';
223
			valid = true;
224
225
			// Do all the fields!
226
			if (!document.getElementById(\'to\').value)
227
				valid = false;
228
			warningMessage = origText.replace(/%member_to%/, document.getElementById(\'to\').value);
229
230
			if (document.getElementById(\'type_email\').checked)
231
			{
232
				if (!document.getElementById(\'from_email\').value)
233
					valid = false;
234
				warningMessage = warningMessage.replace(/%type%/, \'', addcslashes($txt['reattribute_confirm_email'], "'"), '\').replace(/%find%/, document.getElementById(\'from_email\').value);
235
			}
236
			else
237
			{
238
				if (!document.getElementById(\'from_name\').value)
239
					valid = false;
240
				warningMessage = warningMessage.replace(/%type%/, \'', addcslashes($txt['reattribute_confirm_username'], "'"), '\').replace(/%find%/, document.getElementById(\'from_name\').value);
241
			}
242
243
			document.getElementById(\'do_attribute\').disabled = valid ? \'\' : \'disabled\';
244
245
			setTimeout("checkAttributeValidity();", 500);
246
			return valid;
247
		}
248
		setTimeout("checkAttributeValidity();", 500);
249
	</script>
250
	<div id="manage_maintenance">';
251
252
	// If maintenance has finished, tell the user.
253
	if (!empty($context['maintenance_finished']))
254
		echo '
255
		<div class="infobox">
256
			', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
257
		</div>';
258
259
	echo '
260
		<div class="cat_bar">
261
			<h3 class="catbg">', $txt['maintain_reattribute_posts'], '</h3>
262
		</div>
263
		<div class="windowbg">
264
			<form action="', $scripturl, '?action=admin;area=maintain;sa=members;activity=reattribute" method="post" accept-charset="', $context['character_set'], '">
265
				<p><strong>', $txt['reattribute_guest_posts'], '</strong></p>
266
				<dl class="settings">
267
					<dt>
268
						<label for="type_email"><input type="radio" name="type" id="type_email" value="email" checked>', $txt['reattribute_email'], '</label>
269
					</dt>
270
					<dd>
271
						<input type="text" name="from_email" id="from_email" value="" onclick="document.getElementById(\'type_email\').checked = \'checked\'; document.getElementById(\'from_name\').value = \'\';">
272
					</dd>
273
					<dt>
274
						<label for="type_name"><input type="radio" name="type" id="type_name" value="name">', $txt['reattribute_username'], '</label>
275
					</dt>
276
					<dd>
277
						<input type="text" name="from_name" id="from_name" value="" onclick="document.getElementById(\'type_name\').checked = \'checked\'; document.getElementById(\'from_email\').value = \'\';">
278
					</dd>
279
				</dl>
280
				<dl class="settings">
281
					<dt>
282
						<label for="to"><strong>', $txt['reattribute_current_member'], ':</strong></label>
283
					</dt>
284
					<dd>
285
						<input type="text" name="to" id="to" value="">
286
					</dd>
287
				</dl>
288
				<p class="maintain_members">
289
					<input type="checkbox" name="posts" id="posts" checked>
290
					<label for="posts">', $txt['reattribute_increase_posts'], '</label>
291
				</p>
292
				<input type="submit" id="do_attribute" value="', $txt['reattribute'], '" onclick="if (!checkAttributeValidity()) return false;
293
				return confirm(warningMessage);" class="button">
294
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
295
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
296
			</form>
297
		</div><!-- .windowbg -->
298
		<div class="cat_bar">
299
			<h3 class="catbg">
300
				<a href="', $scripturl, '?action=helpadmin;help=maintenance_members" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a> ', $txt['maintain_members'], '
301
			</h3>
302
		</div>
303
		<div class="windowbg">
304
			<form action="', $scripturl, '?action=admin;area=maintain;sa=members;activity=purgeinactive" method="post" accept-charset="', $context['character_set'], '" id="membersForm">
305
				<p>
306
					<a id="membersLink"></a>', $txt['maintain_members_since1'], '
307
					<select name="del_type">
308
						<option value="activated" selected>', $txt['maintain_members_activated'], '</option>
309
						<option value="logged">', $txt['maintain_members_logged_in'], '</option>
310
					</select>
311
					', $txt['maintain_members_since2'], '
312
					<input type="number" name="maxdays" value="30" size="3">', $txt['maintain_members_since3'], '
313
				</p>
314
				<p>
315
					<a href="#membersLink" onclick="swapMembers();"><img src="', $settings['images_url'], '/selected.png" alt="+" id="membersIcon"></a> <a href="#membersLink" onclick="swapMembers();" id="membersText" style="font-weight: bold;">', $txt['maintain_members_all'], '</a>
316
				</p>
317
				<div style="display: none;" id="membersPanel">';
318
319
	foreach ($context['membergroups'] as $group)
320
		echo '
321
					<label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked> ', $group['name'], '</label><br>';
322
323
	echo '
324
				</div>
325
				<input type="submit" value="', $txt['maintain_old_remove'], '" data-confirm="', $txt['maintain_members_confirm'], '" class="button you_sure">
326
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
327
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
328
			</form>
329
		</div><!-- .windowbg -->
330
		<div class="cat_bar">
331
			<h3 class="catbg">', $txt['maintain_recountposts'], '</h3>
332
		</div>
333
		<div class="windowbg">
334
			<form action="', $scripturl, '?action=admin;area=maintain;sa=members;activity=recountposts" method="post" accept-charset="', $context['character_set'], '" id="membersRecountForm">
335
				<p>', $txt['maintain_recountposts_info'], '</p>
336
				<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
337
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
338
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
339
			</form>
340
		</div>
341
	</div><!-- #manage_maintenance -->
342
343
	<script>
344
		var oAttributeMemberSuggest = new smc_AutoSuggest({
345
			sSelf: \'oAttributeMemberSuggest\',
346
			sSessionId: smf_session_id,
347
			sSessionVar: smf_session_var,
348
			sSuggestId: \'attributeMember\',
349
			sControlId: \'to\',
350
			sSearchType: \'member\',
351
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
352
			bItemList: false
353
		});
354
	</script>';
355
}
356
357
/**
358
 * Template for the topic maintenance tasks.
359
 */
360
function template_maintain_topics()
361
{
362
	global $scripturl, $txt, $context, $settings, $modSettings;
363
364
	// If maintenance has finished tell the user.
365
	if (!empty($context['maintenance_finished']))
366
		echo '
367
	<div class="infobox">
368
		', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
369
	</div>';
370
371
	// Bit of javascript for showing which boards to prune in an otherwise hidden list.
372
	echo '
373
	<script>
374
		var rotSwap = false;
375
		function swapRot()
376
		{
377
			rotSwap = !rotSwap;
378
379
			// Toggle icon
380
			document.getElementById("rotIcon").src = smf_images_url + (rotSwap ? "/selected_open.png" : "/selected.png");
381
			setInnerHTML(document.getElementById("rotText"), rotSwap ? ', JavaScriptEscape($txt['maintain_old_choose']), ' : ', JavaScriptEscape($txt['maintain_old_all']), ');
382
383
			// Toggle panel
384
			$("#rotPanel").slideToggle(300);
385
386
			// Toggle checkboxes
387
			var rotPanel = document.getElementById(\'rotPanel\');
388
			var oBoardCheckBoxes = rotPanel.getElementsByTagName(\'input\');
389
			for (var i = 0; i < oBoardCheckBoxes.length; i++)
390
			{
391
				if (oBoardCheckBoxes[i].type.toLowerCase() == "checkbox")
392
					oBoardCheckBoxes[i].checked = !rotSwap;
393
			}
394
		}
395
	</script>';
396
397
	echo '
398
	<div id="manage_maintenance">
399
		<div class="cat_bar">
400
			<h3 class="catbg">', $txt['maintain_old'], '</h3>
401
		</div>
402
		<div class="windowbg">
403
			<div class="flow_auto">
404
				<form action="', $scripturl, '?action=admin;area=maintain;sa=topics;activity=pruneold" method="post" accept-charset="', $context['character_set'], '">';
405
406
	// The otherwise hidden "choose which boards to prune".
407
	echo '
408
					<p>
409
						<a id="rotLink"></a>', $txt['maintain_old_since_days1'], '<input type="number" name="maxdays" value="30" size="3">', $txt['maintain_old_since_days2'], '
410
					</p>
411
					<p>
412
						<label for="delete_type_nothing"><input type="radio" name="delete_type" id="delete_type_nothing" value="nothing"> ', $txt['maintain_old_nothing_else'], '</label><br>
413
						<label for="delete_type_moved"><input type="radio" name="delete_type" id="delete_type_moved" value="moved" checked> ', $txt['maintain_old_are_moved'], '</label><br>
414
						<label for="delete_type_locked"><input type="radio" name="delete_type" id="delete_type_locked" value="locked"> ', $txt['maintain_old_are_locked'], '</label><br>
415
					</p>
416
					<p>
417
						<label for="delete_old_not_sticky"><input type="checkbox" name="delete_old_not_sticky" id="delete_old_not_sticky" checked> ', $txt['maintain_old_are_not_stickied'], '</label><br>
418
					</p>
419
					<p>
420
						<a href="#rotLink" onclick="swapRot();"><img src="', $settings['images_url'], '/selected.png" alt="+" id="rotIcon"></a> <a href="#rotLink" onclick="swapRot();" id="rotText" style="font-weight: bold;">', $txt['maintain_old_all'], '</a>
421
					</p>
422
					<div style="display: none;" id="rotPanel" class="flow_hidden">
423
						<div class="floatleft" style="width: 49%">';
424
425
	// This is the "middle" of the list.
426
	$middle = ceil(count($context['categories']) / 2);
427
428
	$i = 0;
429
	foreach ($context['categories'] as $category)
430
	{
431
		echo '
432
							<fieldset>
433
								<legend>', $category['name'], '</legend>
434
								<ul>';
435
436
		// Display a checkbox with every board.
437
		foreach ($category['boards'] as $board)
438
			echo '
439
									<li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;">
440
										<label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked>', $board['name'], '</label>
441
									</li>';
442
443
		echo '
444
								</ul>
445
							</fieldset>';
446
447
		// Increase $i, and check if we're at the middle yet.
448
		if (++$i == $middle)
449
			echo '
450
						</div><!-- .floatleft -->
451
						<div class="floatright" style="width: 49%;">';
452
	}
453
454
	echo '
455
						</div>
456
					</div><!-- #rotPanel -->
457
					<input type="submit" value="', $txt['maintain_old_remove'], '" data-confirm="', $txt['maintain_old_confirm'], '" class="button you_sure">
458
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
459
					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
460
				</form>
461
			</div><!-- .flow_auto -->
462
		</div><!-- .windowbg -->
463
464
		<div class="cat_bar">
465
			<h3 class="catbg">', $txt['maintain_old_drafts'], '</h3>
466
		</div>
467
		<div class="windowbg">
468
			<form action="', $scripturl, '?action=admin;area=maintain;sa=topics;activity=olddrafts" method="post" accept-charset="', $context['character_set'], '">
469
				<p>
470
					', $txt['maintain_old_drafts_days'], ' <input type="number" name="draftdays" value="', (!empty($modSettings['drafts_keep_days']) ? $modSettings['drafts_keep_days'] : 30), '" size="3"> ', $txt['days_word'], '
471
				</p>
472
				<input type="submit" value="', $txt['maintain_old_remove'], '" data-confirm="', $txt['maintain_old_drafts_confirm'], '" class="button you_sure">
473
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
474
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
475
			</form>
476
		</div>
477
		<div class="cat_bar">
478
			<h3 class="catbg">', $txt['move_topics_maintenance'], '</h3>
479
		</div>
480
		<div class="windowbg">
481
			<form action="', $scripturl, '?action=admin;area=maintain;sa=topics;activity=massmove" method="post" accept-charset="', $context['character_set'], '">
482
				<p>
483
					<label for="id_board_from">', $txt['move_topics_from'], ' </label>
484
					<select name="id_board_from" id="id_board_from">
485
						<option disabled>(', $txt['move_topics_select_board'], ')</option>';
486
487
	// From board
488
	foreach ($context['categories'] as $category)
489
	{
490
		echo '
491
						<optgroup label="', $category['name'], '">';
492
493
		foreach ($category['boards'] as $board)
494
			echo '
495
							<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
496
497
		echo '
498
						</optgroup>';
499
	}
500
501
	echo '
502
					</select>
503
					<label for="id_board_to">', $txt['move_topics_to'], '</label>
504
					<select name="id_board_to" id="id_board_to">
505
						<option disabled>(', $txt['move_topics_select_board'], ')</option>';
506
507
	// To board
508
	foreach ($context['categories'] as $category)
509
	{
510
		echo '
511
						<optgroup label="', $category['name'], '">';
512
513
		foreach ($category['boards'] as $board)
514
			echo '
515
							<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
516
517
		echo '
518
						</optgroup>';
519
	}
520
	echo '
521
					</select>
522
				</p>
523
				<p>
524
					', $txt['move_topics_older_than'], '
525
					<input type="number" name="maxdays" value="30" size="3">
526
					', $txt['manageposts_days'], ' (', $txt['move_zero_all'], ')
527
				</p>
528
				<p>
529
					<label for="move_type_locked"><input type="checkbox" name="move_type_locked" id="move_type_locked" checked> ', $txt['move_type_locked'], '</label><br>
530
					<label for="move_type_sticky"><input type="checkbox" name="move_type_sticky" id="move_type_sticky"> ', $txt['move_type_sticky'], '</label><br>
531
				</p>
532
				<input type="submit" value="', $txt['move_topics_now'], '" onclick="if (document.getElementById(\'id_board_from\').options[document.getElementById(\'id_board_from\').selectedIndex].disabled || document.getElementById(\'id_board_from\').options[document.getElementById(\'id_board_to\').selectedIndex].disabled) return false; var confirmText = \'', $txt['move_topics_confirm'] . '\'; return confirm(confirmText.replace(/%board_from%/, document.getElementById(\'id_board_from\').options[document.getElementById(\'id_board_from\').selectedIndex].text.replace(/^=+&gt;&nbsp;/, \'\')).replace(/%board_to%/, document.getElementById(\'id_board_to\').options[document.getElementById(\'id_board_to\').selectedIndex].text.replace(/^=+&gt;&nbsp;/, \'\')));" class="button">
533
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
534
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
535
			</form>
536
		</div><!-- .windowbg -->
537
	</div><!-- #manage_maintenance -->';
538
}
539
540
/**
541
 * Simple template for showing results of our optimization...
542
 */
543
function template_optimize()
544
{
545
	global $context, $txt, $scripturl;
546
547
	echo '
548
	<div id="manage_maintenance">
549
		<div class="cat_bar">
550
			<h3 class="catbg">', $txt['maintain_optimize'], '</h3>
551
		</div>
552
		<div class="windowbg">
553
			<p>
554
				', $txt['database_numb_tables'], '<br>
555
				', $txt['database_optimize_attempt'], '<br>';
556
557
	// List each table being optimized...
558
	foreach ($context['optimized_tables'] as $table)
559
		echo '
560
				', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>';
561
562
	// How did we go?
563
	echo '
564
				<br>
565
				', $context['num_tables_optimized'] == 0 ? $txt['database_already_optimized'] : $context['num_tables_optimized'] . ' ' . $txt['database_optimized'];
566
567
	echo '
568
			</p>
569
			<p><a href="', $scripturl, '?action=admin;area=maintain">', $txt['maintain_return'], '</a></p>
570
		</div><!-- .windowbg -->
571
	</div><!-- #manage_maintenance -->';
572
}
573
574
/**
575
 * Template for converting entities to UTF-8 characters
576
 */
577
function template_convert_entities()
578
{
579
	global $context, $txt, $scripturl;
580
581
	echo '
582
	<div id="manage_maintenance">
583
		<div class="cat_bar">
584
			<h3 class="catbg">', $txt['entity_convert_title'], '</h3>
585
		</div>
586
		<div class="windowbg">
587
			<p>', $txt['entity_convert_introduction'], '</p>
588
			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertentities;start=0;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
589
			<input type="submit" value="', $txt['entity_convert_proceed'], '" class="button">
590
			</form>
591
		</div>
592
	</div>';
593
}
594
595
/**
596
 * Template for changing message body from TEXT to MEDIUMTEXT.
597
 */
598
function template_convert_msgbody()
599
{
600
	global $context, $txt, $scripturl;
601
602
	echo '
603
	<div id="manage_maintenance">
604
		<div class="cat_bar">
605
			<h3 class="catbg">', $txt[$context['convert_to'] . '_title'], '</h3>
606
		</div>
607
		<div class="windowbg">
608
			<p>', $txt['body_checking_introduction'], '</p>';
609
610
	if (!empty($context['exceeding_messages']))
611
	{
612
		echo '
613
			<p class="noticebox">', $txt['exceeding_messages'], '</p>
614
			<ul>
615
				<li>
616
				', implode('</li><li>', $context['exceeding_messages']), '
617
				</li>
618
			</ul>';
619
620
		if (!empty($context['exceeding_messages_morethan']))
621
			echo '
622
			<p>', $context['exceeding_messages_morethan'], '</p>';
623
	}
624
	else
625
		echo '
626
			<p class="infobox">', $txt['convert_to_text'], '</p>';
627
628
	echo '
629
			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '">
630
			<hr>
631
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
632
			<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
633
			<input type="submit" name="do_conversion" value="', $txt['entity_convert_proceed'], '" class="button">
634
			</form>
635
		</div><!-- .windowbg -->
636
	</div><!-- #manage_maintenance -->';
637
}
638
639
?>