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('
'+hm_empty_folder()+'
'); } - $(".page_links").css("display", "none");// Hide page links as message list is empty } } else { diff --git a/modules/imap/output_modules.php b/modules/imap/output_modules.php index ee07b6365..0294edab3 100644 --- a/modules/imap/output_modules.php +++ b/modules/imap/output_modules.php @@ -976,7 +976,6 @@ class Hm_Output_filter_combined_inbox extends Hm_Output_Module { protected function output() { if ($this->get('imap_combined_inbox_data')) { prepare_imap_message_list($this->get('imap_combined_inbox_data'), $this, 'combined_inbox'); - $this->out('page_links', 'There is no pagination in this view, please visit the individual mail boxes.'); } else { $this->out('formatted_message_list', array()); @@ -1006,8 +1005,6 @@ protected function output() { } $max_pages = ceil($details['detail']['exists']/$details['limit']); $this->out('pages', $max_pages); - $this->out('page_links', build_page_links($details['limit'], $page_num, $details['detail']['exists'], - $this->get('imap_mailbox_page_path'), $this->html_safe($this->get('list_filter')), $this->html_safe($this->get('list_sort')), $this->html_safe($this->get('list_keyword')))); } elseif (!$this->get('formatted_message_list')) { $this->out('formatted_message_list', array()); diff --git a/tests/phpunit/modules/core/message_list_functions.php b/tests/phpunit/modules/core/message_list_functions.php index 4da49bec6..6c67482c7 100644 --- a/tests/phpunit/modules/core/message_list_functions.php +++ b/tests/phpunit/modules/core/message_list_functions.php @@ -163,15 +163,4 @@ public function test_search_field_selection() { $this->assertEquals('', search_field_selection('TEXT', $mod)); $this->assertEquals('', search_field_selection('foo', $mod)); } - /** - * @preserveGlobalState disabled - * @runInSeparateProcess - */ - public function test_build_page_links() { - $this->assertEquals(' 1 2 3 4 5 6 7 8 9 10 11 ... 100 ', build_page_links(10, 5, 1000, '/')); - $this->assertEquals(' 1 ... 4 5 6 7 8 9 10 11 12 13 14 ... 100 ', build_page_links(10, 10, 1000, '/')); - $this->assertEquals('', build_page_links(10, 1, 10, '/')); - $this->assertEquals(' 1 2 3 4 5 6 7 8 9 10 ', build_page_links(10, 1, 100, '/', true, true)); - $this->assertEquals(' 1 2 3 ', build_page_links(10, 1, 30, '/', true, true, "cypht")); - } } diff --git a/tests/phpunit/modules/core/output_modules.php b/tests/phpunit/modules/core/output_modules.php index 9b953753d..370bcc2f2 100644 --- a/tests/phpunit/modules/core/output_modules.php +++ b/tests/phpunit/modules/core/output_modules.php @@ -1139,6 +1139,6 @@ public function test_message_list_heading() { public function test_message_list_end() { $test = new Output_Test('message_list_end', 'core'); $res = $test->run(); - $this->assertEquals(array(''), $res->output_response); + $this->assertEquals(array(''), $res->output_response); } }