Completed
Push — release-2.1 ( f70233...9fa566 )
by Colin
10:32
created

ManageMaintenance.template.php ➔ template_maintain_database()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 59

Duplication

Lines 5
Ratio 8.47 %

Importance

Changes 0
Metric Value
cc 5
nc 8
nop 0
dl 5
loc 59
rs 8.5833
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 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
 * Tempalte for the database maintenance tasks.
15
 */
16
function template_maintain_database()
17
{
18
	global $context, $txt, $scripturl, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
19
20
	// If maintenance has finished tell the user.
21 View Code Duplication
	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 noup">
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 the body column of the post table to MEDIUMTEXT or TEXT
42
	if (isset($context['convert_to']))
43
		echo '
44
		<div class="cat_bar">
45
			<h3 class="catbg">', $txt[$context['convert_to'] . '_title'], '</h3>
46
		</div>
47
		<div class="windowbg noup">
48
			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '">
49
				<p>', $txt['mediumtext_introduction'], '</p>',
50
				$context['convert_to_suggest'] ? '<p class="infobox">' . $txt['convert_to_suggest_text'] . '</p>' : '', '
51
				<input type="submit" name="evaluate_conversion" 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
	// We might want to convert entities if we're on UTF-8.
58
	if ($context['convert_entities'])
59
		echo '
60
		<div class="cat_bar">
61
			<h3 class="catbg">', $txt['entity_convert_title'], '</h3>
62
		</div>
63
		<div class="windowbg noup">
64
			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertentities" method="post" accept-charset="', $context['character_set'], '">
65
				<p>', $txt['entity_convert_introduction'], '</p>
66
				<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
67
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
68
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
69
			</form>
70
		</div>';
71
72
	echo '
73
	</div><!-- #manage_maintenance -->';
74
}
75
76
/**
77
 * Template for the routine maintenance tasks.
78
 */
79
function template_maintain_routine()
80
{
81
	global $context, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
82
83
	// Starts off with general maintenance procedures.
84
	echo '
85
	<div id="manage_maintenance">';
86
87
	// If maintenance has finished tell the user.
88 View Code Duplication
	if (!empty($context['maintenance_finished']))
89
		echo '
90
		<div class="infobox">
91
			', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
92
		</div>';
93
94
	echo '
95
		<div class="cat_bar">
96
			<h3 class="catbg">', $txt['maintain_version'], '</h3>
97
		</div>
98
		<div class="windowbg noup">
99
			<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=version" method="post" accept-charset="', $context['character_set'], '">
100
				<p>
101
					', $txt['maintain_version_info'], '
102
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
103
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
104
				</p>
105
			</form>
106
		</div>
107
		<div class="cat_bar">
108
			<h3 class="catbg">', $txt['maintain_errors'], '</h3>
109
		</div>
110
		<div class="windowbg noup">
111
			<form action="', $scripturl, '?action=admin;area=repairboards" method="post" accept-charset="', $context['character_set'], '">
112
				<p>
113
					', $txt['maintain_errors_info'], '
114
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
115
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
116
					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
117
				</p>
118
			</form>
119
		</div>
120
		<div class="cat_bar">
121
			<h3 class="catbg">', $txt['maintain_recount'], '</h3>
122
		</div>
123
		<div class="windowbg noup">
124
			<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=recount" method="post" accept-charset="', $context['character_set'], '">
125
				<p>
126
					', $txt['maintain_recount_info'], '
127
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
128
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
129
					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
130
				</p>
131
			</form>
132
		</div>
133
		<div class="cat_bar">
134
			<h3 class="catbg">', $txt['maintain_logs'], '</h3>
135
		</div>
136
		<div class="windowbg noup">
137
			<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=logs" method="post" accept-charset="', $context['character_set'], '">
138
				<p>
139
					', $txt['maintain_logs_info'], '
140
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
141
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
142
					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
143
				</p>
144
			</form>
145
		</div>
146
		<div class="cat_bar">
147
			<h3 class="catbg">', $txt['maintain_cache'], '</h3>
148
		</div>
149
		<div class="windowbg noup">
150
			<form action="', $scripturl, '?action=admin;area=maintain;sa=routine;activity=cleancache" method="post" accept-charset="', $context['character_set'], '">
151
				<p>
152
					', $txt['maintain_cache_info'], '
153
					<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
154
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
155
					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
156
				</p>
157
			</form>
158
		</div>
159
	</div><!-- #manage_maintenance -->';
160
}
161
162
/**
163
 * Template for the member maintenance tasks.
164
 */
165
function template_maintain_members()
166
{
167
	global $context, $settings, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
168
169
	echo '
170
	<script>
171
		var warningMessage = \'\';
172
		var membersSwap = false;
173
174
		function swapMembers()
175
		{
176
			membersSwap = !membersSwap;
177
			var membersForm = document.getElementById(\'membersForm\');
178
179
			$("#membersPanel").slideToggle(300);
180
181
			document.getElementById("membersIcon").src = smf_images_url + (membersSwap ? "/selected_open.png" : "/selected.png");
182
			setInnerHTML(document.getElementById("membersText"), membersSwap ? "', $txt['maintain_members_choose'], '" : "', $txt['maintain_members_all'], '");
183
184
			for (var i = 0; i < membersForm.length; i++)
185
			{
186
				if (membersForm.elements[i].type.toLowerCase() == "checkbox")
187
					membersForm.elements[i].checked = !membersSwap;
188
			}
189
		}
190
191
		function checkAttributeValidity()
192
		{
193
			origText = \'', $txt['reattribute_confirm'], '\';
194
			valid = true;
195
196
			// Do all the fields!
197
			if (!document.getElementById(\'to\').value)
198
				valid = false;
199
			warningMessage = origText.replace(/%member_to%/, document.getElementById(\'to\').value);
200
201
			if (document.getElementById(\'type_email\').checked)
202
			{
203
				if (!document.getElementById(\'from_email\').value)
204
					valid = false;
205
				warningMessage = warningMessage.replace(/%type%/, \'', addcslashes($txt['reattribute_confirm_email'], "'"), '\').replace(/%find%/, document.getElementById(\'from_email\').value);
206
			}
207
			else
208
			{
209
				if (!document.getElementById(\'from_name\').value)
210
					valid = false;
211
				warningMessage = warningMessage.replace(/%type%/, \'', addcslashes($txt['reattribute_confirm_username'], "'"), '\').replace(/%find%/, document.getElementById(\'from_name\').value);
212
			}
213
214
			document.getElementById(\'do_attribute\').disabled = valid ? \'\' : \'disabled\';
215
216
			setTimeout("checkAttributeValidity();", 500);
217
			return valid;
218
		}
219
		setTimeout("checkAttributeValidity();", 500);
220
	</script>
221
	<div id="manage_maintenance">';
222
223
	// If maintenance has finished, tell the user.
224 View Code Duplication
	if (!empty($context['maintenance_finished']))
225
		echo '
226
		<div class="infobox">
227
			', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
228
		</div>';
229
230
	echo '
231
		<div class="cat_bar">
232
			<h3 class="catbg">', $txt['maintain_reattribute_posts'], '</h3>
233
		</div>
234
		<div class="windowbg noup">
235
			<form action="', $scripturl, '?action=admin;area=maintain;sa=members;activity=reattribute" method="post" accept-charset="', $context['character_set'], '">
236
				<p><strong>', $txt['reattribute_guest_posts'], '</strong></p>
237
				<dl class="settings">
238
					<dt>
239
						<label for="type_email"><input type="radio" name="type" id="type_email" value="email" checked>', $txt['reattribute_email'], '</label>
240
					</dt>
241
					<dd>
242
						<input type="text" name="from_email" id="from_email" value="" onclick="document.getElementById(\'type_email\').checked = \'checked\'; document.getElementById(\'from_name\').value = \'\';">
243
					</dd>
244
					<dt>
245
						<label for="type_name"><input type="radio" name="type" id="type_name" value="name">', $txt['reattribute_username'], '</label>
246
					</dt>
247
					<dd>
248
						<input type="text" name="from_name" id="from_name" value="" onclick="document.getElementById(\'type_name\').checked = \'checked\'; document.getElementById(\'from_email\').value = \'\';">
249
					</dd>
250
				</dl>
251
				<dl class="settings">
252
					<dt>
253
						<label for="to"><strong>', $txt['reattribute_current_member'], ':</strong></label>
254
					</dt>
255
					<dd>
256
						<input type="text" name="to" id="to" value="">
257
					</dd>
258
				</dl>
259
				<p class="maintain_members">
260
					<input type="checkbox" name="posts" id="posts" checked>
261
					<label for="posts">', $txt['reattribute_increase_posts'], '</label>
262
				</p>
263
				<input type="submit" id="do_attribute" value="', $txt['reattribute'], '" onclick="if (!checkAttributeValidity()) return false;
264
				return confirm(warningMessage);" class="button">
265
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
266
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
267
			</form>
268
		</div><!-- .windowbg -->
269
		<div class="cat_bar">
270
			<h3 class="catbg">
271
				<a href="', $scripturl, '?action=helpadmin;help=maintenance_members" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ', $txt['maintain_members'], '
272
			</h3>
273
		</div>
274
		<div class="windowbg noup">
275
			<form action="', $scripturl, '?action=admin;area=maintain;sa=members;activity=purgeinactive" method="post" accept-charset="', $context['character_set'], '" id="membersForm">
276
				<p>
277
					<a id="membersLink"></a>', $txt['maintain_members_since1'], '
278
					<select name="del_type">
279
						<option value="activated" selected>', $txt['maintain_members_activated'], '</option>
280
						<option value="logged">', $txt['maintain_members_logged_in'], '</option>
281
					</select>
282
					', $txt['maintain_members_since2'], '
283
					<input type="number" name="maxdays" value="30" size="3">', $txt['maintain_members_since3'], '
284
				</p>
285
				<p>
286
					<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>
287
				</p>
288
				<div style="display: none;" id="membersPanel">';
289
290 View Code Duplication
	foreach ($context['membergroups'] as $group)
291
		echo '
292
					<label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked> ', $group['name'], '</label><br>';
293
294
	echo '
295
				</div>
296
				<input type="submit" value="', $txt['maintain_old_remove'], '" data-confirm="', $txt['maintain_members_confirm'], '" class="button you_sure">
297
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
298
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
299
			</form>
300
		</div><!-- .windowbg -->
301
		<div class="cat_bar">
302
			<h3 class="catbg">', $txt['maintain_recountposts'], '</h3>
303
		</div>
304
		<div class="windowbg noup">
305
			<form action="', $scripturl, '?action=admin;area=maintain;sa=members;activity=recountposts" method="post" accept-charset="', $context['character_set'], '" id="membersRecountForm">
306
				<p>', $txt['maintain_recountposts_info'], '</p>
307
				<input type="submit" value="', $txt['maintain_run_now'], '" class="button">
308
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
309
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
310
			</form>
311
		</div>
312
	</div><!-- #manage_maintenance -->
313
314
	<script>
315
		var oAttributeMemberSuggest = new smc_AutoSuggest({
316
			sSelf: \'oAttributeMemberSuggest\',
317
			sSessionId: smf_session_id,
318
			sSessionVar: smf_session_var,
319
			sSuggestId: \'attributeMember\',
320
			sControlId: \'to\',
321
			sSearchType: \'member\',
322
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
323
			bItemList: false
324
		});
325
	</script>';
326
}
327
328
/**
329
 * Template for the topic maintenance tasks.
330
 */
331
function template_maintain_topics()
332
{
333
	global $scripturl, $txt, $context, $settings, $modSettings;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
334
335
	// If maintenance has finished tell the user.
336 View Code Duplication
	if (!empty($context['maintenance_finished']))
337
		echo '
338
	<div class="infobox">
339
		', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
340
	</div>';
341
342
	// Bit of javascript for showing which boards to prune in an otherwise hidden list.
343
	echo '
344
	<script>
345
		var rotSwap = false;
346
		function swapRot()
347
		{
348
			rotSwap = !rotSwap;
349
350
			// Toggle icon
351
			document.getElementById("rotIcon").src = smf_images_url + (rotSwap ? "/selected_open.png" : "/selected.png");
352
			setInnerHTML(document.getElementById("rotText"), rotSwap ? ', JavaScriptEscape($txt['maintain_old_choose']), ' : ', JavaScriptEscape($txt['maintain_old_all']), ');
353
354
			// Toggle panel
355
			$("#rotPanel").slideToggle(300);
356
357
			// Toggle checkboxes
358
			var rotPanel = document.getElementById(\'rotPanel\');
359
			var oBoardCheckBoxes = rotPanel.getElementsByTagName(\'input\');
360
			for (var i = 0; i < oBoardCheckBoxes.length; i++)
361
			{
362
				if (oBoardCheckBoxes[i].type.toLowerCase() == "checkbox")
363
					oBoardCheckBoxes[i].checked = !rotSwap;
364
			}
365
		}
366
	</script>';
367
368
	echo '
369
	<div id="manage_maintenance">
370
		<div class="cat_bar">
371
			<h3 class="catbg">', $txt['maintain_old'], '</h3>
372
		</div>
373
		<div class="windowbg noup">
374
			<div class="flow_auto">
375
				<form action="', $scripturl, '?action=admin;area=maintain;sa=topics;activity=pruneold" method="post" accept-charset="', $context['character_set'], '">';
376
377
	// The otherwise hidden "choose which boards to prune".
378
	echo '
379
					<p>
380
						<a id="rotLink"></a>', $txt['maintain_old_since_days1'], '<input type="number" name="maxdays" value="30" size="3">', $txt['maintain_old_since_days2'], '
381
					</p>
382
					<p>
383
						<label for="delete_type_nothing"><input type="radio" name="delete_type" id="delete_type_nothing" value="nothing"> ', $txt['maintain_old_nothing_else'], '</label><br>
384
						<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>
385
						<label for="delete_type_locked"><input type="radio" name="delete_type" id="delete_type_locked" value="locked"> ', $txt['maintain_old_are_locked'], '</label><br>
386
					</p>
387
					<p>
388
						<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>
389
					</p>
390
					<p>
391
						<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>
392
					</p>
393
					<div style="display: none;" id="rotPanel" class="flow_hidden">
394
						<div class="floatleft" style="width: 49%">';
395
396
	// This is the "middle" of the list.
397
	$middle = ceil(count($context['categories']) / 2);
398
399
	$i = 0;
400 View Code Duplication
	foreach ($context['categories'] as $category)
401
	{
402
		echo '
403
							<fieldset>
404
								<legend>', $category['name'], '</legend>
405
								<ul>';
406
407
		// Display a checkbox with every board.
408
		foreach ($category['boards'] as $board)
409
			echo '
410
									<li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;">
411
										<label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked>', $board['name'], '</label>
412
									</li>';
413
414
		echo '
415
								</ul>
416
							</fieldset>';
417
418
		// Increase $i, and check if we're at the middle yet.
419
		if (++$i == $middle)
420
			echo '
421
						</div><!-- .floatleft -->
422
						<div class="floatright" style="width: 49%;">';
423
	}
424
425
	echo '
426
						</div>
427
					</div><!-- #rotPanel -->
428
					<input type="submit" value="', $txt['maintain_old_remove'], '" data-confirm="', $txt['maintain_old_confirm'], '" class="button you_sure">
429
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
430
					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
431
				</form>
432
			</div><!-- .flow_auto -->
433
		</div><!-- .windowbg -->
434
435
		<div class="cat_bar">
436
			<h3 class="catbg">', $txt['maintain_old_drafts'], '</h3>
437
		</div>
438
		<div class="windowbg noup">
439
			<form action="', $scripturl, '?action=admin;area=maintain;sa=topics;activity=olddrafts" method="post" accept-charset="', $context['character_set'], '">
440
				<p>
441
					', $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'], '
442
				</p>
443
				<input type="submit" value="', $txt['maintain_old_remove'], '" data-confirm="', $txt['maintain_old_drafts_confirm'], '" class="button you_sure">
444
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
445
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
446
			</form>
447
		</div>
448
		<div class="cat_bar">
449
			<h3 class="catbg">', $txt['move_topics_maintenance'], '</h3>
450
		</div>
451
		<div class="windowbg noup">
452
			<form action="', $scripturl, '?action=admin;area=maintain;sa=topics;activity=massmove" method="post" accept-charset="', $context['character_set'], '">
453
				<p>
454
					<label for="id_board_from">', $txt['move_topics_from'], ' </label>
455
					<select name="id_board_from" id="id_board_from">
456
						<option disabled>(', $txt['move_topics_select_board'], ')</option>';
457
458
	// From board
459 View Code Duplication
	foreach ($context['categories'] as $category)
460
	{
461
		echo '
462
						<optgroup label="', $category['name'], '">';
463
464
		foreach ($category['boards'] as $board)
465
			echo '
466
							<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
467
468
		echo '
469
						</optgroup>';
470
	}
471
472
	echo '
473
					</select>
474
					<label for="id_board_to">', $txt['move_topics_to'], '</label>
475
					<select name="id_board_to" id="id_board_to">
476
						<option disabled>(', $txt['move_topics_select_board'], ')</option>';
477
478
	// To board
479 View Code Duplication
	foreach ($context['categories'] as $category)
480
	{
481
		echo '
482
						<optgroup label="', $category['name'], '">';
483
484
		foreach ($category['boards'] as $board)
485
			echo '
486
							<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
487
488
		echo '
489
						</optgroup>';
490
	}
491
	echo '
492
					</select>
493
				</p>
494
				<p>
495
					', $txt['move_topics_older_than'], '
496
					<input type="number" name="maxdays" value="30" size="3">
497
					', $txt['manageposts_days'], ' (', $txt['move_zero_all'], ')
498
				</p>
499
				<p>
500
					<label for="move_type_locked"><input type="checkbox" name="move_type_locked" id="move_type_locked" checked> ', $txt['move_type_locked'], '</label><br>
501
					<label for="move_type_sticky"><input type="checkbox" name="move_type_sticky" id="move_type_sticky"> ', $txt['move_type_sticky'], '</label><br>
502
				</p>
503
				<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">
504
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
505
				<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
506
			</form>
507
		</div><!-- .windowbg -->
508
	</div><!-- #manage_maintenance -->';
509
}
510
511
/**
512
 * Simple template for showing results of our optimization...
513
 */
514
function template_optimize()
515
{
516
	global $context, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
517
518
	echo '
519
	<div id="manage_maintenance">
520
		<div class="cat_bar">
521
			<h3 class="catbg">', $txt['maintain_optimize'], '</h3>
522
		</div>
523
		<div class="windowbg">
524
			<p>
525
				', $txt['database_numb_tables'], '<br>
526
				', $txt['database_optimize_attempt'], '<br>';
527
528
	// List each table being optimized...
529
	foreach ($context['optimized_tables'] as $table)
530
		echo '
531
				', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>';
532
533
	// How did we go?
534
	echo '
535
				<br>
536
				', $context['num_tables_optimized'] == 0 ? $txt['database_already_optimized'] : $context['num_tables_optimized'] . ' ' . $txt['database_optimized'];
537
538
	echo '
539
			</p>
540
			<p><a href="', $scripturl, '?action=admin;area=maintain">', $txt['maintain_return'], '</a></p>
541
		</div><!-- .windowbg -->
542
	</div><!-- #manage_maintenance -->';
543
}
544
545
/**
546
 * Template for converting entities to UTF-8 characters
547
 */
548
function template_convert_entities()
549
{
550
	global $context, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
551
552
	echo '
553
	<div id="manage_maintenance">
554
		<div class="cat_bar">
555
			<h3 class="catbg">', $txt['entity_convert_title'], '</h3>
556
		</div>
557
		<div class="windowbg">
558
			<p>', $txt['entity_convert_introduction'], '</p>
559
			<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'], '">
560
			<input type="submit" value="', $txt['entity_convert_proceed'], '" class="button">
561
			</form>
562
		</div>
563
	</div>';
564
}
565
566
/**
567
 * Template for converting posts to UTF-8.
568
 */
569
function template_convert_msgbody()
570
{
571
	global $context, $txt, $scripturl;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
572
573
	echo '
574
	<div id="manage_maintenance">
575
		<div class="cat_bar">
576
			<h3 class="catbg">', $txt[$context['convert_to'] . '_title'], '</h3>
577
		</div>
578
		<div class="windowbg">
579
			<p>', $txt['body_checking_introduction'], '</p>';
580
581
	if (!empty($context['exceeding_messages']))
582
	{
583
		echo '
584
			<p class="noticebox">', $txt['exceeding_messages'], '</p>
585
			<ul>
586
				<li>
587
				', implode('</li><li>', $context['exceeding_messages']), '
588
				</li>
589
			</ul>';
590
591
		if (!empty($context['exceeding_messages_morethan']))
592
			echo '
593
			<p>', $context['exceeding_messages_morethan'], '</p>';
594
	}
595
	else
596
		echo '
597
			<p class="infobox">', $txt['convert_to_text'], '</p>';
598
599
	echo '
600
			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '">
601
			<hr>
602
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
603
			<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
604
			<input type="submit" name="do_conversion" value="', $txt['entity_convert_proceed'], '" class="button">
605
			</form>
606
		</div><!-- .windowbg -->
607
	</div><!-- #manage_maintenance -->';
608
}
609
610
?>