From 3dacf7378d2030463668455437efb869233289f6 Mon Sep 17 00:00:00 2001 From: Marek Rost Date: Sat, 18 Sep 2021 13:41:56 +0200 Subject: [PATCH] Improvements to bootstrap pagination function. Maintaining full compatibility. Added missing classes to certain elements like page number links, slightly simplified the conditional logic for first+last page button display. Added first and last button text override parameters and option to not show them with default to invisible. Made the bootstrap_html actually use these parameters when configured. --- bl-kernel/helpers/paginator.class.php | 67 +++++++++++++++++---------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/bl-kernel/helpers/paginator.class.php b/bl-kernel/helpers/paginator.class.php index 70207bef..2a1727f8 100644 --- a/bl-kernel/helpers/paginator.class.php +++ b/bl-kernel/helpers/paginator.class.php @@ -99,7 +99,7 @@ class Paginator { $uri = $domain.'/'.$filter.'/'.$url->slug(); } - return $uri.'?page='.$pageNumber; + return $uri.($pageNumber > 1 ? '?page='.$pageNumber : ''); } public static function html($textPrevPage=false, $textNextPage=false, $showPageNumber=false) @@ -144,7 +144,7 @@ class Paginator { /* * Bootstrap Pagination */ - public static function bootstrap_html($textPrevPage=false, $textNextPage=false, $showPageNumber=false){ + public static function bootstrap_html($textPrevPage=false, $textNextPage=false, $showPageNumber=false, $showFirstLast=false, $textFirstPage=false, $textLastPage=false){ global $language; @@ -154,39 +154,56 @@ class Paginator { $first_page = self::firstPage(); $last_page = self::lastPageUrl(); $show_next = (self::showNext()) ? "" : "disabled"; - $show_previois = (self::showPrev()) ? "" : "disabled"; + $show_previous = (self::showPrev()) ? "" : "disabled"; + + if($textPrevPage===false) { + $textPrevPage = ' '.$language->get('Previous'); + } + if($textNextPage===false) { + $textNextPage = $language->get('Next').' '; + } + if($textFirstPage===false) { + $textFirstPage = $language->get('First'); + } + if($textLastPage===false) { + $textLastPage = $language->get('Last'); + } $html = '';