Themes.template.php 43 KB

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