summaryrefslogtreecommitdiffstats
path: root/system/libraries/Pagination.php
diff options
context:
space:
mode:
authorjekkos <jekkos@users.noreply.github.com>2016-01-18 21:14:06 +0100
committerjekkos <jeroen.peelaerts@gmail.com>2016-01-20 18:30:39 +0100
commit356ad58b61d485570d4f4ca96fefda0d3a9c5d32 (patch)
tree78d9671dd610742dfd5fe48c198c92622f4bb521 /system/libraries/Pagination.php
parente5563f8a1d939666b70b2deac10b0e368f6de2e5 (diff)
Respect $config['cur_page'] variable for pagination
After upgrading to CI3 I noticed that developers are able to determine the current page counter for pagination based on * Explicit query string parameters * URI segment configuration In earlier versions a developer could still set the current page counter in the pagination lib directly which is useful if you want to use pagination with HTTP POST instead of GET. This could be done by passing $config['cur_page'] = '10'; to the pagination function for link generation. Currently this code has changed and will always try to check whether the uri segment is a valid number or not, even if the cur_page variable was passed in the associative array, and fallback to zero if it fails to validate that result. This can be easily resolved by checking whether the counter was already set with a valid number from the $config array before trying to resolve it from the uri segment. This fix give a developer more flexibility and stop CI from overwriting the externally set value with an incorrect one. Signed-off-by: jekkos <jeroen.peelaerts@gmail.com>
Diffstat (limited to 'system/libraries/Pagination.php')
-rw-r--r--system/libraries/Pagination.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index cef98ebf4..9ac9661ad 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -497,7 +497,7 @@ class CI_Pagination {
{
$this->cur_page = $this->CI->input->get($this->query_string_segment);
}
- else
+ elseif (empty($this->cur_page))
{
// Default to the last segment number if one hasn't been defined.
if ($this->uri_segment === 0)
@@ -512,6 +512,10 @@ class CI_Pagination {
{
$this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $this->cur_page);
}
+ }
+ else
+ {
+ $this->cur_page = (string) $this->cur_page;
}
// If something isn't quite right, back to the default base page.