Themes.template.php 43 KB

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