Themes.template.php 43 KB

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