Themes.template.php 43 KB

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