From 10824c72d2a45df84ce96f3398708441c7a55c2f Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 26 Mar 2013 13:38:08 -0700 Subject: [PATCH] Remove alpha sort from pager CRM-12212 --- CRM/Utils/Pager.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/CRM/Utils/Pager.php b/CRM/Utils/Pager.php index c25a719f99..2b8fa81857 100644 --- a/CRM/Utils/Pager.php +++ b/CRM/Utils/Pager.php @@ -274,7 +274,7 @@ class CRM_Utils_Pager extends Pager_Sliding { */ function getPerPageLink($perPage) { if ($perPage != $this->_perPage) { - $href = CRM_Utils_System::makeURL(self::PAGE_ROWCOUNT) . $perPage; + $href = $this->makeURL(self::PAGE_ROWCOUNT, $perPage); $link = sprintf('%s', $href, $this->_classString, @@ -293,7 +293,7 @@ class CRM_Utils_Pager extends Pager_Sliding { return ''; } - $href = CRM_Utils_System::makeURL(self::PAGE_ID) . 1; + $href = $this->makeURL(self::PAGE_ID, 1); return sprintf('%s', $href, str_replace('%d', 1, $this->_altFirst), @@ -306,7 +306,7 @@ class CRM_Utils_Pager extends Pager_Sliding { return ''; } - $href = CRM_Utils_System::makeURL(self::PAGE_ID) . $this->_totalPages; + $href = $this->makeURL(self::PAGE_ID, $this->_totalPages); return sprintf('%s', $href, str_replace('%d', $this->_totalPages, $this->_altLast), @@ -316,7 +316,7 @@ class CRM_Utils_Pager extends Pager_Sliding { function getBackPageLink() { if ($this->_currentPage > 1) { - $href = CRM_Utils_System::makeURL(self::PAGE_ID) . $this->getPreviousPageID(); + $href = $this->makeURL(self::PAGE_ID, $this->getPreviousPageID()); return sprintf('%s', $href, $this->_altPrev, $this->_prevImg @@ -327,7 +327,7 @@ class CRM_Utils_Pager extends Pager_Sliding { function getNextPageLink() { if ($this->_currentPage < $this->_totalPages) { - $href = CRM_Utils_System::makeURL(self::PAGE_ID) . $this->getNextPageID(); + $href = $this->makeURL(self::PAGE_ID, $this->getNextPageID()); return $this->_spacesAfter . sprintf('%s', $href, $this->_altNext, $this->_nextImg @@ -335,5 +335,17 @@ class CRM_Utils_Pager extends Pager_Sliding { } return ''; } + + /** + * Build a url for pager links + */ + function makeURL($key, $value) { + $href = CRM_Utils_System::makeURL($key); + // CRM-12212 Remove alpha sort param + if (strpos($href, '&sortByCharacter=')) { + $href = preg_replace('#(.*)\&sortByCharacter=[^&]*(.*)#', '\1\2', $href); + } + return $href . $value; + } } -- 2.25.1