From f93c37b370ea2460682f3c5d115a17f06c921da8 Mon Sep 17 00:00:00 2001 From: Merci Jacob <68013195+mercihabam@users.noreply.github.com> Date: Tue, 24 Dec 2024 15:13:29 +0200 Subject: [PATCH] ref(frontend/backend): remove the remnants of the legacy page links (#1414) --- modules/core/js_modules/actions/pagination.js | 4 +- modules/core/message_list_functions.php | 76 ------------------- modules/core/output_modules.php | 3 +- modules/core/setup.php | 1 - modules/core/site.js | 3 +- modules/imap/output_modules.php | 3 - .../modules/core/message_list_functions.php | 11 --- tests/phpunit/modules/core/output_modules.php | 2 +- 8 files changed, 5 insertions(+), 98 deletions(-) diff --git a/modules/core/js_modules/actions/pagination.js b/modules/core/js_modules/actions/pagination.js index 9789079c3..33288ab5e 100644 --- a/modules/core/js_modules/actions/pagination.js +++ b/modules/core/js_modules/actions/pagination.js @@ -1,6 +1,6 @@ function refreshNextButton(current) { const totalPages = $(".pagination .total").text(); - if (current >= totalPages) { + if (parseInt(current) >= parseInt(totalPages)) { $(".pagination .next").prop('disabled', true); } else { $(".pagination .next").prop('disabled', false); @@ -8,7 +8,7 @@ function refreshNextButton(current) { } function refreshPreviousButton(current) { - if (current <= 1) { + if (parseInt(current) <= 1) { $(".pagination .prev").prop('disabled', true); } else { $(".pagination .prev").prop('disabled', false); diff --git a/modules/core/message_list_functions.php b/modules/core/message_list_functions.php index 6a4362790..95b5586b2 100644 --- a/modules/core/message_list_functions.php +++ b/modules/core/message_list_functions.php @@ -602,79 +602,3 @@ function search_field_selection($current, $output_mod) { $res .= ''; return $res; }} - -/** - * Build pagination links for a list of messages - * @subpackage core/functions - * @param int $page_size number of messages per page - * @param int $current current page number - * @param int $total number of messages total - * @param string $path list path - * @param string $filter list filter - * @param string $sort list sort - * @return string - */ -if (!hm_exists('build_page_links')) { -function build_page_links($page_size, $current_page, $total, $path, $filter=false, $sort=false, $keyword=false) { - $links = ''; - $first = ''; - $last = ''; - $display_links = 10; - if ($filter) { - $filter_str = '&filter='.$filter; - } - else { - $filter_str = ''; - } - if ($sort) { - $sort_str = '&sort='.$sort; - } - else { - $sort_str = ''; - } - if ($keyword) { - $keyword_str = '&keyword='.$keyword; - } - else { - $keyword_str = ''; - } - - $max_pages = ceil($total/$page_size); - if ($max_pages == 1) { - return ''; - } - $floor = ($current_page - 1) - intval($display_links/2); - if ($floor < 0) { - $floor = 1; - } - $ceil = $floor + $display_links; - if ($ceil > $max_pages) { - $floor -= ($ceil - $max_pages); - } - $prev = ''; - $next = ''; - - if ($floor > 1 ) { - $first = '1 ... '; - } - if ($ceil < $max_pages) { - $last = ' ... '.$max_pages.''; - } - if ($current_page > 1) { - $prev = ''; - } - if ($max_pages > 1 && $current_page < $max_pages) { - $next = ''; - } - for ($i=1;$i<=$max_pages;$i++) { - if ($i < $floor || $i > $ceil) { - continue; - } - $links .= ' '.$i.''; - } - return $prev.' '.$first.$links.$last.' '.$next; -}} diff --git a/modules/core/output_modules.php b/modules/core/output_modules.php index 12bedb23a..95799220f 100644 --- a/modules/core/output_modules.php +++ b/modules/core/output_modules.php @@ -1996,7 +1996,7 @@ class Hm_Output_message_list_end extends Hm_Output_Module { * Close the table opened in Hm_Output_message_list_start */ protected function output() { - $res = '
'; + $res = ''; return $res; } } @@ -2444,6 +2444,5 @@ protected function output() { $messageList = array_merge($messageList, $this->get('feed_list_data'), Hm_Output_filter_feed_list_data::formatMessageList($this)); } $this->out('formatted_message_list', $messageList); - $this->out('page_links', 'There is no pagination in this view, please visit the individual mail boxes.'); } } diff --git a/modules/core/setup.php b/modules/core/setup.php index 957aa405d..2c5648447 100644 --- a/modules/core/setup.php +++ b/modules/core/setup.php @@ -227,7 +227,6 @@ 'msg_text' => array(FILTER_UNSAFE_RAW, false), 'msg_source' => array(FILTER_UNSAFE_RAW, false), 'msg_parts' => array(FILTER_UNSAFE_RAW, false), - 'page_links' => array(FILTER_UNSAFE_RAW, false), 'pages' => array(FILTER_VALIDATE_INT, false), 'folder_status' => array(FILTER_DEFAULT, FILTER_REQUIRE_ARRAY), 'imap_server_id' => array(FILTER_DEFAULT, false), diff --git a/modules/core/site.js b/modules/core/site.js index a1d27ebd9..682cdb045 100644 --- a/modules/core/site.js +++ b/modules/core/site.js @@ -243,7 +243,7 @@ var Hm_Ajax_Request = function() { return { messages.load().then(() => { if (messages.count != res.folder_status[name].messages) { messages.load(true).then(() => { - display_imap_mailbox(messages.rows, messages.links); + display_imap_mailbox(messages.rows, messages.list); }) } }); @@ -889,7 +889,6 @@ function Message_List() { else { $('.message_list').append('