Themes.template.php 42 KB

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