ManageAttachments.template.php 11 KB

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