Themes.template.php 43 KB

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