Themes.template.php 45 KB

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