Themes.template.php 44 KB

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