Themes.template.php 45 KB

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