Themes.template.php 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  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. if (isset($setting['type']) && $setting['type'] == 'number')
  388. {
  389. $min = isset($setting['min']) ? ' min="' . $setting['min'] . '"' : ' min="0"';
  390. $max = isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '';
  391. $step = isset($setting['step']) ? ' step="' . $setting['step'] . '"' : '';
  392. echo '
  393. <input type="number"', $min . $max . $step;
  394. }
  395. else
  396. {
  397. echo '
  398. <input type="text"';
  399. }
  400. echo ' 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">';
  401. }
  402. // end of this defintion
  403. echo '
  404. </dd>';
  405. }
  406. // close the option page up
  407. echo '
  408. </dl>
  409. <input type="submit" name="submit" value="', $txt['save'], '" class="button_submit">
  410. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  411. <input type="hidden" name="', $context['admin-sto_token_var'], '" value="', $context['admin-sto_token'], '">
  412. </div>
  413. </div>
  414. </form>
  415. </div>';
  416. }
  417. function template_set_settings()
  418. {
  419. global $context, $settings, $scripturl, $txt;
  420. echo '
  421. <div id="admin_form_wrapper">
  422. <form action="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['theme_settings']['theme_id'], '" method="post" accept-charset="', $context['character_set'], '">
  423. <div class="cat_bar">
  424. <h3 class="catbg">
  425. <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'], '
  426. </h3>
  427. </div>
  428. <br>';
  429. // @todo Why can't I edit the default theme popup.
  430. if ($context['theme_settings']['theme_id'] != 1)
  431. echo '
  432. <div class="cat_bar">
  433. <h3 class="catbg">
  434. <img src="', $settings['images_url'], '/icons/config_hd.png" alt="" class="icon"> ', $txt['theme_edit'], '
  435. </h3>
  436. </div>
  437. <div class="windowbg">
  438. <div class="content">
  439. <ul class="reset">
  440. <li>
  441. <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>
  442. </li>
  443. <li>
  444. <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>
  445. </li>
  446. </ul>
  447. </div>
  448. </div>';
  449. echo '
  450. <div class="cat_bar">
  451. <h3 class="catbg">
  452. <img src="', $settings['images_url'], '/icons/config_hd.png" alt="" class="icon"> ', $txt['theme_url_config'], '
  453. </h3>
  454. </div>
  455. <div class="windowbg2">
  456. <div class="content">
  457. <dl class="settings">
  458. <dt>
  459. <label for="theme_name">', $txt['actual_theme_name'], '</label>
  460. </dt>
  461. <dd>
  462. <input type="text" id="theme_name" name="options[name]" value="', $context['theme_settings']['name'], '" size="32" class="input_text">
  463. </dd>
  464. <dt>
  465. <label for="theme_url">', $txt['actual_theme_url'], '</label>
  466. </dt>
  467. <dd>
  468. <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">
  469. </dd>
  470. <dt>
  471. <label for="images_url">', $txt['actual_images_url'], '</label>
  472. </dt>
  473. <dd>
  474. <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">
  475. </dd>
  476. <dt>
  477. <label for="theme_dir">', $txt['actual_theme_dir'], '</label>
  478. </dt>
  479. <dd>
  480. <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">
  481. </dd>
  482. </dl>
  483. </div>
  484. </div>';
  485. // Do we allow theme variants?
  486. if (!empty($context['theme_variants']))
  487. {
  488. echo '
  489. <div class="cat_bar">
  490. <h3 class="catbg">
  491. <img class="icon" src="', $settings['images_url'], '/icons/config_hd.png" alt=""> ', $txt['theme_variants'], '
  492. </h3>
  493. </div>
  494. <div class="windowbg2">
  495. <div class="content">
  496. <dl class="settings">
  497. <dt>
  498. <label for="variant">', $txt['theme_variants_default'], '</label>:
  499. </dt>
  500. <dd>
  501. <select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">';
  502. foreach ($context['theme_variants'] as $key => $variant)
  503. echo '
  504. <option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
  505. echo '
  506. </select>
  507. </dd>
  508. <dt>
  509. <label for="disable_user_variant">', $txt['theme_variants_user_disable'], '</label>:
  510. </dt>
  511. <dd>
  512. <input type="hidden" name="options[disable_user_variant]" value="0">
  513. <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">
  514. </dd>
  515. </dl>
  516. <img src="', $context['theme_variants'][$context['default_variant']]['thumbnail'], '" id="variant_preview" alt="">
  517. </div>
  518. </div>';
  519. }
  520. echo '
  521. <div class="cat_bar">
  522. <h3 class="catbg">
  523. <img src="', $settings['images_url'], '/icons/config_hd.png" alt="" class="icon"> ', $txt['theme_options'], '
  524. </h3>
  525. </div>
  526. <div class="windowbg">
  527. <div class="content">
  528. <dl class="settings flow_auto">';
  529. foreach ($context['settings'] as $setting)
  530. {
  531. // Is this a separator?
  532. if (empty($setting))
  533. {
  534. echo '
  535. </dl>
  536. <hr class="hrcolor">
  537. <dl class="settings flow_auto">';
  538. }
  539. // A checkbox?
  540. elseif ($setting['type'] == 'checkbox')
  541. {
  542. echo '
  543. <dt>
  544. <label for="', $setting['id'], '">', $setting['label'], '</label>:';
  545. if (isset($setting['description']))
  546. echo '<br>
  547. <span class="smalltext">', $setting['description'], '</span>';
  548. echo '
  549. </dt>
  550. <dd>
  551. <input type="hidden" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" value="0">
  552. <input type="checkbox" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($setting['value']) ? ' checked' : '', ' value="1" class="input_check">
  553. </dd>';
  554. }
  555. // A list with options?
  556. elseif ($setting['type'] == 'list')
  557. {
  558. echo '
  559. <dt>
  560. <label for="', $setting['id'], '">', $setting['label'], '</label>:';
  561. if (isset($setting['description']))
  562. echo '<br>
  563. <span class="smalltext">', $setting['description'], '</span>';
  564. echo '
  565. </dt>
  566. <dd>
  567. <select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">';
  568. foreach ($setting['options'] as $value => $label)
  569. echo '
  570. <option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>';
  571. echo '
  572. </select>
  573. </dd>';
  574. }
  575. // A regular input box, then?
  576. else
  577. {
  578. echo '
  579. <dt>
  580. <label for="', $setting['id'], '">', $setting['label'], '</label>:';
  581. if (isset($setting['description']))
  582. echo '<br>
  583. <span class="smalltext">', $setting['description'], '</span>';
  584. echo '
  585. </dt>
  586. <dd>';
  587. if (isset($setting['type']) && $setting['type'] == 'number')
  588. {
  589. $min = isset($setting['min']) ? ' min="' . $setting['min'] . '"' : ' min="0"';
  590. $max = isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '';
  591. $step = isset($setting['step']) ? ' step="' . $setting['step'] . '"' : '';
  592. echo '
  593. <input type="number"', $min . $max . $step;
  594. }
  595. else
  596. {
  597. echo '
  598. <input type="text"';
  599. }
  600. echo ' name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '" value="', $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : (empty($settings['size']) ? ' size="40"' : ' size="' . $setting['size'] . '"'), ' class="input_text">
  601. </dd>';
  602. }
  603. }
  604. echo '
  605. </dl>
  606. <input type="submit" name="save" value="', $txt['save'], '" class="button_submit">
  607. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  608. <input type="hidden" name="', $context['admin-sts_token_var'], '" value="', $context['admin-sts_token'], '">
  609. </div>
  610. </div>
  611. </form>
  612. </div>';
  613. if (!empty($context['theme_variants']))
  614. {
  615. echo '
  616. <script><!-- // --><![CDATA[
  617. var oThumbnails = {';
  618. // All the variant thumbnails.
  619. $count = 1;
  620. foreach ($context['theme_variants'] as $key => $variant)
  621. {
  622. echo '
  623. \'', $key, '\': \'', $variant['thumbnail'], '\'', (count($context['theme_variants']) == $count ? '' : ',');
  624. $count++;
  625. }
  626. echo '
  627. }
  628. // ]]></script>';
  629. }
  630. }
  631. // This template allows for the selection of different themes ;).
  632. function template_pick()
  633. {
  634. global $context, $scripturl, $txt;
  635. echo '
  636. <div id="pick_theme">
  637. <form action="', $scripturl, '?action=theme;sa=pick;u=', $context['current_member'], ';', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">';
  638. // Just go through each theme and show its information - thumbnail, etc.
  639. foreach ($context['available_themes'] as $theme)
  640. {
  641. echo '
  642. <div class="cat_bar">
  643. <h3 class="catbg">
  644. <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>
  645. </h3>
  646. </div>
  647. <div class="', $theme['selected'] ? 'windowbg' : 'windowbg2', '">
  648. <div class="flow_hidden content">
  649. <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>
  650. <p>', $theme['description'], '</p>';
  651. if (!empty($theme['variants']))
  652. {
  653. echo '
  654. <label for="variant', $theme['id'], '"><strong>', $theme['pick_label'], '</strong></label>:
  655. <select id="variant', $theme['id'], '" name="vrt[', $theme['id'], ']" onchange="changeVariant', $theme['id'], '(this.value);">';
  656. foreach ($theme['variants'] as $key => $variant)
  657. {
  658. echo '
  659. <option value="', $key, '"', $theme['selected_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
  660. }
  661. echo '
  662. </select>
  663. <noscript>
  664. <input type="submit" name="save[', $theme['id'], ']" value="', $txt['save'], '" class="button_submit">
  665. </noscript>';
  666. }
  667. echo '
  668. <br>
  669. <p>
  670. <em class="smalltext">', $theme['num_users'], ' ', ($theme['num_users'] == 1 ? $txt['theme_user'] : $txt['theme_users']), '</em>
  671. </p>
  672. <br>
  673. <ul class="reset">
  674. <li>
  675. <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>
  676. </li>
  677. <li>
  678. <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>
  679. </li>
  680. </ul>
  681. </div>
  682. </div>';
  683. if (!empty($theme['variants']))
  684. {
  685. echo '
  686. <script><!-- // --><![CDATA[
  687. 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'], '\';
  688. 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'], '\';
  689. var oThumbnails', $theme['id'], ' = {';
  690. // All the variant thumbnails.
  691. $count = 1;
  692. foreach ($theme['variants'] as $key => $variant)
  693. {
  694. echo '
  695. \'', $key, '\': \'', $variant['thumbnail'], '\'', (count($theme['variants']) == $count ? '' : ',');
  696. $count++;
  697. }
  698. echo '
  699. }
  700. function changeVariant', $theme['id'], '(sVariant)
  701. {
  702. document.getElementById(\'theme_thumb_', $theme['id'], '\').src = oThumbnails', $theme['id'], '[sVariant];
  703. document.getElementById(\'theme_use_', $theme['id'], '\').href = sBaseUseUrl', $theme['id'] == 0 ? $context['default_theme_id'] : $theme['id'], ' + \';vrt=\' + sVariant;
  704. document.getElementById(\'theme_thumb_preview_', $theme['id'], '\').href = sBasePreviewUrl', $theme['id'], ' + \';vrt=\' + sVariant + \';variant=\' + sVariant;
  705. document.getElementById(\'theme_preview_', $theme['id'], '\').href = sBasePreviewUrl', $theme['id'], ' + \';vrt=\' + sVariant + \';variant=\' + sVariant;
  706. }
  707. // ]]></script>';
  708. }
  709. }
  710. echo '
  711. </form>
  712. </div>';
  713. }
  714. // Okay, that theme was installed/updated successfully!
  715. function template_installed()
  716. {
  717. global $context, $scripturl, $txt;
  718. // The aftermath.
  719. echo '
  720. <div id="admincenter">
  721. <div class="cat_bar">
  722. <h3 class="catbg">', $context['page_title'], '</h3>
  723. </div>
  724. <div class="windowbg">
  725. <div class="content">';
  726. // Oops! there was an error :(
  727. if (!empty($context['error_message']))
  728. echo '
  729. <p>
  730. ', $context['error_message'] ,'
  731. </p>';
  732. // Not much to show except a link back...
  733. else
  734. echo '
  735. <p>
  736. <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'], '
  737. </p>
  738. <p>
  739. <a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a>
  740. </p>';
  741. echo '
  742. </div>
  743. </div>
  744. </div>';
  745. }
  746. function template_edit_list()
  747. {
  748. global $context, $scripturl, $txt;
  749. echo '
  750. <div id="admin_form_wrapper">
  751. <div class="cat_bar">
  752. <h3 class="catbg">', $txt['themeadmin_edit_title'], '</h3>
  753. </div>
  754. <br>';
  755. $alternate = false;
  756. foreach ($context['themes'] as $theme)
  757. {
  758. $alternate = !$alternate;
  759. echo '
  760. <div class="cat_bar">
  761. <h3 class="catbg">
  762. <a href="', $scripturl, '?action=admin;area=theme;th=', $theme['id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=edit">', $theme['name'], '</a>', !empty($theme['version']) ? '
  763. <em>(' . $theme['version'] . ')</em>' : '', '
  764. </h3>
  765. </div>
  766. <div class="windowbg', $alternate ? '' : '2','">
  767. <div class="content">
  768. <ul class="reset">
  769. <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'] ? '
  770. <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>' : '', '
  771. <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>
  772. </ul>
  773. </div>
  774. </div>';
  775. }
  776. echo '
  777. </div>';
  778. }
  779. function template_copy_template()
  780. {
  781. global $context, $scripturl, $txt;
  782. echo '
  783. <div id="admincenter">
  784. <div class="cat_bar">
  785. <h3 class="catbg">', $txt['themeadmin_edit_filename'], '</h3>
  786. </div>
  787. <div class="information">
  788. ', $txt['themeadmin_edit_copy_warning'], '
  789. </div>
  790. <div class="windowbg">
  791. <div class="content">
  792. <ul class="theme_options">';
  793. $alternate = false;
  794. foreach ($context['available_templates'] as $template)
  795. {
  796. $alternate = !$alternate;
  797. echo '
  798. <li class="reset flow_hidden windowbg', $alternate ? '2' : '', '">
  799. <span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span>
  800. <span class="floatright">';
  801. if ($template['can_copy'])
  802. 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>';
  803. else
  804. echo $txt['themeadmin_edit_no_copy'];
  805. echo '
  806. </span>
  807. </li>';
  808. }
  809. echo '
  810. </ul>
  811. </div>
  812. </div>
  813. </div>';
  814. }
  815. function template_edit_browse()
  816. {
  817. global $context, $scripturl, $txt;
  818. echo '
  819. <div id="admincenter">';
  820. if (!empty($context['browse_title']))
  821. echo '
  822. <div class="cat_bar">
  823. <h3 class="catbg">', $context['browse_title'], '</h3>
  824. </div>';
  825. echo '
  826. <table class="table_grid tborder">
  827. <thead>
  828. <tr class="catbg">
  829. <th class="lefttext first_th" scope="col" width="50%">', $txt['themeadmin_edit_filename'], '</th>
  830. <th scope="col" width="35%">', $txt['themeadmin_edit_modified'], '</th>
  831. <th class="last_th" scope="col" width="15%">', $txt['themeadmin_edit_size'], '</th>
  832. </tr>
  833. </thead>
  834. <tbody>';
  835. $alternate = false;
  836. foreach ($context['theme_files'] as $file)
  837. {
  838. $alternate = !$alternate;
  839. echo '
  840. <tr class="windowbg', $alternate ? '2' : '', '">
  841. <td>';
  842. if ($file['is_editable'])
  843. echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>';
  844. elseif ($file['is_directory'])
  845. echo '<a href="', $file['href'], '" class="is_directory">', $file['filename'], '</a>';
  846. else
  847. echo $file['filename'];
  848. echo '
  849. </td>
  850. <td class="righttext">', !empty($file['last_modified']) ? $file['last_modified'] : '', '</td>
  851. <td class="righttext">', $file['size'], '</td>
  852. </tr>';
  853. }
  854. echo '
  855. </tbody>
  856. </table>
  857. </div>';
  858. }
  859. // Wanna edit the stylesheet?
  860. function template_edit_style()
  861. {
  862. global $context, $settings, $scripturl, $txt;
  863. if ($context['session_error'])
  864. echo '
  865. <div class="errorbox">
  866. ', $txt['error_session_timeout'], '
  867. </div>';
  868. // From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com.
  869. echo '
  870. <div id="admincenter">
  871. <script><!-- // --><![CDATA[
  872. var previewData = "";
  873. var previewTimeout;
  874. var editFilename = ', JavaScriptEscape($context['edit_filename']), ';
  875. // Load up a page, but apply our stylesheet.
  876. function navigatePreview(url)
  877. {
  878. var myDoc = new XMLHttpRequest();
  879. myDoc.onreadystatechange = function ()
  880. {
  881. if (myDoc.readyState != 4)
  882. return;
  883. if (myDoc.responseText != null && myDoc.status == 200)
  884. {
  885. previewData = myDoc.responseText;
  886. document.getElementById("css_preview_box").style.display = "";
  887. // Revert to the theme they actually use ;).
  888. var tempImage = new Image();
  889. tempImage.src = smf_prepareScriptUrl(smf_scripturl) + "action=admin;area=theme;sa=edit;theme=', $settings['theme_id'], ';preview;" + (new Date().getTime());
  890. refreshPreviewCache = null;
  891. refreshPreview(false);
  892. }
  893. };
  894. var anchor = "";
  895. if (url.indexOf("#") != -1)
  896. {
  897. anchor = url.substr(url.indexOf("#"));
  898. url = url.substr(0, url.indexOf("#"));
  899. }
  900. myDoc.open("GET", url + (url.indexOf("?") == -1 ? "?" : ";") + "theme=', $context['theme_id'], '" + anchor, true);
  901. myDoc.send(null);
  902. }
  903. navigatePreview(smf_scripturl);
  904. var refreshPreviewCache;
  905. function refreshPreview(check)
  906. {
  907. var identical = document.forms.stylesheetForm.entire_file.value == refreshPreviewCache;
  908. // Don\'t reflow the whole thing if nothing changed!!
  909. if (check && identical)
  910. return;
  911. refreshPreviewCache = document.forms.stylesheetForm.entire_file.value;
  912. // Replace the paths for images.
  913. refreshPreviewCache = refreshPreviewCache.replace(/url\(\.\.\/images/gi, "url(" + smf_images_url);
  914. // Try to do it without a complete reparse.
  915. if (identical)
  916. {
  917. try
  918. {
  919. ';
  920. if (isBrowser('is_ie'))
  921. echo '
  922. var sheets = frames["css_preview_box"].document.styleSheets;
  923. for (var j = 0; j < sheets.length; j++)
  924. {
  925. if (sheets[j].id == "css_preview_box")
  926. sheets[j].cssText = document.forms.stylesheetForm.entire_file.value;
  927. }';
  928. else
  929. echo '
  930. setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);';
  931. echo '
  932. }
  933. catch (e)
  934. {
  935. identical = false;
  936. }
  937. }
  938. // This will work most of the time... could be done with an after-apply, maybe.
  939. if (!identical)
  940. {
  941. var data = previewData + "";
  942. var preview_sheet = document.forms.stylesheetForm.entire_file.value;
  943. var stylesheetMatch = new RegExp(\'<link rel="stylesheet"[^>]+href="[^"]+\' + editFilename + \'[^>]*>\');
  944. // Replace the paths for images.
  945. preview_sheet = preview_sheet.replace(/url\(\.\.\/images/gi, "url(" + smf_images_url);
  946. data = data.replace(stylesheetMatch, "<style type=\"text/css\" id=\"css_preview_sheet\">" + preview_sheet + "<" + "/style>");
  947. frames["css_preview_box"].document.open();
  948. frames["css_preview_box"].document.write(data);
  949. frames["css_preview_box"].document.close();
  950. // Next, fix all its links so we can handle them and reapply the new css!
  951. frames["css_preview_box"].onload = function ()
  952. {
  953. var fixLinks = frames["css_preview_box"].document.getElementsByTagName("a");
  954. for (var i = 0; i < fixLinks.length; i++)
  955. {
  956. if (fixLinks[i].onclick)
  957. continue;
  958. fixLinks[i].onclick = function ()
  959. {
  960. window.parent.navigatePreview(this.href);
  961. return false;
  962. };
  963. }
  964. };
  965. }
  966. }
  967. // ]]></script>
  968. <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>';
  969. // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
  970. echo '
  971. <form action="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';sa=edit" method="post" accept-charset="', $context['character_set'], '" name="stylesheetForm" id="stylesheetForm">
  972. <div class="cat_bar">
  973. <h3 class="catbg">', $txt['theme_edit'], ' - ', $context['edit_filename'], '</h3>
  974. </div>
  975. <div class="windowbg">
  976. <div class="content">';
  977. if (!$context['allow_save'])
  978. echo '
  979. ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
  980. echo '
  981. <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>
  982. <div class="padding righttext">
  983. <input type="submit" name="save" value="', $txt['theme_edit_save'], '"', $context['allow_save'] ? '' : ' disabled', ' style="margin-top: 1ex;" class="button_submit">
  984. <input type="button" value="', $txt['themeadmin_edit_preview'], '" onclick="refreshPreview(false);" class="button_submit">
  985. </div>
  986. </div>
  987. </div>
  988. <input type="hidden" name="filename" value="', $context['edit_filename'], '">
  989. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  990. </form>
  991. </div>';
  992. }
  993. // This edits the template...
  994. function template_edit_template()
  995. {
  996. global $context, $scripturl, $txt;
  997. if ($context['session_error'])
  998. echo '
  999. <div class="errorbox">
  1000. ', $txt['error_session_timeout'], '
  1001. </div>';
  1002. if (isset($context['parse_error']))
  1003. echo '
  1004. <div class="errorbox">
  1005. ', $txt['themeadmin_edit_error'], '
  1006. <div><tt>', $context['parse_error'], '</tt></div>
  1007. </div>';
  1008. // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
  1009. echo '
  1010. <div id="admincenter">
  1011. <form action="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';sa=edit" method="post" accept-charset="', $context['character_set'], '">
  1012. <div class="cat_bar">
  1013. <h3 class="catbg">', $txt['theme_edit'], ' - ', $context['edit_filename'], '</h3>
  1014. </div>
  1015. <div class="windowbg">
  1016. <div class="content">';
  1017. if (!$context['allow_save'])
  1018. echo '
  1019. ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
  1020. foreach ($context['file_parts'] as $part)
  1021. echo '
  1022. <label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br>
  1023. <div class="centertext">
  1024. <textarea id="on_line', $part['line'] ,'" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea>
  1025. </div>';
  1026. echo '
  1027. <div class="padding righttext">
  1028. <input type="submit" name="save" value="', $txt['theme_edit_save'], '"', $context['allow_save'] ? '' : ' 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. </div>
  1039. </form>
  1040. </div>';
  1041. }
  1042. function template_edit_file()
  1043. {
  1044. global $context, $scripturl, $txt;
  1045. if ($context['session_error'])
  1046. echo '
  1047. <div class="errorbox">
  1048. ', $txt['error_session_timeout'], '
  1049. </div>';
  1050. //Is this file writeable?
  1051. if (!$context['allow_save'])
  1052. echo '
  1053. <div class="errorbox">
  1054. ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '
  1055. </div>';
  1056. // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
  1057. echo '
  1058. <div id="admincenter">
  1059. <form action="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';sa=edit" method="post" accept-charset="', $context['character_set'], '">
  1060. <div class="cat_bar">
  1061. <h3 class="catbg">', $txt['theme_edit'], ' - ', $context['edit_filename'], '</h3>
  1062. </div>
  1063. <div class="windowbg">
  1064. <div class="content">
  1065. <textarea name="entire_file" id="entire_file" cols="80" rows="20" class="edit_file">', $context['entire_file'], '</textarea><br>
  1066. <input type="submit" name="save" value="', $txt['theme_edit_save'], '"', $context['allow_save'] ? '' : ' disabled', ' class="button_submit">
  1067. <input type="hidden" name="filename" value="', $context['edit_filename'], '">
  1068. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
  1069. // Hopefully it exists.
  1070. if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
  1071. echo '
  1072. <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'], '">';
  1073. echo '
  1074. </div>
  1075. </div>
  1076. </form>
  1077. </div>';
  1078. }
  1079. ?>