Themes.template.php 43 KB

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