Themes.template.php 43 KB

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