Passed
Pull Request — release-2.1 (#5487)
by John
04:27
created

template_pick()   B

Complexity

Conditions 7
Paths 3

Size

Total Lines 61
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 25
c 0
b 0
f 0
nc 3
nop 0
dl 0
loc 61
rs 8.5866

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 2019 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 RC1
11
 */
12
13
/**
14
 * The main sub template - for theme administration.
15
 */
16
function template_main()
17
{
18
	global $context, $scripturl, $txt, $modSettings;
19
20
	// Theme install info.
21
	echo '
22
		<div class="cat_bar">
23
			<h3 class="catbg">
24
				<a href="', $scripturl, '?action=helpadmin;help=themes" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a>
25
				', $txt['themeadmin_title'], '
26
			</h3>
27
		</div>
28
		<div class="information">
29
			', $txt['themeadmin_explain'], '
30
		</div>';
31
32
	echo '
33
		<form action="', $scripturl, '?action=admin;area=theme;sa=admin" method="post" accept-charset="', $context['character_set'], '">
34
			<div class="cat_bar">
35
				<h3 class="catbg">',
36
					$txt['settings'], '
37
				</h3>
38
			</div>
39
			<div class="windowbg">
40
				<dl class="settings">
41
					<dt>
42
						<label for="options-theme_allow"> ', $txt['theme_allow'], '</label>
43
					</dt>
44
					<dd>
45
						<input type="hidden" value="0" name="options[theme_allow]">
46
						<input type="checkbox" name="options[theme_allow]" id="options-theme_allow" value="1"', !empty($modSettings['theme_allow']) ? ' checked' : '', '>
47
					</dd>
48
					<dt>
49
						<label for="known_themes_list">', $txt['themeadmin_selectable'], '</label>:
50
					</dt>
51
					<dd>
52
						<div id="known_themes_list">';
53
54
	foreach ($context['themes'] as $theme)
55
		echo '
56
							<label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', '> ', $theme['name'], '</label><br>';
57
58
	echo '
59
						</div>
60
						<a href="javascript:void(0);" onclick="document.getElementById(\'known_themes_list\').classList.remove(\'hidden\'); document.getElementById(\'known_themes_link\').classList.add(\'hidden\'); return false; " id="known_themes_link" class="hidden">[ ', $txt['themeadmin_themelist_link'], ' ]</a>
61
						<script>
62
							document.getElementById("known_themes_list").classList.add(\'hidden\');
63
							document.getElementById("known_themes_link").classList.remove(\'hidden\');
64
						</script>
65
					</dd>
66
					<dt>
67
						<label for="theme_guests">', $txt['theme_guests'], ':</label>
68
					</dt>
69
					<dd>
70
						<select name="options[theme_guests]" id="theme_guests">';
71
72
	// Put an option for each theme in the select box.
73
	foreach ($context['themes'] as $theme)
74
		echo '
75
							<option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
76
77
	echo '
78
						</select>
79
						<span class="smalltext pick_theme"><a href="', $scripturl, '?action=theme;sa=pick;u=-1;', $context['session_var'], '=', $context['session_id'], '">', $txt['theme_select'], '</a></span>
80
					</dd>
81
					<dt>
82
						<label for="theme_reset">', $txt['theme_reset'], '</label>:
83
					</dt>
84
					<dd>
85
						<select name="theme_reset" id="theme_reset">
86
							<option value="-1" selected>', $txt['theme_nochange'], '</option>
87
							<option value="0">', $txt['theme_forum_default'], '</option>';
88
89
	// Same thing, this time for changing the theme of everyone.
90
	foreach ($context['themes'] as $theme)
91
		echo '
92
							<option value="', $theme['id'], '">', $theme['name'], '</option>';
93
94
	echo '
95
						</select>
96
						<span class="smalltext pick_theme"><a href="', $scripturl, '?action=theme;sa=pick;u=0;', $context['session_var'], '=', $context['session_id'], '">', $txt['theme_select'], '</a></span>
97
					</dd>
98
				</dl>
99
				<input type="submit" name="save" value="' . $txt['save'] . '" class="button">
100
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
101
				<input type="hidden" name="', $context['admin-tm_token_var'], '" value="', $context['admin-tm_token'], '">
102
			</div><!-- .windowbg -->
103
		</form>';
104
105
	// Link to simplemachines.org for latest themes and info!
106
	echo '
107
		<div class="cat_bar">
108
			<h3 class="catbg">
109
				', $txt['theme_adding_title'], '
110
			</h3>
111
		</div>
112
		<div class="windowbg">
113
			', $txt['theme_adding'], '
114
		</div>';
115
116
	// All the install options.
117
	echo '
118
		<div id="admin_form_wrapper">
119
			<div class="cat_bar">
120
				<h3 class="catbg">
121
					', $txt['theme_install'], '
122
				</h3>
123
			</div>
124
			<div class="windowbg">';
125
126
	if ($context['can_create_new'])
127
	{
128
		// From a file.
129
		echo '
130
				<fieldset>
131
					<legend>', $txt['theme_install_file'], '</legend>
132
					<form action="', $scripturl, '?action=admin;area=theme;sa=install;do=file" method="post" accept-charset="', $context['character_set'], '" enctype="multipart/form-data" class="padding">
133
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
134
						<input type="hidden" name="', $context['admin-t-file_token_var'], '" value="', $context['admin-t-file_token'], '">
135
						<input type="file" name="theme_gz" id="theme_gz" value="theme_gz" size="40" onchange="this.form.copy.disabled = this.value != \'\'; this.form.theme_dir.disabled = this.value != \'\';">
136
						<input type="submit" name="save_file" value="' . $txt['upload'] . '" class="button">
137
					</form>
138
				</fieldset>';
139
140
		// Copied from the default.
141
		echo '
142
				<fieldset>
143
					<legend>', $txt['theme_install_new'], '</legend>
144
					<form action="', $scripturl, '?action=admin;area=theme;sa=install;do=copy" method="post" accept-charset="', $context['character_set'], '" class="padding">
145
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
146
						<input type="hidden" name="', $context['admin-t-copy_token_var'], '" value="', $context['admin-t-copy_token'], '">
147
						<input type="text" name="copy" id="copy" value="', $context['new_theme_name'], '" size="40">
148
						<input type="submit" name="save_copy" value="' . $txt['save'] . '" class="button">
149
					</form>
150
				</fieldset>';
151
	}
152
153
	// From a dir.
154
	echo '
155
				<fieldset>
156
					<legend>', $txt['theme_install_dir'], '</legend>
157
					<form action="', $scripturl, '?action=admin;area=theme;sa=install;do=dir" method="post" accept-charset="', $context['character_set'], '" class="padding">
158
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
159
						<input type="hidden" name="', $context['admin-t-dir_token_var'], '" value="', $context['admin-t-dir_token'], '">
160
						<input type="text" name="theme_dir" id="theme_dir" value="', $context['new_theme_dir'], '" size="40">
161
						<input type="submit" name="save_dir" value="' . $txt['save'] . '" class="button">
162
					</form>
163
				</fieldset>';
164
165
	echo '
166
			</div><!-- .windowbg -->
167
		</div><!-- #admin_form_wrapper -->';
168
169
	echo '
170
	<script>
171
		window.smfForum_scripturl = smf_scripturl;
172
		window.smfForum_sessionid = smf_session_id;
173
		window.smfForum_sessionvar = smf_session_var;
174
		window.smfThemes_writable = ', $context['can_create_new'] ? 'true' : 'false', ';
175
	</script>';
176
}
177
178
/**
179
 * This lists all themes
180
 */
181
function template_list_themes()
182
{
183
	global $context, $scripturl, $txt;
184
185
	// Show a nice confirmation message.
186
	if (isset($_GET['done']))
187
		echo '
188
	<div class="infobox">
189
		', $txt['theme_confirmed_' . $_GET['done']], '
190
	</div>';
191
192
	echo '
193
		<div class="cat_bar">
194
			<h3 class="catbg">', $txt['themeadmin_list_heading'], '</h3>
195
		</div>
196
		<div class="information">
197
			', $txt['themeadmin_list_tip'], '
198
		</div>
199
		<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=theme;', $context['session_var'], '=', $context['session_id'], ';sa=list" method="post" accept-charset="', $context['character_set'], '">
200
			<div class="cat_bar">
201
				<h3 class="catbg">', $txt['theme_settings'], '</h3>
202
			</div>
203
			<br>';
204
205
	// Show each theme.... with X for delete, an enable/disable link and a link to their own settings page.
206
	foreach ($context['themes'] as $theme)
207
	{
208
		echo '
209
			<div class="cat_bar">
210
				<h3 class="catbg">
211
					<span class="floatleft">
212
						', (!empty($theme['enable']) || $theme['id'] == 1 ? '<a href="' . $scripturl . '?action=admin;area=theme;th=' . $theme['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=list">' . $theme['name'] . '</a>' : $theme['name']), '', (!empty($theme['version']) ? ' <em>(' . $theme['version'] . ')</em>' : ''), '
213
					</span>';
214
215
		// You *cannot* disable/enable/delete the default theme. It's important!
216
		if ($theme['id'] != 1)
217
		{
218
			echo '
219
					<span class="floatright">';
220
221
			// Enable/Disable.
222
			echo '
223
						<a href="', $scripturl, '?action=admin;area=theme;sa=enable;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['admin-tre_token_var'], '=', $context['admin-tre_token'], '', (!empty($theme['enable']) ? ';disabled' : ''), '" data-confirm="', $txt['theme_' . (!empty($theme['enable']) ? 'disable' : 'enable') . '_confirm'], '" class="you_sure"><span class="main_icons ', !empty($theme['enable']) ? 'disable' : 'enable', '" title="', $txt['theme_' . (!empty($theme['enable']) ? 'disable' : 'enable')], '"></span></a>';
224
225
			// Deleting.
226
			echo '
227
						<a href="', $scripturl, '?action=admin;area=theme;sa=remove;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['admin-tr_token_var'], '=', $context['admin-tr_token'], '" data-confirm="', $txt['theme_remove_confirm'], '" class="you_sure"><span class="main_icons delete" title="', $txt['theme_remove'], '"></span></a>';
228
229
			echo '
230
					</span>';
231
		}
232
233
		echo '
234
				</h3>
235
			</div><!-- .cat_bar -->
236
			<div class="windowbg">
237
				<dl class="settings themes_list">
238
					<dt>', $txt['themeadmin_list_theme_dir'], ':</dt>
239
					<dd', $theme['valid_path'] ? '' : ' class="error"', '>', $theme['theme_dir'], $theme['valid_path'] ? '' : ' ' . $txt['themeadmin_list_invalid'], '</dd>
240
					<dt>', $txt['themeadmin_list_theme_url'], ':</dt>
241
					<dd>', $theme['theme_url'], '</dd>
242
					<dt>', $txt['themeadmin_list_images_url'], ':</dt>
243
					<dd>', $theme['images_url'], '</dd>
244
				</dl>
245
			</div>';
246
	}
247
248
	echo '
249
			<div class="cat_bar">
250
				<h3 class="catbg">', $txt['themeadmin_list_reset'], '</h3>
251
			</div>
252
			<div class="windowbg">
253
				<dl class="settings">
254
					<dt>
255
						<label for="reset_dir">', $txt['themeadmin_list_reset_dir'], '</label>:
256
					</dt>
257
					<dd>
258
						<input type="text" name="reset_dir" id="reset_dir" value="', $context['reset_dir'], '" size="40">
259
					</dd>
260
					<dt>
261
						<label for="reset_url">', $txt['themeadmin_list_reset_url'], '</label>:
262
					</dt>
263
					<dd>
264
						<input type="text" name="reset_url" id="reset_url" value="', $context['reset_url'], '" size="40">
265
					</dd>
266
				</dl>
267
				<input type="submit" name="save" value="', $txt['themeadmin_list_reset_go'], '" class="button">
268
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
269
				<input type="hidden" name="', $context['admin-tl_token_var'], '" value="', $context['admin-tl_token'], '">
270
			</div>
271
		</form>';
272
}
273
274
/**
275
 * This lets you reset themes
276
 */
277
function template_reset_list()
278
{
279
	global $context, $scripturl, $txt;
280
281
	echo '
282
		<div class="cat_bar">
283
			<h3 class="catbg">', $txt['themeadmin_reset_title'], '</h3>
284
		</div>
285
		<div class="information">
286
			', $txt['themeadmin_reset_tip'], '
287
		</div>
288
		<div id="admin_form_wrapper">';
289
290
	// Show each theme.... with X for delete and a link to settings.
291
	foreach ($context['themes'] as $theme)
292
	{
293
		echo '
294
			<div class="cat_bar">
295
				<h3 class="catbg">', $theme['name'], '</h3>
296
			</div>
297
			<div class="windowbg">
298
				<ul>
299
					<li>
300
						<a href="', $scripturl, '?action=admin;area=theme;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=reset">', $txt['themeadmin_reset_defaults'], '</a> <em class="smalltext">(', $theme['num_default_options'], ' ', $txt['themeadmin_reset_defaults_current'], ')</em>
301
					</li>
302
					<li>
303
						<a href="', $scripturl, '?action=admin;area=theme;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=reset;who=1">', $txt['themeadmin_reset_members'], '</a>
304
					</li>
305
					<li>
306
						<a href="', $scripturl, '?action=admin;area=theme;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=reset;who=2;', $context['admin-stor_token_var'], '=', $context['admin-stor_token'], '" data-confirm="', $txt['themeadmin_reset_remove_confirm'], '" class="you_sure">', $txt['themeadmin_reset_remove'], '</a> <em class="smalltext">(', $theme['num_members'], ' ', $txt['themeadmin_reset_remove_current'], ')</em>
307
					</li>
308
				</ul>
309
			</div>';
310
	}
311
312
	echo '
313
		</div><!-- #admin_form_wrapper -->';
314
}
315
316
/**
317
 * This displays the form for setting theme options
318
 */
319
function template_set_options()
320
{
321
	global $context, $scripturl, $txt;
322
323
	echo '
324
		<form action="', $scripturl, '?action=admin;area=theme;th=', $context['theme_settings']['theme_id'], ';sa=reset" method="post" accept-charset="', $context['character_set'], '">
325
			<input type="hidden" name="who" value="', $context['theme_options_reset'] ? 1 : 0, '">
326
			<div class="cat_bar">
327
				<h3 class="catbg">
328
					', $txt['theme_options_title'], ' - ', $context['theme_settings']['name'], '
329
				</h3>
330
			</div>
331
			<div class="information noup">
332
				', $context['theme_options_reset'] ? $txt['themeadmin_reset_options_info'] : $txt['theme_options_defaults'], '
333
			</div>
334
			<div class="windowbg noup">
335
				<dl class="settings">';
336
337
	$skeys = array_keys($context['options']);
338
	$first_option_key = array_shift($skeys);
339
	$titled_section = false;
340
341
	foreach ($context['options'] as $i => $setting)
342
	{
343
		// Just spit out separators and move on
344
		if (empty($setting) || !is_array($setting))
345
		{
346
			// Insert a separator (unless this is the first item in the list)
347
			if ($i !== $first_option_key)
348
				echo '
349
				</dl>
350
				<hr>
351
				<dl class="settings">';
352
353
			// Should we give a name to this section?
354
			if (is_string($setting) && !empty($setting))
355
			{
356
				$titled_section = true;
357
				echo '
358
					<dt><strong>' . $setting . '</strong></dt>
359
					<dd></dd>';
360
			}
361
			else
362
				$titled_section = false;
363
364
			continue;
365
		}
366
367
		echo '
368
					<dt>';
369
370
		// Show the change option box?
371
		if ($context['theme_options_reset'])
372
			echo '
373
						<span class="floatleft">
374
							<select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;">
375
								<option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option>
376
								<option value="1">', $txt['themeadmin_reset_options_change'], '</option>
377
								<option value="2">', $txt['themeadmin_reset_options_default'], '</option>
378
							</select>
379
						</span>';
380
381
		echo '
382
						<label for="options_', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
383
384
		if (isset($setting['description']))
385
			echo '
386
						<br>
387
						<span class="smalltext">', $setting['description'], '</span>';
388
		echo '
389
					</dt>';
390
391
		// Display checkbox options
392
		if ($setting['type'] == 'checkbox')
393
			echo '
394
					<dd>
395
						<input type="hidden" name="' . (!empty($setting['default']) ? 'default_' : '') . 'options[' . $setting['id'] . ']" value="0">
396
						<input type="checkbox" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '"', !empty($setting['value']) ? ' checked' : '', $context['theme_options_reset'] ? ' disabled' : '', ' value="1" class="floatleft">';
397
398
		// How about selection lists, we all love them
399
		elseif ($setting['type'] == 'list')
400
		{
401
			echo '
402
					<dd>
403
						<select class="floatleft" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '"', $context['theme_options_reset'] ? ' disabled' : '', '>';
404
405
			foreach ($setting['options'] as $value => $label)
406
				echo '
407
							<option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>';
408
409
			echo '
410
						</select>';
411
		}
412
		// A textbox it is then
413
		else
414
		{
415
			echo '
416
					<dd>';
417
418
			if (isset($setting['type']) && $setting['type'] == 'number')
419
			{
420
				$min = isset($setting['min']) ? ' min="' . $setting['min'] . '"' : ' min="0"';
421
				$max = isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '';
422
				$step = isset($setting['step']) ? ' step="' . $setting['step'] . '"' : '';
423
424
				echo '
425
						<input type="number"', $min . $max . $step;
426
			}
427
			elseif (isset($setting['type']) && $setting['type'] == 'url')
428
				echo '
429
						<input type="url"';
430
431
			else
432
				echo '
433
						<input type="text"';
434
435
			echo ' name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '" value="', $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', $context['theme_options_reset'] ? ' disabled' : '', '>';
436
		}
437
438
		// End of this defintion, close open dds
439
		echo '
440
					</dd>';
441
	}
442
443
	// Close the option page up
444
	echo '
445
				</dl>
446
				<input type="submit" name="submit" value="', $txt['save'], '" class="button">
447
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
448
				<input type="hidden" name="', $context['admin-sto_token_var'], '" value="', $context['admin-sto_token'], '">
449
			</div>
450
		</form>';
451
}
452
453
/**
454
 * The page for setting and managing theme settings.
455
 */
456
function template_set_settings()
457
{
458
	global $context, $settings, $scripturl, $txt;
459
460
	echo '
461
	<div id="admin_form_wrapper">
462
		<form action="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['theme_settings']['theme_id'], '" method="post" accept-charset="', $context['character_set'], '">
463
			<div class="cat_bar">
464
				<h3 class="catbg">
465
					<a href="', $scripturl, '?action=helpadmin;help=theme_settings" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a> ', $txt['theme_settings'], ' - ', $context['theme_settings']['name'], '
466
				</h3>
467
			</div>
468
			<div class="windowbg">';
469
470
	// @todo Why can't I edit the default theme popup.
471
	if ($context['theme_settings']['theme_id'] != 1)
472
		echo '
473
				<div class="title_bar">
474
					<h3 class="titlebg config_hd">
475
						', $txt['theme_edit'], '
476
					</h3>
477
				</div>
478
				<div class="windowbg">
479
					<ul>
480
						<li>
481
							<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_settings']['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=edit;filename=index.template.php">', $txt['theme_edit_index'], '</a>
482
						</li>
483
						<li>
484
							<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_settings']['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=edit;directory=css">', $txt['theme_edit_style'], '</a>
485
						</li>
486
					</ul>
487
				</div>';
488
489
	echo '
490
				<div class="title_bar">
491
					<h3 class="titlebg config_hd">
492
						', $txt['theme_url_config'], '
493
					</h3>
494
				</div>
495
				<dl class="settings">
496
					<dt>
497
						<label for="theme_name">', $txt['actual_theme_name'], '</label>
498
					</dt>
499
					<dd>
500
						<input type="text" id="theme_name" name="options[name]" value="', $context['theme_settings']['name'], '" size="32">
501
					</dd>
502
					<dt>
503
						<label for="theme_url">', $txt['actual_theme_url'], '</label>
504
					</dt>
505
					<dd>
506
						<input type="text" id="theme_url" name="options[theme_url]" value="', $context['theme_settings']['actual_theme_url'], '" size="50">
507
					</dd>
508
					<dt>
509
						<label for="images_url">', $txt['actual_images_url'], '</label>
510
					</dt>
511
					<dd>
512
						<input type="text" id="images_url" name="options[images_url]" value="', $context['theme_settings']['actual_images_url'], '" size="50">
513
					</dd>
514
					<dt>
515
						<label for="theme_dir">', $txt['actual_theme_dir'], '</label>
516
					</dt>
517
					<dd>
518
						<input type="text" id="theme_dir" name="options[theme_dir]" value="', $context['theme_settings']['actual_theme_dir'], '" size="50">
519
					</dd>
520
				</dl>';
521
522
	// Do we allow theme variants?
523
	if (!empty($context['theme_variants']))
524
	{
525
		echo '
526
				<div class="title_bar">
527
					<h3 class="titlebg config_hd">
528
						', $txt['theme_variants'], '
529
					</h3>
530
				</div>
531
				<dl class="settings">
532
					<dt>
533
						<label for="variant">', $txt['theme_variants_default'], '</label>:
534
					</dt>
535
					<dd>
536
						<select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">';
537
538
		foreach ($context['theme_variants'] as $key => $variant)
539
			echo '
540
							<option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
541
542
		echo '
543
						</select>
544
					</dd>
545
					<dt>
546
						<label for="disable_user_variant">', $txt['theme_variants_user_disable'], '</label>:
547
					</dt>
548
					<dd>
549
						<input type="hidden" name="options[disable_user_variant]" value="0">
550
						<input type="checkbox" name="options[disable_user_variant]" id="disable_user_variant"', !empty($context['theme_settings']['disable_user_variant']) ? ' checked' : '', ' value="1">
551
					</dd>
552
				</dl>
553
				<img src="', $context['theme_variants'][$context['default_variant']]['thumbnail'], '" id="variant_preview" alt="">';
554
	}
555
556
	echo '
557
				<div class="title_bar">
558
					<h3 class="titlebg config_hd">
559
						', $txt['theme_options'], '
560
					</h3>
561
				</div>
562
				<dl class="settings">';
563
564
	$skeys = array_keys($context['settings']);
565
	$first_setting_key = array_shift($skeys);
566
	$titled_section = false;
567
568
	foreach ($context['settings'] as $i => $setting)
569
	{
570
		// Is this a separator?
571
		if (empty($setting) || !is_array($setting))
572
		{
573
			// We don't need a separator before the first list element
574
			if ($i !== $first_setting_key)
575
				echo '
576
				</dl>
577
				<hr>
578
				<dl class="settings">';
579
580
			// Add a fake heading?
581
			if (is_string($setting) && !empty($setting))
582
			{
583
				$titled_section = true;
584
				echo '
585
					<dt><strong>' . $setting . '</strong></dt>
586
					<dd></dd>';
587
			}
588
			else
589
				$titled_section = false;
590
591
			continue;
592
		}
593
594
		echo '
595
					<dt>
596
						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>:';
597
598
		if (isset($setting['description']))
599
			echo '<br>
600
						<span class="smalltext">', $setting['description'], '</span>';
601
602
		echo '
603
					</dt>';
604
605
		// A checkbox?
606
		if ($setting['type'] == 'checkbox')
607
			echo '
608
					<dd>
609
						<input type="hidden" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" value="0">
610
						<input type="checkbox" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($setting['value']) ? ' checked' : '', ' value="1">
611
					</dd>';
612
613
		// A list with options?
614
		elseif ($setting['type'] == 'list')
615
		{
616
			echo '
617
					<dd>
618
						<select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">';
619
620
			foreach ($setting['options'] as $value => $label)
621
				echo '
622
							<option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>';
623
624
			echo '
625
						</select>
626
					</dd>';
627
		}
628
		// A Textarea?
629
		elseif ($setting['type'] == 'textarea')
630
		{
631
			echo '
632
					<dd>
633
						<textarea rows="4" style="width: 95%;" cols="40" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">', $setting['value'], '</textarea>
634
					</dd>';
635
		}
636
		// A regular input box, then?
637
		else
638
		{
639
			echo '
640
					<dd>';
641
642
			if (isset($setting['type']) && $setting['type'] == 'number')
643
			{
644
				$min = isset($setting['min']) ? ' min="' . $setting['min'] . '"' : ' min="0"';
645
				$max = isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '';
646
				$step = isset($setting['step']) ? ' step="' . $setting['step'] . '"' : '';
647
648
				echo '
649
						<input type="number"', $min . $max . $step;
650
			}
651
			elseif (isset($setting['type']) && $setting['type'] == 'url')
652
				echo '
653
						<input type="url"';
654
655
			else
656
				echo '
657
						<input type="text"';
658
659
			echo ' name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '" value="', $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : (empty($setting['size']) ? ' size="40"' : ' size="' . $setting['size'] . '"'), '>
660
					</dd>';
661
		}
662
	}
663
664
	echo '
665
				</dl>
666
				<input type="submit" name="save" value="', $txt['save'], '" class="button">
667
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
668
				<input type="hidden" name="', $context['admin-sts_token_var'], '" value="', $context['admin-sts_token'], '">
669
			</div><!-- .windowbg -->
670
		</form>
671
	</div><!-- #admin_form_wrapper -->';
672
673
	if (!empty($context['theme_variants']))
674
	{
675
		echo '
676
		<script>
677
		var oThumbnails = {';
678
679
		// All the variant thumbnails.
680
		$count = 1;
681
		foreach ($context['theme_variants'] as $key => $variant)
682
		{
683
			echo '
684
			\'', $key, '\': \'', $variant['thumbnail'], '\'', (count($context['theme_variants']) == $count ? '' : ',');
685
			$count++;
686
		}
687
688
		echo '
689
		}
690
		</script>';
691
	}
692
}
693
694
/**
695
 * This template allows for the selection of different themes ;)
696
 */
697
function template_pick()
698
{
699
	global $context, $scripturl, $txt;
700
701
	echo '
702
	<div id="pick_theme">
703
		<form action="', $scripturl, '?action=theme;sa=pick" method="post" accept-charset="', $context['character_set'], '">';
704
705
	// Just go through each theme and show its information - thumbnail, etc.
706
	foreach ($context['available_themes'] as $theme)
707
	{
708
		echo '
709
			<div class="cat_bar">
710
				<h3 class="catbg">
711
					', $theme['name'], '
712
				</h3>
713
			</div>
714
			<div class="windowbg', $theme['selected'] ? ' selected' : '', '">
715
				<div class="flow_hidden">
716
					<div class="floatright">
717
						<a href="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';theme=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], '" id="theme_thumb_preview_', $theme['id'], '" title="', $txt['theme_preview'], '">
718
							<img src="', $theme['thumbnail_href'], '" id="theme_thumb_', $theme['id'], '" alt="" class="padding">
719
						</a>
720
					</div>
721
					<p>', $theme['description'], '</p>';
722
723
		if (!empty($theme['variants']))
724
		{
725
			echo '
726
					<label for="variant', $theme['id'], '"><strong>', $theme['pick_label'], '</strong></label>:
727
					<select id="variant', $theme['id'], '" name="vrt[', $theme['id'], ']" onchange="changeVariant(', $theme['id'], ', this);">';
728
729
			foreach ($theme['variants'] as $key => $variant)
730
				echo '
731
						<option value="', $key, '"', $theme['selected_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
732
733
			echo '
734
					</select>';
735
		}
736
737
		echo '
738
					<br>
739
					<p>
740
						<em class="smalltext">', $theme['num_users'], ' ', ($theme['num_users'] == 1 ? $txt['theme_user'] : $txt['theme_users']), '</em>
741
					</p>
742
					<br>
743
					<ul>
744
						<li class="lower_padding">
745
							<input type="submit" name="save[', $theme['id'], ']" value="', $txt['theme_set'], '" class="button">
746
						</li>
747
						<li>
748
							<a class="button" href="', $scripturl, '?action=theme;sa=pick;theme=', $theme['id'], '" id="theme_preview_', $theme['id'], '">', $txt['theme_preview'], '</a>
749
						</li>
750
					</ul>
751
				</div>
752
			</div>';
753
		}
754
755
		echo '
756
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
757
			<input type="hidden" name="u" value="', $context['current_member'], '">
758
		</form>
759
	</div><!-- #pick_theme -->';
760
}
761
762
/**
763
 * Okay, that theme was installed/updated successfully!
764
 */
765
function template_installed()
766
{
767
	global $context, $scripturl, $txt;
768
769
	// The aftermath.
770
	echo '
771
		<div class="cat_bar">
772
			<h3 class="catbg">', $context['page_title'], '</h3>
773
		</div>
774
		<div class="windowbg">';
775
776
	// Oops! there was an error :(
777
	if (!empty($context['error_message']))
778
		echo '
779
			<p>
780
				', $context['error_message'], '
781
			</p>';
782
783
	// Not much to show except a link back...
784
	else
785
		echo '
786
			<p>
787
				<a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], '
788
			</p>
789
			<p>
790
				<a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a>
791
			</p>';
792
793
	echo '
794
		</div><!-- .windowbg -->';
795
}
796
797
/**
798
 * The page for editing themes.
799
 */
800
function template_edit_list()
801
{
802
	global $context, $scripturl, $txt;
803
804
	echo '
805
	<div id="admin_form_wrapper">
806
		<div class="cat_bar">
807
			<h3 class="catbg">', $txt['themeadmin_edit_title'], '</h3>
808
		</div>
809
		<div class="windowbg">';
810
811
	foreach ($context['themes'] as $theme)
812
	{
813
		echo '
814
			<fieldset>
815
				<legend>
816
					<a href="', $scripturl, '?action=admin;area=theme;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=edit">', $theme['name'], '</a>', !empty($theme['version']) ? '
817
					<em>(' . $theme['version'] . ')</em>' : '', '
818
				</legend>
819
				<ul>
820
					<li><a href="', $scripturl, '?action=admin;area=theme;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=edit">', $txt['themeadmin_edit_browse'], '</a></li>', $theme['can_edit_style'] ? '
821
					<li><a href="' . $scripturl . '?action=admin;area=theme;th=' . $theme['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=css">' . $txt['themeadmin_edit_style'] . '</a></li>' : '', '
822
					<li><a href="', $scripturl, '?action=admin;area=theme;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy">', $txt['themeadmin_edit_copy_template'], '</a></li>
823
				</ul>
824
			</fieldset>';
825
	}
826
827
	echo '
828
		</div><!-- .windowbg -->
829
	</div><!-- #admin_form_wrapper -->';
830
}
831
832
/**
833
 * The page allowing you to copy a template from one theme to another.
834
 */
835
function template_copy_template()
836
{
837
	global $context, $scripturl, $txt;
838
839
	echo '
840
		<div class="cat_bar">
841
			<h3 class="catbg">', $txt['themeadmin_edit_filename'], '</h3>
842
		</div>
843
		<div class="information">
844
			', $txt['themeadmin_edit_copy_warning'], '
845
		</div>
846
		<div class="windowbg">
847
			<ul class="theme_options">';
848
849
	foreach ($context['available_templates'] as $template)
850
	{
851
		echo '
852
				<li class="flow_hidden windowbg">
853
					<span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span>
854
					<span class="floatright">';
855
856
		if ($template['can_copy'])
857
			echo '
858
						<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>';
859
		else
860
			echo $txt['themeadmin_edit_no_copy'];
861
862
		echo '
863
					</span>
864
				</li>';
865
	}
866
867
	echo '
868
			</ul>
869
		</div><!-- .windowbg -->';
870
}
871
872
/**
873
 * This lets you browse a list of files in a theme so you can choose which one to edit.
874
 */
875
function template_edit_browse()
876
{
877
	global $context, $txt;
878
879
	if (!empty($context['browse_title']))
880
		echo '
881
		<div class="cat_bar">
882
			<h3 class="catbg">', $context['browse_title'], '</h3>
883
		</div>';
884
885
	echo '
886
		<table class="table_grid tborder">
887
			<thead>
888
				<tr class="title_bar">
889
					<th class="lefttext half_table" scope="col">', $txt['themeadmin_edit_filename'], '</th>
890
					<th class="quarter_table" scope="col">', $txt['themeadmin_edit_modified'], '</th>
891
					<th class="quarter_table" scope="col">', $txt['themeadmin_edit_size'], '</th>
892
				</tr>
893
			</thead>
894
			<tbody>';
895
896
	foreach ($context['theme_files'] as $file)
897
	{
898
		echo '
899
				<tr class="windowbg">
900
					<td>';
901
902
		if ($file['is_editable'])
903
			echo '
904
						<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>';
905
906
		elseif ($file['is_directory'])
907
			echo '
908
						<a href="', $file['href'], '" class="is_directory"><span class="main_icons folder"></span>', $file['filename'], '</a>';
909
910
		else
911
			echo $file['filename'];
912
913
		echo '
914
					</td>
915
					<td class="righttext">', !empty($file['last_modified']) ? $file['last_modified'] : '', '</td>
916
					<td class="righttext">', $file['size'], '</td>
917
				</tr>';
918
	}
919
920
	echo '
921
			</tbody>
922
		</table>';
923
}
924
925
/**
926
 * Wanna edit the stylesheet?
927
 */
928
function template_edit_style()
929
{
930
	global $context, $settings, $scripturl, $txt;
931
932
	if ($context['session_error'])
933
		echo '
934
	<div class="errorbox">
935
		', $txt['error_session_timeout'], '
936
	</div>';
937
938
	// From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com.
939
	echo '
940
		<script>
941
			var previewData = "";
942
			var previewTimeout;
943
			var editFilename = ', JavaScriptEscape($context['edit_filename']), ';
944
945
			// Load up a page, but apply our stylesheet.
946
			function navigatePreview(url)
947
			{
948
				var myDoc = new XMLHttpRequest();
949
				myDoc.onreadystatechange = function ()
950
				{
951
					if (myDoc.readyState != 4)
952
						return;
953
954
					if (myDoc.responseText != null && myDoc.status == 200)
955
					{
956
						previewData = myDoc.responseText;
957
						document.getElementById("css_preview_box").style.display = "";
958
959
						// Revert to the theme they actually use ;).
960
						var tempImage = new Image();
961
						tempImage.src = smf_prepareScriptUrl(smf_scripturl) + "action=admin;area=theme;sa=edit;theme=', $settings['theme_id'], ';preview;" + (new Date().getTime());
962
963
						refreshPreviewCache = null;
964
						refreshPreview(false);
965
					}
966
				};
967
968
				var anchor = "";
969
				if (url.indexOf("#") != -1)
970
				{
971
					anchor = url.substr(url.indexOf("#"));
972
					url = url.substr(0, url.indexOf("#"));
973
				}
974
975
				myDoc.open("GET", url + (url.indexOf("?") == -1 ? "?" : ";") + "theme=', $context['theme_id'], ';normalcss" + anchor, true);
976
				myDoc.send(null);
977
			}
978
			navigatePreview(smf_scripturl);
979
980
			var refreshPreviewCache;
981
			function refreshPreview(check)
982
			{
983
				var identical = document.forms.stylesheetForm.entire_file.value == refreshPreviewCache;
984
985
				// Don\'t reflow the whole thing if nothing changed!!
986
				if (check && identical)
987
					return;
988
				refreshPreviewCache = document.forms.stylesheetForm.entire_file.value;
989
				// Replace the paths for images.
990
				refreshPreviewCache = refreshPreviewCache.replace(/url\(\.\.\/images/gi, "url(" + smf_images_url);
991
992
				// Try to do it without a complete reparse.
993
				if (identical)
994
				{
995
					try
996
					{
997
					';
998
999
	if (isBrowser('is_ie'))
1000
		echo '
1001
						var sheets = frames["css_preview_box"].document.styleSheets;
1002
						for (var j = 0; j < sheets.length; j++)
1003
						{
1004
							if (sheets[j].id == "css_preview_box")
1005
								sheets[j].cssText = document.forms.stylesheetForm.entire_file.value;
1006
						}';
1007
	else
1008
		echo '
1009
						setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);';
1010
	echo '
1011
					}
1012
					catch (e)
1013
					{
1014
						identical = false;
1015
					}
1016
				}
1017
1018
				// This will work most of the time... could be done with an after-apply, maybe.
1019
				if (!identical)
1020
				{
1021
					var data = previewData + "";
1022
					var preview_sheet = document.forms.stylesheetForm.entire_file.value;
1023
					var stylesheetMatch = new RegExp(\'<link rel="stylesheet"[^>]+href="[^"]+\' + editFilename + \'[^>]*>\');
1024
1025
					// Replace the paths for images.
1026
					preview_sheet = preview_sheet.replace(/url\(\.\.\/images/gi, "url(" + smf_images_url);
1027
					data = data.replace(stylesheetMatch, "<style type=\"text/css\" id=\"css_preview_sheet\">" + preview_sheet + "<" + "/style>");
1028
1029
					frames["css_preview_box"].document.open();
1030
					frames["css_preview_box"].document.write(data);
1031
					frames["css_preview_box"].document.close();
1032
1033
					// Next, fix all its links so we can handle them and reapply the new css!
1034
					frames["css_preview_box"].onload = function ()
1035
					{
1036
						var fixLinks = frames["css_preview_box"].document.getElementsByTagName("a");
1037
						for (var i = 0; i < fixLinks.length; i++)
1038
						{
1039
							if (fixLinks[i].onclick)
1040
								continue;
1041
							fixLinks[i].onclick = function ()
1042
							{
1043
								window.parent.navigatePreview(this.href);
1044
								return false;
1045
							};
1046
						}
1047
					};
1048
				}
1049
			}
1050
		</script>
1051
		<iframe id="css_preview_box" name="css_preview_box" src="about:blank" frameborder="0" style="display: none;"></iframe>';
1052
1053
	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1054
	echo '
1055
		<form action="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';sa=edit" method="post" accept-charset="', $context['character_set'], '" name="stylesheetForm" id="stylesheetForm">
1056
			<div class="cat_bar">
1057
				<h3 class="catbg">', $txt['theme_edit'], ' - ', $context['edit_filename'], '</h3>
1058
			</div>
1059
			<div class="windowbg">';
1060
1061
	if (!$context['allow_save'])
1062
		echo '
1063
				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1064
1065
	echo '
1066
				<textarea class="edit_file" name="entire_file" cols="80" rows="20" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea>
1067
				<br>
1068
				<div class="padding righttext">
1069
					<input type="submit" name="save" value="', $txt['theme_edit_save'], '"', $context['allow_save'] ? '' : ' disabled', ' class="button">
1070
					<input type="button" value="', $txt['themeadmin_edit_preview'], '" onclick="refreshPreview(false);" class="button">
1071
				</div>
1072
			</div>
1073
			<input type="hidden" name="filename" value="', $context['edit_filename'], '">
1074
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1075
1076
	// Hopefully it exists.
1077
	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1078
		echo '
1079
			<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1080
1081
	echo '
1082
		</form>';
1083
}
1084
1085
/**
1086
 * This edits the template...
1087
 */
1088
function template_edit_template()
1089
{
1090
	global $context, $scripturl, $txt;
1091
1092
	if ($context['session_error'])
1093
		echo '
1094
	<div class="errorbox">
1095
		', $txt['error_session_timeout'], '
1096
	</div>';
1097
1098
	if (isset($context['parse_error']))
1099
		echo '
1100
	<div class="errorbox">
1101
		', $txt['themeadmin_edit_error'], '
1102
		<div><pre>', $context['parse_error'], '</pre></div>
1103
	</div>';
1104
1105
	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1106
	echo '
1107
		<form action="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';sa=edit" method="post" accept-charset="', $context['character_set'], '">
1108
			<div class="cat_bar">
1109
				<h3 class="catbg">', $txt['theme_edit'], ' - ', $context['edit_filename'], '</h3>
1110
			</div>
1111
			<div class="windowbg">';
1112
1113
	if (!$context['allow_save'])
1114
		echo '
1115
				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1116
1117
	foreach ($context['file_parts'] as $part)
1118
		echo '
1119
				<label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br>
1120
				<div class="centertext">
1121
					<textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea>
1122
				</div>';
1123
1124
	echo '
1125
				<div class="padding righttext">
1126
					<input type="submit" name="save" value="', $txt['theme_edit_save'], '"', $context['allow_save'] ? '' : ' disabled', ' class="button">
1127
					<input type="hidden" name="filename" value="', $context['edit_filename'], '">
1128
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1129
1130
	// Hopefully it exists.
1131
	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1132
		echo '
1133
					<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1134
1135
	echo '
1136
				</div><!-- .righttext -->
1137
			</div><!-- .windowbg -->
1138
		</form>';
1139
}
1140
1141
/**
1142
 * This allows you to edit a file
1143
 */
1144
function template_edit_file()
1145
{
1146
	global $context, $scripturl, $txt;
1147
1148
	if ($context['session_error'])
1149
		echo '
1150
	<div class="errorbox">
1151
		', $txt['error_session_timeout'], '
1152
	</div>';
1153
1154
	// Is this file writeable?
1155
	if (!$context['allow_save'])
1156
		echo '
1157
	<div class="errorbox">
1158
		', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '
1159
	</div>';
1160
1161
	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1162
	echo '
1163
		<form action="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';sa=edit" method="post" accept-charset="', $context['character_set'], '">
1164
			<div class="cat_bar">
1165
				<h3 class="catbg">', $txt['theme_edit'], ' - ', $context['edit_filename'], '</h3>
1166
			</div>
1167
			<div class="windowbg">
1168
				<textarea name="entire_file" id="entire_file" cols="80" rows="20" class="edit_file">', $context['entire_file'], '</textarea><br>
1169
				<input type="submit" name="save" value="', $txt['theme_edit_save'], '"', $context['allow_save'] ? '' : ' disabled', ' class="button">
1170
				<input type="hidden" name="filename" value="', $context['edit_filename'], '">
1171
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1172
1173
	// Hopefully it exists.
1174
	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1175
		echo '
1176
				<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1177
1178
	echo '
1179
			</div><!-- .windowbg -->
1180
		</form>';
1181
}
1182
1183
?>