diff --git a/components/com_contact/views/category/view.html.php b/components/com_contact/views/category/view.html.php index 0ccc65636ba06..d04bf1757e670 100644 --- a/components/com_contact/views/category/view.html.php +++ b/components/com_contact/views/category/view.html.php @@ -53,6 +53,9 @@ public function display($tpl = null) { parent::commonCategoryDisplay(); + // Flag indicates to not add limitstart=0 to URL + $this->pagination->hideEmptyLimitstart = true; + // Prepare the data. // Compute the contact slug. foreach ($this->items as $item) diff --git a/components/com_contact/views/featured/view.html.php b/components/com_contact/views/featured/view.html.php index 33903ddf80a05..690797bf740c5 100644 --- a/components/com_contact/views/featured/view.html.php +++ b/components/com_contact/views/featured/view.html.php @@ -82,6 +82,9 @@ public function display($tpl = null) $parent = $this->get('Parent'); $pagination = $this->get('Pagination'); + // Flag indicates to not add limitstart=0 to URL + $pagination->hideEmptyLimitstart = true; + // Check for errors. if (count($errors = $this->get('Errors'))) { diff --git a/components/com_content/views/archive/view.html.php b/components/com_content/views/archive/view.html.php index 0171db6e07e42..99d18e98c849a 100644 --- a/components/com_content/views/archive/view.html.php +++ b/components/com_content/views/archive/view.html.php @@ -40,6 +40,9 @@ public function display($tpl = null) $items = $this->get('Items'); $pagination = $this->get('Pagination'); + // Flag indicates to not add limitstart=0 to URL + $pagination->hideEmptyLimitstart = true; + // Get the page/component configuration $params = &$state->params; diff --git a/components/com_content/views/category/view.html.php b/components/com_content/views/category/view.html.php index 0a0311bf49dd1..ae141003b0857 100644 --- a/components/com_content/views/category/view.html.php +++ b/components/com_content/views/category/view.html.php @@ -73,6 +73,9 @@ public function display($tpl = null) { parent::commonCategoryDisplay(); + // Flag indicates to not add limitstart=0 to URL + $this->pagination->hideEmptyLimitstart = true; + // Prepare the data // Get the metrics for the structural page layout. $params = $this->params; diff --git a/components/com_content/views/featured/view.html.php b/components/com_content/views/featured/view.html.php index ac82b66dba8b8..332b3fe78e2db 100644 --- a/components/com_content/views/featured/view.html.php +++ b/components/com_content/views/featured/view.html.php @@ -55,6 +55,9 @@ public function display($tpl = null) $items = $this->get('Items'); $pagination = $this->get('Pagination'); + // Flag indicates to not add limitstart=0 to URL + $pagination->hideEmptyLimitstart = true; + // Check for errors. if (count($errors = $this->get('Errors'))) { diff --git a/components/com_finder/views/search/view.html.php b/components/com_finder/views/search/view.html.php index 5e59683f6cb86..e4cf9755614b0 100644 --- a/components/com_finder/views/search/view.html.php +++ b/components/com_finder/views/search/view.html.php @@ -93,6 +93,9 @@ public function display($tpl = null) $pagination = $this->get('Pagination'); JDEBUG ? JProfiler::getInstance('Application')->mark('afterFinderPagination') : null; + // Flag indicates to not add limitstart=0 to URL + $pagination->hideEmptyLimitstart = true; + // Check for errors. if (count($errors = $this->get('Errors'))) { diff --git a/components/com_newsfeeds/views/category/view.html.php b/components/com_newsfeeds/views/category/view.html.php index c5299e0f58b3f..043e50ef0c58a 100644 --- a/components/com_newsfeeds/views/category/view.html.php +++ b/components/com_newsfeeds/views/category/view.html.php @@ -47,6 +47,9 @@ public function display($tpl = null) { $this->commonCategoryDisplay(); + // Flag indicates to not add limitstart=0 to URL + $this->pagination->hideEmptyLimitstart = true; + // Prepare the data. // Compute the newsfeed slug. foreach ($this->items as $item) diff --git a/components/com_search/views/search/view.html.php b/components/com_search/views/search/view.html.php index 649017a13d753..854f2a4a3b764 100644 --- a/components/com_search/views/search/view.html.php +++ b/components/com_search/views/search/view.html.php @@ -127,6 +127,9 @@ public function display($tpl = null) $total = $this->get('total'); $pagination = $this->get('pagination'); + // Flag indicates to not add limitstart=0 to URL + $pagination->hideEmptyLimitstart = true; + if ($state->get('match') === 'exact') { $searchWords = array($searchWord); diff --git a/components/com_tags/views/tag/view.html.php b/components/com_tags/views/tag/view.html.php index 6746f7fab1b93..b8af07bb3daf8 100644 --- a/components/com_tags/views/tag/view.html.php +++ b/components/com_tags/views/tag/view.html.php @@ -96,6 +96,9 @@ public function display($tpl = null) $parent = $this->get('Parent'); $pagination = $this->get('Pagination'); + // Flag indicates to not add limitstart=0 to URL + $pagination->hideEmptyLimitstart = true; + /* * // Change to catch * if (count($errors = $this->get('Errors'))) { diff --git a/components/com_tags/views/tags/view.html.php b/components/com_tags/views/tags/view.html.php index 4d89eac1399aa..355b7bcde2c0d 100644 --- a/components/com_tags/views/tags/view.html.php +++ b/components/com_tags/views/tags/view.html.php @@ -46,6 +46,9 @@ public function display($tpl = null) $item = $this->get('Item'); $pagination = $this->get('Pagination'); + // Flag indicates to not add limitstart=0 to URL + $pagination->hideEmptyLimitstart = true; + /* * // Change to catch * if (count($errors = $this->get('Errors'))) { diff --git a/libraries/src/Pagination/Pagination.php b/libraries/src/Pagination/Pagination.php index 568ff4d3e9a16..d317eea26fd16 100644 --- a/libraries/src/Pagination/Pagination.php +++ b/libraries/src/Pagination/Pagination.php @@ -67,6 +67,12 @@ class Pagination */ public $pagesTotal; + /** + * @var boolean The flag indicates whether to add limitstart=0 to URL + * @since __DEPLOY_VERSION__ + */ + public $hideEmptyLimitstart = false; + /** * @var boolean View all flag * @since 3.0 @@ -139,8 +145,8 @@ public function __construct($total, $limitstart, $limit, $prefix = '', CMSApplic // Set the total pages and current page values. if ($this->limit > 0) { - $this->pagesTotal = ceil($this->total / $this->limit); - $this->pagesCurrent = ceil(($this->limitstart + 1) / $this->limit); + $this->pagesTotal = (int) ceil($this->total / $this->limit); + $this->pagesCurrent = (int) ceil(($this->limitstart + 1) / $this->limit); } // Set the pagination iteration loop values. @@ -778,7 +784,15 @@ protected function _buildDataObject() if (!$this->viewall) { $data->all->base = '0'; - $data->all->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart='); + + if ($this->hideEmptyLimitstart) + { + $data->all->link = \JRoute::_($params ?: '&'); + } + else + { + $data->all->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart='); + } } // Set the start and previous data objects. @@ -789,13 +803,26 @@ protected function _buildDataObject() { $page = ($this->pagesCurrent - 2) * $this->limit; - // Set the empty for removal from route - // @todo remove code: $page = $page == 0 ? '' : $page; + if ($this->hideEmptyLimitstart) + { + $data->start->link = \JRoute::_($params ?: '&'); + } + else + { + $data->start->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=0'); + } $data->start->base = '0'; - $data->start->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=0'); $data->previous->base = $page; - $data->previous->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page); + + if ($page === 0 && $this->hideEmptyLimitstart) + { + $data->previous->link = $data->start->link; + } + else + { + $data->previous->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page); + } } // Set the next and end data objects. @@ -825,7 +852,15 @@ protected function _buildDataObject() if ($i != $this->pagesCurrent || $this->viewall) { $data->pages[$i]->base = $offset; - $data->pages[$i]->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset); + + if ($offset === 0 && $this->hideEmptyLimitstart) + { + $data->pages[$i]->link = $data->start->link; + } + else + { + $data->pages[$i]->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset); + } } else { diff --git a/plugins/content/pagebreak/pagebreak.php b/plugins/content/pagebreak/pagebreak.php index 9fe03f0b8ad14..a8244f8945109 100644 --- a/plugins/content/pagebreak/pagebreak.php +++ b/plugins/content/pagebreak/pagebreak.php @@ -172,6 +172,9 @@ public function onContentPrepare($context, &$row, &$params, $page = 0) // Traditional mos page navigation $pageNav = new JPagination($n, $page, 1); + // Flag indicates to not add limitstart=0 to URL + $pageNav->hideEmptyLimitstart = true; + // Page counter. $row->text .= '