media-page.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?php
  2. /**
  3. * Admin Media Page for QDR Temporary Shared Storage
  4. *
  5. * @package QDR_Temporary_Shared_Storage
  6. */
  7. // If this file is called directly, abort.
  8. if (!defined('WPINC')) {
  9. die;
  10. }
  11. // Get current settings
  12. $settings = QDR_TSS_Settings::instance()->get_settings();
  13. $db_manager = QDR_TSS_DB_Manager::instance();
  14. // Get total storage usage
  15. $total_size = $db_manager->get_total_storage();
  16. $max_size = $settings['max_upload_size'];
  17. $usage_percent = ($max_size > 0) ? min(100, ($total_size / $max_size) * 100) : 0;
  18. ?>
  19. <div class="wrap qdr-tss-admin">
  20. <h1><?php esc_html_e('Shared Storage', 'qdr-temporary-shared-storage'); ?></h1>
  21. <div class="qdr-tss-storage-summary">
  22. <h2><?php esc_html_e('Storage Usage', 'qdr-temporary-shared-storage'); ?></h2>
  23. <div class="qdr-tss-storage-bar">
  24. <div class="qdr-tss-storage-used" style="width: <?php echo esc_attr($usage_percent); ?>%"></div>
  25. </div>
  26. <p>
  27. <?php echo esc_html(qdr_tss_format_bytes($total_size)); ?> / <?php echo esc_html(qdr_tss_format_bytes($max_size)); ?>
  28. (<?php echo number_format($usage_percent, 1); ?>%)
  29. </p>
  30. </div>
  31. <div class="qdr-tss-toolbar">
  32. <div class="qdr-tss-search">
  33. <input type="text" id="qdr-tss-search-filename" placeholder="<?php esc_attr_e('Search by filename', 'qdr-temporary-shared-storage'); ?>">
  34. <input type="text" id="qdr-tss-search-reference" placeholder="<?php esc_attr_e('Search by reference', 'qdr-temporary-shared-storage'); ?>">
  35. <button class="button" id="qdr-tss-search-button">
  36. <span class="dashicons dashicons-search"></span> <?php esc_html_e('Search', 'qdr-temporary-shared-storage'); ?>
  37. </button>
  38. <button class="button" id="qdr-tss-reset-search">
  39. <span class="dashicons dashicons-dismiss"></span> <?php esc_html_e('Reset', 'qdr-temporary-shared-storage'); ?>
  40. </button>
  41. </div>
  42. <div class="qdr-tss-actions">
  43. <button class="button button-primary" id="qdr-tss-refresh">
  44. <span class="dashicons dashicons-update"></span> <?php esc_html_e('Refresh', 'qdr-temporary-shared-storage'); ?>
  45. </button>
  46. </div>
  47. </div>
  48. <div class="qdr-tss-table-container">
  49. <table class="wp-list-table widefat fixed striped qdr-tss-table">
  50. <thead>
  51. <tr>
  52. <th class="column-fileid sortable" data-sort="fileid"><?php esc_html_e('File ID', 'qdr-temporary-shared-storage'); ?> <span class="sorting-indicator"></span></th>
  53. <th class="column-filename sortable" data-sort="original_file_name"><?php esc_html_e('File Name', 'qdr-temporary-shared-storage'); ?> <span class="sorting-indicator"></span></th>
  54. <th class="column-description"><?php esc_html_e('Description', 'qdr-temporary-shared-storage'); ?></th>
  55. <th class="column-message"><?php esc_html_e('Message', 'qdr-temporary-shared-storage'); ?></th>
  56. <th class="column-active-from sortable" data-sort="active_from"><?php esc_html_e('Active From', 'qdr-temporary-shared-storage'); ?> <span class="sorting-indicator"></span></th>
  57. <th class="column-active-to sortable" data-sort="active_to"><?php esc_html_e('Active To', 'qdr-temporary-shared-storage'); ?> <span class="sorting-indicator"></span></th>
  58. <th class="column-reference sortable" data-sort="reference"><?php esc_html_e('Reference', 'qdr-temporary-shared-storage'); ?> <span class="sorting-indicator"></span></th>
  59. <th class="column-upload-date sortable" data-sort="upload_date"><?php esc_html_e('Upload Date', 'qdr-temporary-shared-storage'); ?> <span class="sorting-indicator"></span></th>
  60. <th class="column-download-count sortable" data-sort="download_count"><?php esc_html_e('Downloads', 'qdr-temporary-shared-storage'); ?> <span class="sorting-indicator"></span></th>
  61. <th class="column-last-download sortable" data-sort="last_download"><?php esc_html_e('Last Download', 'qdr-temporary-shared-storage'); ?> <span class="sorting-indicator"></span></th>
  62. <th class="column-actions"><?php esc_html_e('Actions', 'qdr-temporary-shared-storage'); ?></th>
  63. </tr>
  64. </thead>
  65. <tbody id="qdr-tss-items-list">
  66. <tr>
  67. <td colspan="11" class="qdr-tss-loading">
  68. <span class="spinner is-active"></span> <?php esc_html_e('Loading...', 'qdr-temporary-shared-storage'); ?>
  69. </td>
  70. </tr>
  71. </tbody>
  72. </table>
  73. </div>
  74. <div class="qdr-tss-pagination">
  75. <div class="qdr-tss-pagination-info"></div>
  76. <div class="qdr-tss-pagination-controls"></div>
  77. </div>
  78. </div>
  79. <!-- Edit Item Modal -->
  80. <div id="qdr-tss-edit-modal" class="qdr-tss-modal">
  81. <div class="qdr-tss-modal-content">
  82. <span class="qdr-tss-modal-close">&times;</span>
  83. <h2><?php esc_html_e('Edit Shared File', 'qdr-temporary-shared-storage'); ?></h2>
  84. <form id="qdr-tss-edit-form">
  85. <input type="hidden" id="qdr-tss-edit-id" name="id">
  86. <div class="qdr-tss-form-row">
  87. <label for="qdr-tss-edit-description"><?php esc_html_e('Description', 'qdr-temporary-shared-storage'); ?></label>
  88. <textarea id="qdr-tss-edit-description" name="description" rows="3"></textarea>
  89. </div>
  90. <div class="qdr-tss-form-row">
  91. <label for="qdr-tss-edit-message"><?php esc_html_e('Message', 'qdr-temporary-shared-storage'); ?></label>
  92. <textarea id="qdr-tss-edit-message" name="message" rows="3"></textarea>
  93. </div>
  94. <div class="qdr-tss-form-row">
  95. <label for="qdr-tss-edit-active-from"><?php esc_html_e('Active From', 'qdr-temporary-shared-storage'); ?></label>
  96. <input type="text" id="qdr-tss-edit-active-from" name="active_from" class="qdr-tss-datepicker" autocomplete="off">
  97. </div>
  98. <div class="qdr-tss-form-row">
  99. <label for="qdr-tss-edit-active-to"><?php esc_html_e('Active To', 'qdr-temporary-shared-storage'); ?></label>
  100. <input type="text" id="qdr-tss-edit-active-to" name="active_to" class="qdr-tss-datepicker" autocomplete="off">
  101. </div>
  102. <div class="qdr-tss-form-row">
  103. <label for="qdr-tss-edit-reference"><?php esc_html_e('Reference', 'qdr-temporary-shared-storage'); ?></label>
  104. <input type="text" id="qdr-tss-edit-reference" name="reference">
  105. </div>
  106. <div class="qdr-tss-form-actions">
  107. <button type="submit" class="button button-primary"><?php esc_html_e('Save Changes', 'qdr-temporary-shared-storage'); ?></button>
  108. <button type="button" class="button qdr-tss-modal-cancel"><?php esc_html_e('Cancel', 'qdr-temporary-shared-storage'); ?></button>
  109. </div>
  110. </form>
  111. <div id="qdr-tss-edit-status"></div>
  112. </div>
  113. </div>
  114. <!-- View Details Modal -->
  115. <div id="qdr-tss-details-modal" class="qdr-tss-modal">
  116. <div class="qdr-tss-modal-content">
  117. <span class="qdr-tss-modal-close">&times;</span>
  118. <h2><?php esc_html_e('File Details', 'qdr-temporary-shared-storage'); ?></h2>
  119. <div class="qdr-tss-details-content">
  120. <table class="widefat striped">
  121. <tr>
  122. <th><?php esc_html_e('File ID', 'qdr-temporary-shared-storage'); ?></th>
  123. <td id="qdr-tss-details-fileid"></td>
  124. </tr>
  125. <tr>
  126. <th><?php esc_html_e('File Name', 'qdr-temporary-shared-storage'); ?></th>
  127. <td id="qdr-tss-details-filename"></td>
  128. </tr>
  129. <tr>
  130. <th><?php esc_html_e('Description', 'qdr-temporary-shared-storage'); ?></th>
  131. <td id="qdr-tss-details-description"></td>
  132. </tr>
  133. <tr>
  134. <th><?php esc_html_e('Message', 'qdr-temporary-shared-storage'); ?></th>
  135. <td id="qdr-tss-details-message"></td>
  136. </tr>
  137. <tr>
  138. <th><?php esc_html_e('Reference', 'qdr-temporary-shared-storage'); ?></th>
  139. <td id="qdr-tss-details-reference"></td>
  140. </tr>
  141. <tr>
  142. <th><?php esc_html_e('Active Period', 'qdr-temporary-shared-storage'); ?></th>
  143. <td id="qdr-tss-details-active-period"></td>
  144. </tr>
  145. <tr>
  146. <th><?php esc_html_e('File Size', 'qdr-temporary-shared-storage'); ?></th>
  147. <td id="qdr-tss-details-filesize"></td>
  148. </tr>
  149. <tr>
  150. <th><?php esc_html_e('Download Count', 'qdr-temporary-shared-storage'); ?></th>
  151. <td id="qdr-tss-details-download-count"></td>
  152. </tr>
  153. <tr>
  154. <th><?php esc_html_e('Last Download', 'qdr-temporary-shared-storage'); ?></th>
  155. <td id="qdr-tss-details-last-download"></td>
  156. </tr>
  157. <tr>
  158. <th><?php esc_html_e('Permalink', 'qdr-temporary-shared-storage'); ?></th>
  159. <td id="qdr-tss-details-permalink"></td>
  160. </tr>
  161. <tr>
  162. <th><?php esc_html_e('Shortcode', 'qdr-temporary-shared-storage'); ?></th>
  163. <td id="qdr-tss-details-shortcode"></td>
  164. </tr>
  165. </table>
  166. </div>
  167. <div class="qdr-tss-form-actions">
  168. <button type="button" class="button button-secondary qdr-tss-copy-shortcode"><?php esc_html_e('Copy Shortcode', 'qdr-temporary-shared-storage'); ?></button>
  169. <button type="button" class="button button-secondary qdr-tss-copy-permalink"><?php esc_html_e('Copy Permalink', 'qdr-temporary-shared-storage'); ?></button>
  170. <button type="button" class="button qdr-tss-modal-cancel"><?php esc_html_e('Close', 'qdr-temporary-shared-storage'); ?></button>
  171. </div>
  172. </div>
  173. </div>
  174. <!-- Confirm Delete Modal -->
  175. <div id="qdr-tss-confirm-delete-modal" class="qdr-tss-modal">
  176. <div class="qdr-tss-modal-content qdr-tss-modal-sm">
  177. <span class="qdr-tss-modal-close">&times;</span>
  178. <h2><?php esc_html_e('Confirm Delete', 'qdr-temporary-shared-storage'); ?></h2>
  179. <p><?php esc_html_e('Are you sure you want to delete this file? This action cannot be undone.', 'qdr-temporary-shared-storage'); ?></p>
  180. <div class="qdr-tss-form-actions">
  181. <button type="button" class="button button-primary qdr-tss-confirm-delete-button"><?php esc_html_e('Delete', 'qdr-temporary-shared-storage'); ?></button>
  182. <button type="button" class="button qdr-tss-modal-cancel"><?php esc_html_e('Cancel', 'qdr-temporary-shared-storage'); ?></button>
  183. </div>
  184. <input type="hidden" id="qdr-tss-delete-id">
  185. </div>
  186. </div>