PageRenderTime 57ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/Themes/default/Packages.template.php

https://github.com/smf-portal/SMF2.1
PHP | 1815 lines | 1626 code | 127 blank | 62 comment | 94 complexity | c186dcd7f52886827b3e92b5754016f5 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2012 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. function template_main()
  13. {
  14. global $context, $settings, $options;
  15. }
  16. function template_view_package()
  17. {
  18. global $context, $settings, $options, $txt, $scripturl, $smcFunc;
  19. echo '
  20. <div id="admincenter">
  21. <div class="cat_bar">
  22. <h3 class="catbg">', $txt[($context['uninstalling'] ? 'un' : '') . 'install_mod'], '</h3>
  23. </div>
  24. <div class="information">';
  25. if ($context['is_installed'])
  26. echo '
  27. <strong>', $txt['package_installed_warning1'], '</strong><br />
  28. <br />
  29. ', $txt['package_installed_warning2'], '<br />
  30. <br />';
  31. echo $txt['package_installed_warning3'], '
  32. </div>';
  33. // Do errors exist in the install? If so light them up like a christmas tree.
  34. if ($context['has_failure'])
  35. {
  36. echo '
  37. <div class="errorbox">
  38. ', sprintf($txt['package_will_fail_title'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), '<br />
  39. ', sprintf($txt['package_will_fail_warning'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]),
  40. !empty($context['failure_details']) ? '<br /><br /><strong>' . $context['failure_details'] . '</strong>' : '', '
  41. </div>';
  42. }
  43. // Display the package readme if one exists
  44. if (isset($context['package_readme']))
  45. {
  46. echo '
  47. <div class="cat_bar">
  48. <h3 class="catbg">', $txt['package_' . ($context['uninstalling'] ? 'un' : '') . 'install_readme'], '</h3>
  49. </div>
  50. <div class="windowbg2">
  51. <div class="content">
  52. ', $context['package_readme'], '
  53. <span class="floatright">', $txt['package_available_readme_language'], '
  54. <select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">';
  55. foreach ($context['readmes'] as $a => $b)
  56. echo '<option value="', $b, '"', $a === 'selected' ? ' selected="selected"' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>';
  57. echo '
  58. </select>
  59. </span>
  60. </div>
  61. </div>
  62. <br />';
  63. }
  64. // Did they specify a license to display?
  65. if (isset($context['package_license']))
  66. {
  67. echo '
  68. <div class="cat_bar">
  69. <h3 class="catbg">', $txt['package_install_license'], '</h3>
  70. </div>
  71. <div class="windowbg2">
  72. <div class="content">
  73. ', $context['package_license'], '
  74. <span class="floatright">', $txt['package_available_license_language'], '
  75. <select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">';
  76. foreach ($context['licenses'] as $a => $b)
  77. echo '<option value="', $b, '"', $a === 'selected' ? ' selected="selected"' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>';
  78. echo '
  79. </select>
  80. </span>
  81. </div>
  82. </div>
  83. <br />';
  84. }
  85. echo '
  86. <form action="', $context['post_url'], '" onsubmit="submitonce(this);" method="post" accept-charset="', $context['character_set'], '">
  87. <div class="cat_bar">
  88. <h3 class="catbg">
  89. ', $context['uninstalling'] ? $txt['package_uninstall_actions'] : $txt['package_install_actions'], ' &quot;', $context['package_name'], '&quot;
  90. </h3>
  91. </div>';
  92. // Are there data changes to be removed?
  93. if ($context['uninstalling'] && !empty($context['database_changes']))
  94. {
  95. echo '
  96. <div class="windowbg2">
  97. <div class="content">
  98. <label for="do_db_changes"><input type="checkbox" name="do_db_changes" id="do_db_changes" class="input_check" />', $txt['package_db_uninstall'], '</label> [<a href="#" onclick="return swap_database_changes();">', $txt['package_db_uninstall_details'], '</a>]
  99. <div id="db_changes_div">
  100. ', $txt['package_db_uninstall_actions'], ':
  101. <ul>';
  102. foreach ($context['database_changes'] as $change)
  103. echo '
  104. <li>', $change, '</li>';
  105. echo '
  106. </ul>
  107. </div>
  108. </div>
  109. </div>';
  110. }
  111. echo '
  112. <div class="information">';
  113. if (empty($context['actions']) && empty($context['database_changes']))
  114. echo '
  115. <br />
  116. <div class="errorbox">
  117. ', $txt['corrupt_compatible'], '
  118. </div>
  119. </div>';
  120. else
  121. {
  122. echo '
  123. ', $txt['perform_actions'], '
  124. </div>
  125. <table class="table_grid" width="100%">
  126. <thead>
  127. <tr class="catbg">
  128. <th class="first_th" scope="col" width="20"></th>
  129. <th scope="col" width="30"></th>
  130. <th scope="col" class="lefttext">', $txt['package_install_type'], '</th>
  131. <th scope="col" class="lefttext" width="50%">', $txt['package_install_action'], '</th>
  132. <th class="last_th lefttext" scope="col" width="20%">', $txt['package_install_desc'], '</th>
  133. </tr>
  134. </thead>
  135. <tbody>';
  136. $alternate = true;
  137. $i = 1;
  138. $action_num = 1;
  139. $js_operations = array();
  140. foreach ($context['actions'] as $packageaction)
  141. {
  142. // Did we pass or fail? Need to now for later on.
  143. $js_operations[$action_num] = isset($packageaction['failed']) ? $packageaction['failed'] : 0;
  144. echo '
  145. <tr class="windowbg', $alternate ? '' : '2', '">
  146. <td>', isset($packageaction['operations']) ? '<img id="operation_img_' . $action_num . '" src="' . $settings['images_url'] . '/selected_open.png" alt="*" style="display: none;" />' : '', '</td>
  147. <td>', $i++, '.</td>
  148. <td>', $packageaction['type'], '</td>
  149. <td>', $packageaction['action'], '</td>
  150. <td>', $packageaction['description'], '</td>
  151. </tr>';
  152. // Is there water on the knee? Operation!
  153. if (isset($packageaction['operations']))
  154. {
  155. echo '
  156. <tr id="operation_', $action_num, '">
  157. <td colspan="5" class="windowbg3">
  158. <table border="0" cellpadding="3" cellspacing="0" width="100%">';
  159. // Show the operations.
  160. $alternate2 = true;
  161. $operation_num = 1;
  162. foreach ($packageaction['operations'] as $operation)
  163. {
  164. // Determine the position text.
  165. $operation_text = $operation['position'] == 'replace' ? 'operation_replace' : ($operation['position'] == 'before' ? 'operation_after' : 'operation_before');
  166. echo '
  167. <tr class="windowbg', $alternate2 ? '' : '2', '">
  168. <td width="0"></td>
  169. <td width="30" class="smalltext"><a href="' . $scripturl . '?action=admin;area=packages;sa=showoperations;operation_key=', $operation['operation_key'], ';package=', $_REQUEST['package'], ';filename=', $operation['filename'], ($operation['is_boardmod'] ? ';boardmod' : ''), (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'uninstall' ? ';reverse' : ''), '" onclick="return reqWin(this.href, 680, 400, false);"><img src="', $settings['default_images_url'], '/admin/package_ops.png" alt="" /></a></td>
  170. <td width="30" class="smalltext">', $operation_num, '.</td>
  171. <td width="23%" class="smalltext">', $txt[$operation_text], '</td>
  172. <td width="50%" class="smalltext">', $operation['action'], '</td>
  173. <td width="20%" class="smalltext">', $operation['description'], !empty($operation['ignore_failure']) ? ' (' . $txt['operation_ignore'] . ')' : '', '</td>
  174. </tr>';
  175. $operation_num++;
  176. $alternate2 = !$alternate2;
  177. }
  178. echo '
  179. </table>
  180. </td>
  181. </tr>';
  182. // Increase it.
  183. $action_num++;
  184. }
  185. $alternate = !$alternate;
  186. }
  187. echo '
  188. </tbody>
  189. </table>
  190. ';
  191. // What if we have custom themes we can install into? List them too!
  192. if (!empty($context['theme_actions']))
  193. {
  194. echo '
  195. <br />
  196. <div class="cat_bar">
  197. <h3 class="catbg">
  198. ', $context['uninstalling'] ? $txt['package_other_themes_uninstall'] : $txt['package_other_themes'], '
  199. </h3>
  200. </div>
  201. <div id="custom_changes">
  202. <div class="information">
  203. ', $txt['package_other_themes_desc'], '
  204. </div>
  205. <table class="table_grid" width="100%">';
  206. // Loop through each theme and display it's name, and then it's details.
  207. foreach ($context['theme_actions'] as $id => $theme)
  208. {
  209. // Pass?
  210. $js_operations[$action_num] = !empty($theme['has_failure']);
  211. echo '
  212. <tr class="catbg">
  213. <td></td>
  214. <td align="center">';
  215. if (!empty($context['themes_locked']))
  216. echo '
  217. <input type="hidden" name="custom_theme[]" value="', $id, '" />';
  218. echo '
  219. <input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" class="input_check" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);" ', !empty($context['themes_locked']) ? 'disabled="disabled" checked="checked"' : '', '/>
  220. </td>
  221. <td colspan="3">
  222. ', $theme['name'], '
  223. </td>
  224. </tr>';
  225. foreach ($theme['actions'] as $action)
  226. {
  227. echo '
  228. <tr class="windowbg', $alternate ? '' : '2', '">
  229. <td>', isset($packageaction['operations']) ? '<img id="operation_img_' . $action_num . '" src="' . $settings['images_url'] . '/selected_open.png" alt="*" style="display: none;" />' : '', '</td>
  230. <td width="30" align="center">
  231. <input type="checkbox" name="theme_changes[]" value="', !empty($action['value']) ? $action['value'] : '', '" id="dummy_theme_', $id, '" class="input_check" ', (!empty($action['not_mod']) ? '' : 'disabled="disabled"'), ' ', !empty($context['themes_locked']) ? 'checked="checked"' : '', '/>
  232. </td>
  233. <td>', $action['type'], '</td>
  234. <td width="50%">', $action['action'], '</td>
  235. <td width="20%"><strong>', $action['description'], '</strong></td>
  236. </tr>';
  237. // Is there water on the knee? Operation!
  238. if (isset($action['operations']))
  239. {
  240. echo '
  241. <tr id="operation_', $action_num, '">
  242. <td colspan="5" class="windowbg3">
  243. <table border="0" cellpadding="3" cellspacing="0" width="100%">';
  244. $alternate2 = true;
  245. $operation_num = 1;
  246. foreach ($action['operations'] as $operation)
  247. {
  248. // Determine the possition text.
  249. $operation_text = $operation['position'] == 'replace' ? 'operation_replace' : ($operation['position'] == 'before' ? 'operation_after' : 'operation_before');
  250. echo '
  251. <tr class="windowbg', $alternate2 ? '' : '2', '">
  252. <td width="0"></td>
  253. <td width="30" class="smalltext"><a href="' . $scripturl . '?action=admin;area=packages;sa=showoperations;operation_key=', $operation['operation_key'], ';package=', $_REQUEST['package'], ';filename=', $operation['filename'], ($operation['is_boardmod'] ? ';boardmod' : ''), (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'uninstall' ? ';reverse' : ''), '" onclick="return reqWin(this.href, 600, 400, false);"><img src="', $settings['default_images_url'], '/admin/package_ops.png" alt="" /></a></td>
  254. <td width="30" class="smalltext">', $operation_num, '.</td>
  255. <td width="23%" class="smalltext">', $txt[$operation_text], '</td>
  256. <td width="50%" class="smalltext">', $operation['action'], '</td>
  257. <td width="20%" class="smalltext">', $operation['description'], !empty($operation['ignore_failure']) ? ' (' . $txt['operation_ignore'] . ')' : '', '</td>
  258. </tr>';
  259. $operation_num++;
  260. $alternate2 = !$alternate2;
  261. }
  262. echo '
  263. </table>
  264. </td>
  265. </tr>';
  266. // Increase it.
  267. $action_num++;
  268. }
  269. }
  270. $alternate = !$alternate;
  271. }
  272. echo '
  273. </table>
  274. </div>';
  275. }
  276. }
  277. // Are we effectively ready to install?
  278. if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes'])))
  279. {
  280. echo '
  281. <div class="righttext padding">
  282. <input type="submit" value="', $context['uninstalling'] ? $txt['package_uninstall_now'] : $txt['package_install_now'], '" onclick="return ', !empty($context['has_failure']) ? '(submitThisOnce(this) &amp;&amp; confirm(\'' . ($context['uninstalling'] ? $txt['package_will_fail_popup_uninstall'] : $txt['package_will_fail_popup']) . '\'))' : 'submitThisOnce(this)', ';" class="button_submit" />
  283. </div>';
  284. }
  285. // If we need ftp information then demand it!
  286. elseif ($context['ftp_needed'])
  287. {
  288. echo '
  289. <div class="cat_bar">
  290. <h3 class="catbg">', $txt['package_ftp_necessary'], '</h3>
  291. </div>
  292. <div>
  293. ', template_control_chmod(), '
  294. </div>';
  295. }
  296. echo '
  297. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />', (isset($context['form_sequence_number']) && !$context['ftp_needed']) ? '
  298. <input type="hidden" name="seqnum" value="' . $context['form_sequence_number'] . '" />' : '', '
  299. </form>
  300. </div>';
  301. // Toggle options.
  302. echo '
  303. <script type="text/javascript"><!-- // --><![CDATA[
  304. var aOperationElements = new Array();';
  305. // Operations.
  306. if (!empty($js_operations))
  307. {
  308. foreach ($js_operations as $key => $operation)
  309. {
  310. echo '
  311. aOperationElements[', $key, '] = new smc_Toggle({
  312. bToggleEnabled: true,
  313. bCurrentlyCollapsed: ', $operation ? 'false' : 'true', ',
  314. aSwappableContainers: [
  315. \'operation_', $key, '\'
  316. ],
  317. aSwapImages: [
  318. {
  319. sId: \'operation_img_', $key, '\',
  320. srcExpanded: smf_images_url + \'/selected_open.png\',
  321. altExpanded: \'*\',
  322. srcCollapsed: smf_images_url + \'/selected.png\',
  323. altCollapsed: \'*\'
  324. }
  325. ]
  326. });';
  327. }
  328. }
  329. echo '
  330. // ]]></script>';
  331. // Get the currently selected item from a select list
  332. echo '
  333. <script type="text/javascript"><!-- // --><![CDATA[
  334. function get_selected(id)
  335. {
  336. var aSelected = document.getElementById(id);
  337. for (var i = 0; i < aSelected.options.length; i++)
  338. {
  339. if (aSelected.options[i].selected == true)
  340. return aSelected.options[i].value;
  341. }
  342. return aSelected.options[0];
  343. }
  344. // ]]></script>';
  345. // And a bit more for database changes.
  346. if (!empty($context['database_changes']))
  347. echo '
  348. <script type="text/javascript"><!-- // --><![CDATA[
  349. var database_changes_area = document.getElementById(\'db_changes_div\');
  350. var db_vis = false;
  351. database_changes_area.style.display = "none";
  352. // ]]></script>';
  353. }
  354. function template_extract_package()
  355. {
  356. global $context, $settings, $options, $txt, $scripturl;
  357. if (!empty($context['redirect_url']))
  358. {
  359. echo '
  360. <script type="text/javascript"><!-- // --><![CDATA[
  361. setTimeout("doRedirect();", ', empty($context['redirect_timeout']) ? '5000' : $context['redirect_timeout'], ');
  362. function doRedirect()
  363. {
  364. window.location = "', $context['redirect_url'], '";
  365. }
  366. // ]]></script>';
  367. }
  368. echo '
  369. <div id="admincenter">';
  370. if (empty($context['redirect_url']))
  371. {
  372. echo '
  373. <div class="cat_bar">
  374. <h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3>
  375. </div>
  376. <div class="information">', $txt['package_installed_extract'], '</div>';
  377. }
  378. else
  379. echo '
  380. <div class="cat_bar">
  381. <h3 class="catbg">', $txt['package_installed_redirecting'], '</h3>
  382. </div>';
  383. echo '
  384. <div class="windowbg">
  385. <div class="content">';
  386. // If we are going to redirect we have a slightly different agenda.
  387. if (!empty($context['redirect_url']))
  388. {
  389. echo '
  390. ', $context['redirect_text'], '<br /><br />
  391. <a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>';
  392. }
  393. elseif ($context['uninstalling'])
  394. echo '
  395. ', $txt['package_uninstall_done'];
  396. elseif ($context['install_finished'])
  397. {
  398. if ($context['extract_type'] == 'avatar')
  399. echo '
  400. ', $txt['avatars_extracted'];
  401. elseif ($context['extract_type'] == 'language')
  402. echo '
  403. ', $txt['language_extracted'];
  404. else
  405. echo '
  406. ', $txt['package_installed_done'];
  407. }
  408. else
  409. echo '
  410. ', $txt['corrupt_compatible'];
  411. echo '
  412. </div>
  413. </div>';
  414. // Show the "restore permissions" screen?
  415. if (function_exists('template_show_list') && !empty($context['restore_file_permissions']['rows']))
  416. {
  417. echo '<br />';
  418. template_show_list('restore_file_permissions');
  419. }
  420. echo '
  421. </div>';
  422. }
  423. function template_list()
  424. {
  425. global $context, $settings, $options, $txt, $scripturl;
  426. echo '
  427. <div id="admincenter">
  428. <div class="cat_bar">
  429. <h3 class="catbg">', $txt['list_file'], '</h3>
  430. </div>
  431. <div class="title_bar">
  432. <h3 class="titlebg">', $txt['files_archive'], ' ', $context['filename'], ':</h3>
  433. </div>
  434. <div class="windowbg">
  435. <div class="content">
  436. <ol>';
  437. foreach ($context['files'] as $fileinfo)
  438. echo '
  439. <li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>';
  440. echo '
  441. </ol>
  442. <br />
  443. <a href="', $scripturl, '?action=admin;area=packages">[ ', $txt['back'], ' ]</a>
  444. </div>
  445. </div>
  446. </div>';
  447. }
  448. function template_examine()
  449. {
  450. global $context, $settings, $options, $txt, $scripturl;
  451. echo '
  452. <div id="admincenter">
  453. <div class="cat_bar">
  454. <h3 class="catbg">', $txt['package_examine_file'], '</h3>
  455. </div>
  456. <div class="title_bar">
  457. <h3 class="titlebg">', $txt['package_file_contents'], ' ', $context['filename'], ':</h3>
  458. </div>
  459. <div class="windowbg">
  460. <div class="content">
  461. <pre class="file_content">', $context['filedata'], '</pre>
  462. <a href="', $scripturl, '?action=admin;area=packages;sa=list;package=', $context['package'], '">[ ', $txt['list_files'], ' ]</a>
  463. </div>
  464. </div>
  465. </div>';
  466. }
  467. function template_browse()
  468. {
  469. global $context, $settings, $options, $txt, $scripturl, $modSettings, $forum_version;
  470. echo '
  471. <div id="admincenter">';
  472. if ($context['sub_action'] == 'browse')
  473. {
  474. echo '
  475. <div id="admin_form_wrapper">
  476. <div class="cat_bar">
  477. <h3 class="catbg">
  478. <a href="', $scripturl, '?action=helpadmin;help=latest_packages" onclick="return reqOverlayDiv(this.href);" class="help"><img class="icon" src="', $settings['images_url'], '/helptopics_hd.png" alt="', $txt['help'], '" /></a> ', $txt['packages_latest'], '
  479. </h3>
  480. </div>
  481. <div class="windowbg2">
  482. <div class="content">
  483. <div id="packagesLatest">', $txt['packages_latest_fetch'], '</div>
  484. </div>
  485. </div>
  486. <script type="text/javascript"><!-- // --><![CDATA[
  487. window.smfForum_scripturl = smf_scripturl;
  488. window.smfForum_sessionid = smf_session_id;
  489. window.smfForum_sessionvar = smf_session_var;';
  490. // Make a list of already installed mods so nothing is listed twice ;).
  491. echo '
  492. window.smfInstalledPackages = ["', implode('", "', $context['installed_mods']), '"];
  493. window.smfVersion = "', $context['forum_version'], '";
  494. // ]]></script>';
  495. if (empty($modSettings['disable_smf_js']))
  496. echo '
  497. <script type="text/javascript" src="', $scripturl, '?action=viewsmfile;filename=latest-packages.js"></script>';
  498. echo '
  499. <script type="text/javascript"><!-- // --><![CDATA[
  500. var tempOldOnload;
  501. smfSetLatestPackages();
  502. // ]]></script>
  503. </div>';
  504. }
  505. $mods_available = false;
  506. foreach ($context['modification_types'] as $type)
  507. {
  508. if (!empty($context['available_' . $type]))
  509. {
  510. template_show_list('packages_lists_' . $type);
  511. $mods_available = true;
  512. }
  513. }
  514. if (!$mods_available)
  515. echo '
  516. <div class="descbox">', $context['sub_action'] == 'browse' ? $txt['no_packages'] : $txt['no_mods_installed'], '</div>';
  517. // the advanced (emulation) box, collapsed by default
  518. echo '
  519. <form action="', $scripturl, '?action=admin;area=packages;sa=', $context['sub_action'], '" method="get">
  520. <div id="advanced_box" >
  521. <div class="cat_bar">
  522. <h3 class="catbg">
  523. <img id="advanced_panel_toggle" class="panel_toggle" style="display: none;" src="', $settings['images_url'], '/', empty($context['show_advanced_options']) ? 'collapse' : 'expand', '.png" alt="*" />
  524. <a href="#" id="advanced_panel_link">', $txt['package_advanced_button'], '</a>
  525. </h3>
  526. </div>
  527. <div id="advanced_panel_div" class="windowbg">
  528. <div class="content">
  529. <p>
  530. ', $txt['package_emulate_desc'], '
  531. </p>
  532. <dl class="settings">
  533. <dt>
  534. <strong>', $txt['package_emulate'], ':</strong><br />
  535. <span class="smalltext">
  536. <a href="#" onclick="document.getElementById(\'ve\').value = \'', $forum_version, '\';document.getElementsByName(\'version_emulate\')[0].value = \'', $forum_version, '\';return false">', $txt['package_emulate_revert'], '</a>
  537. </span>
  538. </dt>
  539. <dd>
  540. <input type="text" name="version_emulate" id="ve" value="', $context['forum_version'], '" size="25" class="input_text" />
  541. </dd>
  542. </dl>
  543. <div class="righttext padding">
  544. <input type="submit" value="', $txt['package_apply'], '" class="button_submit" />
  545. </div>
  546. </div>
  547. </div>
  548. </div>
  549. <input type="hidden" name="action" value="admin" />
  550. <input type="hidden" name="area" value="packages" />
  551. <input type="hidden" name="sa" value="', $context['sub_action'], '" />
  552. </form>';
  553. echo '
  554. </div>
  555. <script type="text/javascript"><!-- // --><![CDATA[
  556. var oAdvancedPanelToggle = new smc_Toggle({
  557. bToggleEnabled: true,
  558. bCurrentlyCollapsed: ', empty($context['show_advanced_options']) ? 'true' : 'false', ',
  559. aSwappableContainers: [
  560. \'advanced_panel_div\'
  561. ],
  562. aSwapImages: [
  563. {
  564. sId: \'advanced_panel_toggle\',
  565. srcExpanded: smf_images_url + \'/collapse.png\',
  566. altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ',
  567. srcCollapsed: smf_images_url + \'/expand.png\',
  568. altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), '
  569. }
  570. ],
  571. aSwapLinks: [
  572. {
  573. sId: \'advanced_panel_link\',
  574. msgExpanded: ', JavaScriptEscape($txt['package_advanced_button']), ',
  575. msgCollapsed: ', JavaScriptEscape($txt['package_advanced_button']), '
  576. }
  577. ],
  578. oThemeOptions: {
  579. bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
  580. sOptionName: \'admin_preferences\',
  581. sSessionVar: smf_session_var,
  582. sSessionId: smf_session_id,
  583. sThemeId: \'1\'
  584. }
  585. });
  586. // ]]></script>
  587. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
  588. <script type="text/javascript"><!-- // --><![CDATA[
  589. var oAddVersionSuggest = new smc_AutoSuggest({
  590. sSelf: \'oAddVersionSuggest\',
  591. sSessionId: smf_session_id,
  592. sSessionVar: smf_session_var,
  593. sControlId: \'ve\',
  594. sSearchType: \'versions\',
  595. bItemList: false
  596. });
  597. // ]]></script>';
  598. }
  599. function template_servers()
  600. {
  601. global $context, $settings, $options, $txt, $scripturl;
  602. if (!empty($context['package_ftp']['error']))
  603. echo '
  604. <div class="errorbox">
  605. <tt>', $context['package_ftp']['error'], '</tt>
  606. </div>';
  607. echo '
  608. <div id="admin_form_wrapper">
  609. <div class="cat_bar">
  610. <h3 class="catbg">', $txt['download_new_package'], '</h3>
  611. </div>';
  612. if ($context['package_download_broken'])
  613. {
  614. echo '
  615. <div class="title_bar">
  616. <h3 class="titlebg">', $txt['package_ftp_necessary'], '</h3>
  617. </div>
  618. <div class="windowbg">
  619. <div class="content">
  620. <p>
  621. ', $txt['package_ftp_why_download'], '
  622. </p>
  623. <form action="', $scripturl, '?action=admin;area=packages;get" method="post" accept-charset="', $context['character_set'], '">
  624. <dl class="settings">
  625. <dt>
  626. <label for="ftp_server">', $txt['package_ftp_server'], ':</label>
  627. </dt>
  628. <dd>
  629. <input type="text" size="30" name="ftp_server" id="ftp_server" value="', $context['package_ftp']['server'], '" class="input_text" />
  630. <label for="ftp_port">', $txt['package_ftp_port'], ':&nbsp;</label> <input type="text" size="3" name="ftp_port" id="ftp_port" value="', $context['package_ftp']['port'], '" class="input_text" />
  631. </dd>
  632. <dt>
  633. <label for="ftp_username">', $txt['package_ftp_username'], ':</label>
  634. </dt>
  635. <dd>
  636. <input type="text" size="50" name="ftp_username" id="ftp_username" value="', $context['package_ftp']['username'], '" style="width: 99%;" class="input_text" />
  637. </dd>
  638. <dt>
  639. <label for="ftp_password">', $txt['package_ftp_password'], ':</label>
  640. </dt>
  641. <dd>
  642. <input type="password" size="50" name="ftp_password" id="ftp_password" style="width: 99%;" class="input_password" />
  643. </dd>
  644. <dt>
  645. <label for="ftp_path">', $txt['package_ftp_path'], ':</label>
  646. </dt>
  647. <dd>
  648. <input type="text" size="50" name="ftp_path" id="ftp_path" value="', $context['package_ftp']['path'], '" style="width: 99%;" class="input_text" />
  649. </dd>
  650. </dl>
  651. <div class="righttext">
  652. <input type="submit" value="', $txt['package_proceed'], '" class="button_submit" />
  653. </div>
  654. </form>
  655. </div>
  656. </div>';
  657. }
  658. echo '
  659. <div class="windowbg2">
  660. <div class="content">
  661. <fieldset>
  662. <legend>' . $txt['package_servers'] . '</legend>
  663. <ul class="package_servers">';
  664. foreach ($context['servers'] as $server)
  665. echo '
  666. <li class="flow_auto">
  667. <span class="floatleft">' . $server['name'] . '</span>
  668. <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span>
  669. <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span>
  670. </li>';
  671. echo '
  672. </ul>
  673. </fieldset>
  674. <fieldset>
  675. <legend>' . $txt['add_server'] . '</legend>
  676. <form action="' . $scripturl . '?action=admin;area=packages;get;sa=add" method="post" accept-charset="', $context['character_set'], '">
  677. <dl class="settings">
  678. <dt>
  679. <strong>' . $txt['server_name'] . ':</strong>
  680. </dt>
  681. <dd>
  682. <input type="text" name="servername" size="44" value="SMF" class="input_text" />
  683. </dd>
  684. <dt>
  685. <strong>' . $txt['serverurl'] . ':</strong>
  686. </dt>
  687. <dd>
  688. <input type="text" name="serverurl" size="44" value="http://" class="input_text" />
  689. </dd>
  690. </dl>
  691. <div class="righttext">
  692. <input type="submit" value="' . $txt['add_server'] . '" class="button_submit" />
  693. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
  694. </div>
  695. </form>
  696. </fieldset>
  697. <fieldset>
  698. <legend>', $txt['package_download_by_url'], '</legend>
  699. <form action="', $scripturl, '?action=admin;area=packages;get;sa=download;byurl;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  700. <dl class="settings">
  701. <dt>
  702. <strong>' . $txt['serverurl'] . ':</strong>
  703. </dt>
  704. <dd>
  705. <input type="text" name="package" size="44" value="http://" class="input_text" />
  706. </dd>
  707. <dt>
  708. <strong>', $txt['package_download_filename'], ':</strong>
  709. </dt>
  710. <dd>
  711. <input type="text" name="filename" size="44" class="input_text" /><br />
  712. <span class="smalltext">', $txt['package_download_filename_info'], '</span>
  713. </dd>
  714. </dl>
  715. <div class="righttext">
  716. <input type="submit" value="', $txt['download'], '" class="button_submit" />
  717. </div>
  718. </form>
  719. </fieldset>
  720. </div>
  721. </div>
  722. <br />
  723. <div class="cat_bar">
  724. <h3 class="catbg">' . $txt['package_upload_title'] . '</h3>
  725. </div>
  726. <div class="windowbg">
  727. <div class="content">
  728. <form action="' . $scripturl . '?action=admin;area=packages;get;sa=upload" method="post" accept-charset="', $context['character_set'], '" enctype="multipart/form-data" style="margin-bottom: 0;">
  729. <dl class="settings">
  730. <dt>
  731. <strong>' . $txt['package_upload_select'] . ':</strong>
  732. </dt>
  733. <dd>
  734. <input type="file" name="package" size="38" class="input_file" />
  735. </dd>
  736. </dl>
  737. <hr class="hrcolor" />
  738. <input type="submit" value="' . $txt['package_upload'] . '" class="button_submit" />
  739. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
  740. </form>
  741. </div>
  742. </div>
  743. </div>';
  744. }
  745. function template_package_confirm()
  746. {
  747. global $context, $settings, $options, $txt, $scripturl;
  748. echo '
  749. <div id="admincenter">
  750. <div class="cat_bar">
  751. <h3 class="catbg">', $context['page_title'], '</h3>
  752. </div>
  753. <div class="windowbg">
  754. <div class="content">
  755. <p>', $context['confirm_message'], '</p>
  756. <a href="', $context['proceed_href'], '">[ ', $txt['package_confirm_proceed'], ' ]</a> <a href="JavaScript:history.go(-1);">[ ', $txt['package_confirm_go_back'], ' ]</a>
  757. </div>
  758. </div>
  759. </div>';
  760. }
  761. function template_package_list()
  762. {
  763. global $context, $settings, $options, $txt, $scripturl, $smcFunc;
  764. echo '
  765. <div id="admincenter">
  766. <div class="cat_bar">
  767. <h3 class="catbg">' . $context['page_title'] . '</h3>
  768. </div>
  769. <div class="windowbg">
  770. <div class="content">';
  771. // No packages, as yet.
  772. if (empty($context['package_list']))
  773. echo '
  774. <ul>
  775. <li>', $txt['no_packages'], '</li>
  776. </ul>';
  777. // List out the packages...
  778. else
  779. {
  780. echo '
  781. <ul id="package_list">';
  782. foreach ($context['package_list'] as $i => $packageSection)
  783. {
  784. echo '
  785. <li>
  786. <strong><img id="ps_img_', $i, '" src="', $settings['images_url'], '/collapse.png" alt="*" style="display: none;" /> ', $packageSection['title'], '</strong>';
  787. if (!empty($packageSection['text']))
  788. echo '
  789. <div class="information">', $packageSection['text'], '</div>';
  790. echo '
  791. <', $context['list_type'], ' id="package_section_', $i, '" class="packages">';
  792. $alt = false;
  793. foreach ($packageSection['items'] as $id => $package)
  794. {
  795. echo '
  796. <li>';
  797. // Textual message. Could be empty just for a blank line...
  798. if ($package['is_text'])
  799. echo '
  800. ', empty($package['name']) ? '&nbsp;' : $package['name'];
  801. // This is supposed to be a rule..
  802. elseif ($package['is_line'])
  803. echo '
  804. <hr class="hrcolor" />';
  805. // A remote link.
  806. elseif ($package['is_remote'])
  807. {
  808. echo '
  809. <strong>', $package['link'], '</strong>';
  810. }
  811. // A title?
  812. elseif ($package['is_heading'] || $package['is_title'])
  813. {
  814. echo '
  815. <strong>', $package['name'], '</strong>';
  816. }
  817. // Otherwise, it's a package.
  818. else
  819. {
  820. // 1. Some mod [ Download ].
  821. echo '
  822. <strong><img id="ps_img_', $i, '_pkg_', $id, '" src="', $settings['images_url'], '/collapse.png" alt="*" style="display: none;" /> ', $package['can_install'] ? '<strong>' . $package['name'] . '</strong> <a href="' . $package['download']['href'] . '">[ ' . $txt['download'] . ' ]</a>': $package['name'];
  823. // Mark as installed and current?
  824. if ($package['is_installed'] && !$package['is_newer'])
  825. echo '<img src="', $settings['images_url'], '/icons/package_', $package['is_current'] ? 'installed' : 'old', '.png" width="12" height="11" class="centericon" style="margin-left: 2ex;" alt="', $package['is_current'] ? $txt['package_installed_current'] : $txt['package_installed_old'], '" />';
  826. echo '
  827. </strong>
  828. <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
  829. // Show the mod type?
  830. if ($package['type'] != '')
  831. echo '
  832. <li class="package_section">', $txt['package_type'], ':&nbsp; ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '</li>';
  833. // Show the version number?
  834. if ($package['version'] != '')
  835. echo '
  836. <li class="package_section">', $txt['mod_version'], ':&nbsp; ', $package['version'], '</li>';
  837. // How 'bout the author?
  838. if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link']))
  839. echo '
  840. <li class="package_section">', $txt['mod_author'], ':&nbsp; ', $package['author']['link'], '</li>';
  841. // The homepage....
  842. if ($package['author']['website']['link'] != '')
  843. echo '
  844. <li class="package_section">', $txt['author_website'], ':&nbsp; ', $package['author']['website']['link'], '</li>';
  845. // Desciption: bleh bleh!
  846. // Location of file: http://someplace/.
  847. echo '
  848. <li class="package_section">', $txt['file_location'], ':&nbsp; <a href="', $package['href'], '">', $package['href'], '</a></li>
  849. <li class="package_section"><div class="information">', $txt['package_description'], ':&nbsp; ', $package['description'], '</div></li>
  850. </ul>';
  851. }
  852. $alt = !$alt;
  853. echo '
  854. </li>';
  855. }
  856. echo '
  857. </', $context['list_type'], '>
  858. </li>';
  859. }
  860. echo '
  861. </ul>';
  862. }
  863. echo '
  864. </div>
  865. </div>
  866. <div class="padding smalltext floatleft">
  867. ', $txt['package_installed_key'], '
  868. <img src="', $settings['images_url'], '/icons/package_installed.png" alt="" class="centericon" style="margin-left: 1ex;" /> ', $txt['package_installed_current'], '
  869. <img src="', $settings['images_url'], '/icons/package_old.png" alt="" class="centericon" style="margin-left: 2ex;" /> ', $txt['package_installed_old'], '
  870. </div>
  871. </div>
  872. ';
  873. // Now go through and turn off all the sections.
  874. if (!empty($context['package_list']))
  875. {
  876. $section_count = count($context['package_list']);
  877. echo '
  878. <script type="text/javascript"><!-- // --><![CDATA[';
  879. foreach ($context['package_list'] as $section => $ps)
  880. {
  881. echo '
  882. var oPackageServerToggle_', $section, ' = new smc_Toggle({
  883. bToggleEnabled: true,
  884. bCurrentlyCollapsed: ', count($ps['items']) == 1 || $section_count == 1 ? 'false' : 'true', ',
  885. aSwappableContainers: [
  886. \'package_section_', $section, '\'
  887. ],
  888. aSwapImages: [
  889. {
  890. sId: \'ps_img_', $section, '\',
  891. srcExpanded: smf_images_url + \'/collapse.png\',
  892. altExpanded: \'*\',
  893. srcCollapsed: smf_images_url + \'/expand.png\',
  894. altCollapsed: \'*\'
  895. }
  896. ]
  897. });';
  898. foreach ($ps['items'] as $id => $package)
  899. {
  900. if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote'])
  901. echo '
  902. var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({
  903. bToggleEnabled: true,
  904. bCurrentlyCollapsed: true,
  905. aSwappableContainers: [
  906. \'package_section_', $section, '_pkg_', $id, '\'
  907. ],
  908. aSwapImages: [
  909. {
  910. sId: \'ps_img_', $section, '_pkg_', $id, '\',
  911. srcExpanded: smf_images_url + \'/collapse.png\',
  912. altExpanded: \'*\',
  913. srcCollapsed: smf_images_url + \'/expand.png\',
  914. altCollapsed: \'*\'
  915. }
  916. ]
  917. });';
  918. }
  919. }
  920. echo '
  921. // ]]></script>';
  922. }
  923. }
  924. function template_downloaded()
  925. {
  926. global $context, $settings, $options, $txt, $scripturl;
  927. echo '
  928. <div id="admincenter">
  929. <div class="cat_bar">
  930. <h3 class="catbg">', $context['page_title'], '</h3>
  931. </div>
  932. <div class="windowbg">
  933. <div class="content">
  934. <p>', (empty($context['package_server']) ? $txt['package_uploaded_successfully'] : $txt['package_downloaded_successfully']), '</p>
  935. <ul class="reset">
  936. <li class="reset"><span class="floatleft"><strong>', $context['package']['name'], '</strong></span>
  937. <span class="package_server floatright">', $context['package']['list_files']['link'], '</span>
  938. <span class="package_server floatright">', $context['package']['install']['link'], '</span>
  939. </li>
  940. </ul>
  941. <br /><br />
  942. <p><a href="', $scripturl, '?action=admin;area=packages;get', (isset($context['package_server']) ? ';sa=browse;server=' . $context['package_server'] : ''), '">[ ', $txt['back'], ' ]</a></p>
  943. </div>
  944. </div>
  945. </div>';
  946. }
  947. function template_install_options()
  948. {
  949. global $context, $settings, $options, $txt, $scripturl;
  950. echo '
  951. <div id="admincenter">
  952. <div class="cat_bar">
  953. <h3 class="catbg">', $txt['package_install_options'], '</h3>
  954. </div>
  955. <div class="information">
  956. ', $txt['package_install_options_ftp_why'], '
  957. </div>
  958. <div class="windowbg">
  959. <div class="content">
  960. <form action="', $scripturl, '?action=admin;area=packages;sa=options" method="post" accept-charset="', $context['character_set'], '">
  961. <dl class="settings">
  962. <dt>
  963. <label for="pack_server"><strong>', $txt['package_install_options_ftp_server'], ':</strong></label>
  964. </dt>
  965. <dd>
  966. <input type="text" name="pack_server" id="pack_server" value="', $context['package_ftp_server'], '" size="30" class="input_text" />
  967. </dd>
  968. <dt>
  969. <label for="pack_port"><strong>', $txt['package_install_options_ftp_port'], ':</strong></label>
  970. </dt>
  971. <dd>
  972. <input type="text" name="pack_port" id="pack_port" size="3" value="', $context['package_ftp_port'], '" class="input_text" />
  973. </dd>
  974. <dt>
  975. <label for="pack_user"><strong>', $txt['package_install_options_ftp_user'], ':</strong></label>
  976. </dt>
  977. <dd>
  978. <input type="text" name="pack_user" id="pack_user" value="', $context['package_ftp_username'], '" size="30" class="input_text" />
  979. </dd>
  980. <dt>
  981. <label for="package_make_backups">', $txt['package_install_options_make_backups'], '</label>
  982. </dt>
  983. <dd>
  984. <input type="checkbox" name="package_make_backups" id="package_make_backups" value="1" class="input_check"', $context['package_make_backups'] ? ' checked="checked"' : '', ' />
  985. </dd>
  986. <dt>
  987. <label for="package_make_full_backups">', $txt['package_install_options_make_full_backups'], '</label>
  988. </dt>
  989. <dd>
  990. <input type="checkbox" name="package_make_full_backups" id="package_make_full_backups" value="1" class="input_check"', $context['package_make_full_backups'] ? ' checked="checked"' : '', ' />
  991. </dd>
  992. </dl>
  993. <input type="submit" name="save" value="', $txt['save'], '" class="button_submit" />
  994. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  995. </form>
  996. </div>
  997. </div>
  998. </div>';
  999. }
  1000. function template_control_chmod()
  1001. {
  1002. global $context, $settings, $options, $txt, $scripturl;
  1003. // Nothing to do? Brilliant!
  1004. if (empty($context['package_ftp']))
  1005. return false;
  1006. if (empty($context['package_ftp']['form_elements_only']))
  1007. {
  1008. echo '
  1009. ', sprintf($txt['package_ftp_why'], 'document.getElementById(\'need_writable_list\').style.display = \'\'; return false;'), '<br />
  1010. <div id="need_writable_list" class="smalltext">
  1011. ', $txt['package_ftp_why_file_list'], '
  1012. <ul style="display: inline;">';
  1013. if (!empty($context['notwritable_files']))
  1014. foreach ($context['notwritable_files'] as $file)
  1015. echo '
  1016. <li>', $file, '</li>';
  1017. echo '
  1018. </ul>
  1019. </div>';
  1020. }
  1021. echo '
  1022. <div class="bordercolor" id="ftp_error_div" style="', (!empty($context['package_ftp']['error']) ? '' : 'display:none;'), 'padding: 1px; margin: 1ex;"><div class="windowbg2" id="ftp_error_innerdiv" style="padding: 1ex;">
  1023. <tt id="ftp_error_message">', !empty($context['package_ftp']['error']) ? $context['package_ftp']['error'] : '', '</tt>
  1024. </div></div>';
  1025. if (!empty($context['package_ftp']['destination']))
  1026. echo '
  1027. <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">';
  1028. echo '
  1029. <fieldset>
  1030. <dl class="settings">
  1031. <dt>
  1032. <label for="ftp_server">', $txt['package_ftp_server'], ':</label>
  1033. </dt>
  1034. <dd>
  1035. <input type="text" size="30" name="ftp_server" id="ftp_server" value="', $context['package_ftp']['server'], '" class="input_text" />
  1036. <label for="ftp_port">', $txt['package_ftp_port'], ':&nbsp;</label> <input type="text" size="3" name="ftp_port" id="ftp_port" value="', $context['package_ftp']['port'], '" class="input_text" />
  1037. </dd>
  1038. <dt>
  1039. <label for="ftp_username">', $txt['package_ftp_username'], ':</label>
  1040. </dt>
  1041. <dd>
  1042. <input type="text" size="50" name="ftp_username" id="ftp_username" value="', $context['package_ftp']['username'], '" style="width: 98%;" class="input_text" />
  1043. </dd>
  1044. <dt>
  1045. <label for="ftp_password">', $txt['package_ftp_password'], ':</label>
  1046. </dt>
  1047. <dd>
  1048. <input type="password" size="50" name="ftp_password" id="ftp_password" style="width: 98%;" class="input_password" />
  1049. </dd>
  1050. <dt>
  1051. <label for="ftp_path">', $txt['package_ftp_path'], ':</label>
  1052. </dt>
  1053. <dd>
  1054. <input type="text" size="50" name="ftp_path" id="ftp_path" value="', $context['package_ftp']['path'], '" style="width: 98%;" class="input_text" />
  1055. </dd>
  1056. </dl>
  1057. </fieldset>';
  1058. if (empty($context['package_ftp']['form_elements_only']))
  1059. echo '
  1060. <div class="righttext" style="margin: 1ex;">
  1061. <span id="test_ftp_placeholder_full"></span>
  1062. <input type="submit" value="', $txt['package_proceed'], '" class="button_submit" />
  1063. </div>';
  1064. if (!empty($context['package_ftp']['destination']))
  1065. echo '
  1066. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1067. </form>';
  1068. // Hide the details of the list.
  1069. if (empty($context['package_ftp']['form_elements_only']))
  1070. echo '
  1071. <script type="text/javascript"><!-- // --><![CDATA[
  1072. document.getElementById(\'need_writable_list\').style.display = \'none\';
  1073. // ]]></script>';
  1074. // Quick generate the test button.
  1075. echo '
  1076. <script type="text/javascript"><!-- // --><![CDATA[
  1077. // Generate a "test ftp" button.
  1078. var generatedButton = false;
  1079. function generateFTPTest()
  1080. {
  1081. // Don\'t ever call this twice!
  1082. if (generatedButton)
  1083. return false;
  1084. generatedButton = true;
  1085. // No XML?
  1086. if (!window.XMLHttpRequest || (!document.getElementById("test_ftp_placeholder") && !document.getElementById("test_ftp_placeholder_full")))
  1087. return false;
  1088. var ftpTest = document.createElement("input");
  1089. ftpTest.type = "button";
  1090. ftpTest.onclick = testFTP;
  1091. if (document.getElementById("test_ftp_placeholder"))
  1092. {
  1093. ftpTest.value = "', $txt['package_ftp_test'], '";
  1094. document.getElementById("test_ftp_placeholder").appendChild(ftpTest);
  1095. }
  1096. else
  1097. {
  1098. ftpTest.value = "', $txt['package_ftp_test_connection'], '";
  1099. document.getElementById("test_ftp_placeholder_full").appendChild(ftpTest);
  1100. }
  1101. }
  1102. function testFTPResults(oXMLDoc)
  1103. {
  1104. ajax_indicator(false);
  1105. // This assumes it went wrong!
  1106. var wasSuccess = false;
  1107. var message = "', addcslashes($txt['package_ftp_test_failed'], "'"), '";
  1108. var results = oXMLDoc.getElementsByTagName(\'results\')[0].getElementsByTagName(\'result\');
  1109. if (results.length > 0)
  1110. {
  1111. if (results[0].getAttribute(\'success\') == 1)
  1112. wasSuccess = true;
  1113. message = results[0].firstChild.nodeValue;
  1114. }
  1115. document.getElementById("ftp_error_div").style.display = "";
  1116. document.getElementById("ftp_error_div").style.backgroundColor = wasSuccess ? "green" : "red";
  1117. document.getElementById("ftp_error_innerdiv").style.backgroundColor = wasSuccess ? "#DBFDC7" : "#FDBDBD";
  1118. setInnerHTML(document.getElementById("ftp_error_message"), message);
  1119. }
  1120. generateFTPTest();
  1121. // ]]></script>';
  1122. // Make sure the button gets generated last.
  1123. $context['insert_after_template'] .= '
  1124. <script type="text/javascript"><!-- // --><![CDATA[
  1125. generateFTPTest();
  1126. // ]]></script>';
  1127. }
  1128. function template_ftp_required()
  1129. {
  1130. global $context, $settings, $options, $txt, $scripturl;
  1131. echo '
  1132. <fieldset>
  1133. <legend>
  1134. ', $txt['package_ftp_necessary'], '
  1135. </legend>
  1136. <div class="ftp_details">
  1137. ', template_control_chmod(), '
  1138. </div>
  1139. </fieldset>';
  1140. }
  1141. function template_view_operations()
  1142. {
  1143. global $context, $txt, $settings;
  1144. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  1145. <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
  1146. <head>
  1147. <title>', $txt['operation_title'], '</title>
  1148. <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
  1149. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
  1150. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/admin.css?alp21" />
  1151. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?alp21"></script>
  1152. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/theme.js?alp21"></script>
  1153. </head>
  1154. <body>
  1155. <div class="padding windowbg">
  1156. <div class="padding">
  1157. ', $context['operations']['search'], '
  1158. </div>
  1159. <div class="padding">
  1160. ', $context['operations']['replace'], '
  1161. </div>
  1162. </div>
  1163. </body>
  1164. </html>';
  1165. }
  1166. function template_file_permissions()
  1167. {
  1168. global $txt, $scripturl, $context, $settings;
  1169. // This will handle expanding the selection.
  1170. echo '
  1171. <script type="text/javascript"><!-- // --><![CDATA[
  1172. var oRadioColors = {
  1173. 0: "#D1F7BF",
  1174. 1: "#FFBBBB",
  1175. 2: "#FDD7AF",
  1176. 3: "#C2C6C0",
  1177. 4: "#EEEEEE"
  1178. }
  1179. var oRadioValues = {
  1180. 0: "read",
  1181. 1: "writable",
  1182. 2: "execute",
  1183. 3: "custom",
  1184. 4: "no_change"
  1185. }
  1186. function dynamicAddMore()
  1187. {
  1188. ajax_indicator(true);
  1189. getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=admin;area=packages;fileoffset=\' + (parseInt(this.offset) + ', $context['file_limit'], ') + \';onlyfind=\' + escape(this.path) + \';sa=perms;xml;', $context['session_var'], '=', $context['session_id'], '\', onNewFolderReceived);
  1190. }
  1191. // Getting something back?
  1192. function onNewFolderReceived(oXMLDoc)
  1193. {
  1194. ajax_indicator(false);
  1195. var fileItems = oXMLDoc.getElementsByTagName(\'folders\')[0].getElementsByTagName(\'folder\');
  1196. // No folders, no longer worth going further.
  1197. if (fileItems.length < 1)
  1198. {
  1199. if (oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0])
  1200. {
  1201. var rootName = oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0].firstChild.nodeValue;
  1202. var itemLink = document.getElementById(\'link_\' + rootName);
  1203. // Move the children up.
  1204. for (i = 0; i <= itemLink.childNodes.length; i++)
  1205. itemLink.parentNode.insertBefore(itemLink.childNodes[0], itemLink);
  1206. // And remove the link.
  1207. itemLink.parentNode.removeChild(itemLink);
  1208. }
  1209. return false;
  1210. }
  1211. var tableHandle = false;
  1212. var isMore = false;
  1213. var ident = "";
  1214. var my_ident = "";
  1215. var curLevel = 0;
  1216. for (var i = 0; i < fileItems.length; i++)
  1217. {
  1218. if (fileItems[i].getAttribute(\'more\') == 1)
  1219. {
  1220. isMore = true;
  1221. var curOffset = fileItems[i].getAttribute(\'offset\');
  1222. }
  1223. if (fileItems[i].getAttribute(\'more\') != 1 && document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\')))
  1224. {
  1225. ident = fileItems[i].getAttribute(\'ident\');
  1226. my_ident = fileItems[i].getAttribute(\'my_ident\');
  1227. curLevel = fileItems[i].getAttribute(\'level\') * 5;
  1228. curPath = fileItems[i].getAttribute(\'path\');
  1229. // Get where we\'re putting it next to.
  1230. tableHandle = document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\'));
  1231. var curRow = document.createElement("tr");
  1232. curRow.className = "windowbg";
  1233. curRow.id = "content_" + my_ident;
  1234. curRow.style.display = "";
  1235. var curCol = document.createElement("td");
  1236. curCol.className = "smalltext";
  1237. curCol.width = "40%";
  1238. // This is the name.
  1239. var fileName = document.createTextNode(fileItems[i].firstChild.nodeValue);
  1240. // Start by wacking in the spaces.
  1241. setInnerHTML(curCol, repeatString("&nbsp;", curLevel));
  1242. // Create the actual text.
  1243. if (fileItems[i].getAttribute(\'folder\') == 1)
  1244. {
  1245. var linkData = document.createElement("a");
  1246. linkData.name = "fol_" + my_ident;
  1247. linkData.id = "link_" + my_ident;
  1248. linkData.href = \'#\';
  1249. linkData.path = curPath + "/" + fileItems[i].firstChild.nodeValue;
  1250. linkData.ident = my_ident;
  1251. linkData.onclick = dynamicExpandFolder;
  1252. var folderImage = document.createElement("img");
  1253. folderImage.src = \'', addcslashes($settings['default_images_url'], "\\"), '/board.png\';
  1254. linkData.appendChild(folderImage);
  1255. linkData.appendChild(fileName);
  1256. curCol.appendChild(linkData);
  1257. }
  1258. else
  1259. curCol.appendChild(fileName);
  1260. curRow.appendChild(curCol);
  1261. // Right, the permissions.
  1262. curCol = document.createElement("td");
  1263. curCol.className = "smalltext";
  1264. var writeSpan = document.createElement("span");
  1265. writeSpan.style.color = fileItems[i].getAttribute(\'writable\') ? "green" : "red";
  1266. setInnerHTML(writeSpan, fileItems[i].getAttribute(\'writable\') ? \'', $txt['package_file_perms_writable'], '\' : \'', $txt['package_file_perms_not_writable'], '\');
  1267. curCol.appendChild(writeSpan);
  1268. if (fileItems[i].getAttribute(\'permissions\'))
  1269. {
  1270. var permData = document.createTextNode("\u00a0(', $txt['package_file_perms_chmod'], ': " + fileItems[i].getAttribute(\'permissions\') + ")");
  1271. curCol.appendChild(permData);
  1272. }
  1273. curRow.appendChild(curCol);
  1274. // Now add the five radio buttons.
  1275. for (j = 0; j < 5; j++)
  1276. {
  1277. curCol = document.createElement("td");
  1278. curCol.style.backgroundColor = oRadioColors[j];
  1279. curCol.align = "center";
  1280. var curInput = createNamedElement("input", "permStatus[" + curPath + "/" + fileItems[i].firstChild.nodeValue + "]", j == 4 ? \'checked="checked"\…

Large files files are truncated, but you can click here to view the full file