2
0

ManageAttachments.template.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2013 Simple Machines and individual contributors
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. // Template template wraps around the simple settings page to add javascript functionality.
  13. function template_avatar_settings_above()
  14. {
  15. }
  16. function template_avatar_settings_below()
  17. {
  18. echo '
  19. <script type="text/javascript"><!-- // --><![CDATA[
  20. var fUpdateStatus = function ()
  21. {
  22. document.getElementById("avatar_max_width_external").disabled = document.getElementById("avatar_download_external").checked;
  23. document.getElementById("avatar_max_height_external").disabled = document.getElementById("avatar_download_external").checked;
  24. document.getElementById("avatar_action_too_large").disabled = document.getElementById("avatar_download_external").checked;
  25. }
  26. addLoadEvent(fUpdateStatus);
  27. // ]]></script>
  28. ';
  29. }
  30. function template_maintenance()
  31. {
  32. global $context, $settings, $options, $scripturl, $txt, $modSettings;
  33. echo '
  34. <div id="manage_attachments">
  35. <div class="cat_bar">
  36. <h3 class="catbg">', $txt['attachment_stats'], '</h3>
  37. </div>
  38. <div class="windowbg">
  39. <div class="content">
  40. <dl class="settings">
  41. <dt><strong>', $txt['attachment_total'], ':</strong></dt><dd>', $context['num_attachments'], '</dd>
  42. <dt><strong>', $txt['attachment_manager_total_avatars'], ':</strong></dt><dd>', $context['num_avatars'], '</dd>
  43. <dt><strong>', $txt['attachmentdir_size'], ':</strong></dt><dd>', $context['attachment_total_size'], ' ', $txt['kilobyte'], '</dd>
  44. <dt><strong>', $txt['attach_current_dir'], ':</strong></dt><dd>', $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']], '</dd>
  45. <dt><strong>', $txt['attachmentdir_size_current'], ':</strong></dt><dd>', $context['attachment_current_size'], ' ', $txt['kilobyte'], '</dd>
  46. <dt><strong>', $txt['attachment_space'], ':</strong></dt><dd>', isset($context['attachment_space']) ? $context['attachment_space'] . ' ' . $txt['kilobyte'] : $txt['attachmentdir_size_not_set'], '</dd>
  47. <dt><strong>', $txt['attachmentdir_files_current'], ':</strong></dt><dd>', $context['attachment_current_files'], '</dd>
  48. <dt><strong>', $txt['attachment_files'], ':</strong></dt><dd>', isset($context['attachment_files']) ? $context['attachment_files'] : $txt['attachmentdir_files_not_set'], '</dd>
  49. </dl>
  50. </div>
  51. </div>
  52. <div class="cat_bar">
  53. <h3 class="catbg">', $txt['attachment_integrity_check'], '</h3>
  54. </div>
  55. <div class="windowbg">
  56. <div class="content">
  57. <form action="', $scripturl, '?action=admin;area=manageattachments;sa=repair;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  58. <p>', $txt['attachment_integrity_check_desc'], '</p>
  59. <hr class="hrcolor" />
  60. <input type="submit" name="repair" value="', $txt['attachment_check_now'], '" class="button_submit" />
  61. <br class="clear_right" />
  62. </form>
  63. </div>
  64. </div>
  65. <div class="cat_bar">
  66. <h3 class="catbg">', $txt['attachment_pruning'], '</h3>
  67. </div>
  68. <div class="windowbg">
  69. <div class="content">
  70. <form action="', $scripturl, '?action=admin;area=manageattachments" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirm(\'', $txt['attachment_pruning_warning'], '\');" style="margin: 0 0 2ex 0;">
  71. ', $txt['attachment_remove_old'], ' <input type="text" name="age" value="25" size="4" class="input_text" /> ', $txt['days_word'], '<br />
  72. ', $txt['attachment_pruning_message'], ': <input type="text" name="notice" value="', $txt['attachment_delete_admin'], '" size="40" class="input_text" /><br />
  73. <input type="submit" name="remove" value="', $txt['remove'], '" class="button_submit" />
  74. <input type="hidden" name="type" value="attachments" />
  75. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  76. <input type="hidden" name="sa" value="byAge" />
  77. <br class="clear_right" />
  78. </form>
  79. <hr />
  80. <form action="', $scripturl, '?action=admin;area=manageattachments" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirm(\'', $txt['attachment_pruning_warning'], '\');" style="margin: 0 0 2ex 0;">
  81. ', $txt['attachment_remove_size'], ' <input type="text" name="size" id="size" value="100" size="4" class="input_text" /> ', $txt['kilobyte'], '<br />
  82. ', $txt['attachment_pruning_message'], ': <input type="text" name="notice" value="', $txt['attachment_delete_admin'], '" size="40" class="input_text" /><br />
  83. <input type="submit" name="remove" value="', $txt['remove'], '" class="button_submit" />
  84. <input type="hidden" name="type" value="attachments" />
  85. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  86. <input type="hidden" name="sa" value="bySize" />
  87. <br class="clear_right" />
  88. </form>
  89. <hr />
  90. <form action="', $scripturl, '?action=admin;area=manageattachments" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirm(\'', $txt['attachment_pruning_warning'], '\');" style="margin: 0 0 2ex 0;">
  91. ', $txt['attachment_manager_avatars_older'], ' <input type="text" name="age" value="45" size="4" class="input_text" /> ', $txt['days_word'], '<br />
  92. <input type="submit" name="remove" value="', $txt['remove'], '" class="button_submit" />
  93. <input type="hidden" name="type" value="avatars" />
  94. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  95. <input type="hidden" name="sa" value="byAge" />
  96. </form>
  97. </div>
  98. </div>
  99. </div>';
  100. echo '
  101. <div id="transfer" class="cat_bar">
  102. <h3 class="catbg">', $txt['attachment_transfer'], '</h3>
  103. </div>';
  104. if (!empty($context['results']))
  105. echo '
  106. <div class="noticebox">', $context['results'], '</div>';
  107. echo '
  108. <div class="windowbg">
  109. <div class="content">
  110. <form action="', $scripturl, '?action=admin;area=manageattachments;sa=transfer" method="post" accept-charset="', $context['character_set'], '">
  111. <p>', $txt['attachment_transfer_desc'], '</p>
  112. <hr class="hrcolor" />
  113. <dl class="settings">
  114. <dt>', $txt['attachment_transfer_from'], '</dt>
  115. <dd><select name="from">
  116. <option value="0">', $txt['attachment_transfer_select'], '</option>';
  117. foreach ($context['attach_dirs'] as $id => $dir)
  118. echo '
  119. <option value="', $id, '">', $dir, '</option>';
  120. echo '
  121. </select></dd>
  122. <dt>', $txt['attachment_transfer_auto'], '</dt>
  123. <dd><select name="auto">
  124. <option value="0">', $txt['attachment_transfer_auto_select'], '</option>
  125. <option value="-1">', $txt['attachment_transfer_forum_root'], '</option>';
  126. if (!empty($context['base_dirs']))
  127. foreach ($context['base_dirs'] as $id => $dir)
  128. echo '
  129. <option value="', $id, '">', $dir, '</option>';
  130. else
  131. echo '
  132. <option value="0" disabled="disabled">', $txt['attachment_transfer_no_base'], '</option>';
  133. echo '
  134. </select></dd>
  135. <dt>', $txt['attachment_transfer_to'], '</dt>
  136. <dd><select name="to">
  137. <option value="0">', $txt['attachment_transfer_select'], '</option>';
  138. foreach ($context['attach_dirs'] as $id => $dir)
  139. echo '
  140. <option value="', $id, '">', $dir, '</option>';
  141. echo '
  142. </select></dd>';
  143. if (!empty($modSettings['attachmentDirFileLimit']))
  144. echo '
  145. <dt>', $txt['attachment_transfer_empty'], '</dt>
  146. <dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked="checked"' : '', ' /></dd>';
  147. echo '
  148. </dl>
  149. <hr class="hrcolor"/>
  150. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  151. <input type="submit" onclick="start_progress()" name="transfer" value="', $txt['attachment_transfer_now'], '" class="button_submit" />
  152. <div id="progress_msg"></div>
  153. <div id="show_progress" class="padding"></div>
  154. <br class="clear_right" />
  155. </form>
  156. <script type="text/javascript"><!-- // --><![CDATA[
  157. function start_progress() {
  158. setTimeout(\'show_msg()\', 1000);
  159. }
  160. function show_msg() {
  161. $(\'#progress_msg\').html(\'<div><img src="', $settings['actual_images_url'], '/loading_sm.gif" alt="', $txt['ajax_in_progress'], '" width="35" height="35" />&nbsp; ', $txt['attachment_transfer_progress'] , '<\/div>\');
  162. show_progress();
  163. }
  164. function show_progress() {
  165. $(\'#show_progress\').load("progress.php");
  166. setTimeout(\'show_progress()\', 1500);
  167. }
  168. // ]]></script>
  169. </div>
  170. </div>
  171. <br class="clear" />';
  172. }
  173. function template_attachment_repair()
  174. {
  175. global $context, $txt, $scripturl, $settings;
  176. // If we've completed just let them know!
  177. if ($context['completed'])
  178. {
  179. echo '
  180. <div id="manage_attachments">
  181. <div class="cat_bar">
  182. <h3 class="catbg">', $txt['repair_attachments_complete'], '</h3>
  183. </div>
  184. <div class="windowbg">
  185. <div class="content">
  186. ', $txt['repair_attachments_complete_desc'], '
  187. </div>
  188. </div>
  189. </div>
  190. <br class="clear" />';
  191. }
  192. // What about if no errors were even found?
  193. elseif (!$context['errors_found'])
  194. {
  195. echo '
  196. <div id="manage_attachments">
  197. <div class="cat_bar">
  198. <h3 class="catbg">', $txt['repair_attachments_complete'], '</h3>
  199. </div>
  200. <div class="windowbg">
  201. <div class="content">
  202. ', $txt['repair_attachments_no_errors'], '
  203. </div>
  204. </div>
  205. </div>
  206. <br class="clear" />';
  207. }
  208. // Otherwise, I'm sad to say, we have a problem!
  209. else
  210. {
  211. echo '
  212. <div id="manage_attachments">
  213. <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=manageattachments;sa=repair;fixErrors=1;step=0;substep=0;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  214. <div class="cat_bar">
  215. <h3 class="catbg">', $txt['repair_attachments'], '</h3>
  216. </div>
  217. <div class="windowbg">
  218. <div class="content">
  219. <p>', $txt['repair_attachments_error_desc'], '</p>';
  220. // Loop through each error reporting the status
  221. foreach ($context['repair_errors'] as $error => $number)
  222. {
  223. if (!empty($number))
  224. echo '
  225. <input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '" class="input_check" />
  226. <label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br />';
  227. }
  228. echo ' <br />
  229. <input type="submit" value="', $txt['repair_attachments_continue'], '" class="button_submit" />
  230. <input type="submit" name="cancel" value="', $txt['repair_attachments_cancel'], '" class="button_submit" />
  231. </div>
  232. </div>
  233. </form>
  234. </div>
  235. <br class="clear" />';
  236. }
  237. }
  238. function template_attachment_paths()
  239. {
  240. global $modSettings;
  241. if (!empty($modSettings['attachment_basedirectories']))
  242. {
  243. template_show_list('base_paths');
  244. }
  245. template_show_list('attach_paths');
  246. }
  247. ?>