From cf192276899087ba85e3a43180deff10d855e959 Mon Sep 17 00:00:00 2001 From: Jerome Date: Mon, 29 Sep 2014 19:22:03 +0200 Subject: [PATCH 1/3] Not generating URLs with "limitstart=0" Instead of removing the "limitstart" parameter in the router file (see https://github.com/joomla/joomla-cms/pull/3725 ), we do not generate URLs with "limitstart=0". Kind of weird to add it there to be then removed in the router, isn't it? So components will be able to use the parameter "limitstart=0" if they want to... and we still avoid the duplicate url issue we used to have. Sounds like a win / win! :) --- libraries/cms/pagination/pagination.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libraries/cms/pagination/pagination.php b/libraries/cms/pagination/pagination.php index 3c8844a1b6219..82cd36b7cb8e6 100644 --- a/libraries/cms/pagination/pagination.php +++ b/libraries/cms/pagination/pagination.php @@ -781,7 +781,7 @@ protected function _buildDataObject() // @todo remove code: $page = $page == 0 ? '' : $page; $data->start->base = '0'; - $data->start->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=0'); + $data->start->link = JRoute::_($params); $data->previous->base = $page; $data->previous->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page); } @@ -813,7 +813,14 @@ 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) + { + $data->pages[$i]->link = JRoute::_($params); + } + else + { + $data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset); + } } else { From efecb9431c49b5fe3103322eeead56f663371714 Mon Sep 17 00:00:00 2001 From: Jerome Date: Mon, 29 Sep 2014 19:33:57 +0200 Subject: [PATCH 2/3] Allow the parameter "limitstart=0" With the patch https://github.com/joomla/joomla-cms/pull/4393 we also modify the router in order to accept this parameter. So components which want to use it for resetting the pagination, still can. --- libraries/cms/router/site.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/cms/router/site.php b/libraries/cms/router/site.php index 21166fddb00b5..2c93555fd0c52 100644 --- a/libraries/cms/router/site.php +++ b/libraries/cms/router/site.php @@ -532,7 +532,8 @@ protected function processParseRules(&$uri) // Process the pagination support if ($this->_mode == JROUTER_MODE_SEF) { - if ($start = $uri->getVar('start')) + $start = (int) $uri->getVar('start', -1) + if ($start >= 0) { $uri->delVar('start'); $vars['limitstart'] = $start; @@ -579,9 +580,9 @@ protected function processBuildRules(&$uri) if ($this->_mode == JROUTER_MODE_SEF && $route) { - $limitstart = (int) $uri->getVar('limitstart'); + $limitstart = (int) $uri->getVar('limitstart', -1); - if ($limitstart > 0) + if ($limitstart >= 0) { $uri->setVar('start', $limitstart); } From 7db31cae892004955b88da1d74271d0694e0add5 Mon Sep 17 00:00:00 2001 From: Jerome Date: Mon, 29 Sep 2014 19:54:33 +0200 Subject: [PATCH 3/3] Update site.php --- libraries/cms/router/site.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/cms/router/site.php b/libraries/cms/router/site.php index 2c93555fd0c52..95fe49068827a 100644 --- a/libraries/cms/router/site.php +++ b/libraries/cms/router/site.php @@ -532,7 +532,7 @@ protected function processParseRules(&$uri) // Process the pagination support if ($this->_mode == JROUTER_MODE_SEF) { - $start = (int) $uri->getVar('start', -1) + $start = (int) $uri->getVar('start', -1); if ($start >= 0) { $uri->delVar('start');