Themes.template.php 44 KB

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