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