2
0

Themes.template.php 44 KB

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