diff options
author | Rubén Calvo <rubencm@gmail.com> | 2017-10-17 18:45:56 +0200 |
---|---|---|
committer | Rubén Calvo <rubencm@gmail.com> | 2017-10-17 18:47:47 +0200 |
commit | 3f95d49fee64d05ad03fab9ea1363de7e2fad4ac (patch) | |
tree | dc3342341e4183b9a8c470a1026b5b90058e553d /phpBB | |
parent | ee9eb586dd49edd8044a9910782a01aef691e0df (diff) | |
download | forums-3f95d49fee64d05ad03fab9ea1363de7e2fad4ac.tar forums-3f95d49fee64d05ad03fab9ea1363de7e2fad4ac.tar.gz forums-3f95d49fee64d05ad03fab9ea1363de7e2fad4ac.tar.bz2 forums-3f95d49fee64d05ad03fab9ea1363de7e2fad4ac.tar.xz forums-3f95d49fee64d05ad03fab9ea1363de7e2fad4ac.zip |
[ticket/15041] Add pagination to orphaned attachments
PHPBB3-15041
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/adm/style/acp_attachments.html | 24 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_attachments.php | 35 |
2 files changed, 56 insertions, 3 deletions
diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index e1f7f140c9..5e0c841d2b 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -329,6 +329,17 @@ <fieldset class="tabulated"> <legend>{L_TITLE}</legend> + <div class="pagination top-pagination"> + <!-- IF .pagination or TOTAL_FILES --> + {L_NUMBER_FILES}{L_COLON} {TOTAL_FILES} • {L_TOTAL_SIZE}{L_COLON} {TOTAL_SIZE} + <!-- IF .pagination --> + • <!-- INCLUDE pagination.html --> + <!-- ELSE --> + • {PAGE_NUMBER} + <!-- ENDIF --> + <!-- ENDIF --> + </div> + <table class="table1 zebra-table fixed-width-table"> <thead> <tr> @@ -359,7 +370,16 @@ </tbody> </table> - <br /> + <!-- IF TOTAL_FILES --> + <div class="pagination"> + {L_NUMBER_FILES}{L_COLON} {TOTAL_FILES} • {L_TOTAL_SIZE}{L_COLON} {TOTAL_SIZE} + <!-- IF .pagination --> + • <!-- INCLUDE pagination.html --> + <!-- ELSE --> + • {PAGE_NUMBER} + <!-- ENDIF --> + </div> + <!-- ENDIF --> <p class="submit-buttons"> <input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" /> @@ -440,7 +460,7 @@ <input class="button2" type="submit" name="submit" value="{L_DELETE_MARKED}" /><br /> <p class="small"> <a href="#" onclick="marklist('attachments', 'delete', true); return false;">{L_MARK_ALL}</a> • - <a href="#" onclick="marklist('attachments', 'delete', false); return false;">{L_UNMARK_ALL}</a> + <a href="#" onclick="marklist('attachments', 'delete', false); return false;">{L_UNMARK_ALL}</a> </p> </fieldset> <!-- ENDIF --> diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 3cfe5de293..2480f1f025 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -922,6 +922,9 @@ class acp_attachments case 'orphan': + /* @var $pagination \phpbb\pagination */ + $pagination = $this->phpbb_container->get('pagination'); + if ($submit) { $delete_files = (isset($_POST['delete'])) ? array_keys($request->variable('delete', array('' => 0))) : array(); @@ -1064,13 +1067,29 @@ class acp_attachments 'S_ORPHAN' => true) ); + $attachments_per_page = (int) $config['topics_per_page']; + + // Get total number or orphans older than 3 hours + $sql = 'SELECT COUNT(attach_id) as num_files, SUM(filesize) as total_size + FROM ' . ATTACHMENTS_TABLE . ' + WHERE is_orphan = 1 + AND filetime < ' . (time() - 3*60*60); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $num_files = (int) $row['num_files']; + $total_size = (int) $row['total_size']; + $this->db->sql_freeresult($result); + + $start = $request->variable('start', 0); + $start = $pagination->validate_start($start, $attachments_per_page, $num_files); + // Just get the files with is_orphan set and older than 3 hours $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 1 AND filetime < ' . (time() - 3*60*60) . ' ORDER BY filetime DESC'; - $result = $db->sql_query($sql); + $result = $db->sql_query_limit($sql, $attachments_per_page, $start); while ($row = $db->sql_fetchrow($result)) { @@ -1086,6 +1105,20 @@ class acp_attachments } $db->sql_freeresult($result); + $pagination->generate_template_pagination( + $this->u_action, + 'pagination', + 'start', + $num_files, + $attachments_per_page, + $start + ); + + $template->assign_vars(array( + 'TOTAL_FILES' => $num_files, + 'TOTAL_SIZE' => get_formatted_filesize($total_size), + )); + break; case 'manage': |