summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-12-26 19:04:11 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-12-26 19:04:11 +0100
commit7956765ec33ba78114a24db10644e90dcdb8edac (patch)
tree7fd910bb14c258e3d5de48c22d9705d71600c487 /system
parentefa0895ecc9b60c994a6edc897bf1d724d09e700 (diff)
parent33987e6a318eaf853f626f950573601928547f8f (diff)
Merge pull request #820 from narfbg/develop-pagination
Improve the Pagination library
Diffstat (limited to 'system')
-rw-r--r--system/libraries/Pagination.php30
1 files changed, 8 insertions, 22 deletions
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index eea953ae4..008c15192 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -131,7 +131,7 @@ class CI_Pagination {
$num_pages = ceil($this->total_rows / $this->per_page);
// Is there only one page? Hm... nothing more to do here then.
- if ($num_pages == 1)
+ if ($num_pages === 1)
{
return '';
}
@@ -146,25 +146,16 @@ class CI_Pagination {
{
if ($CI->input->get($this->query_string_segment) != $base_page)
{
- $this->cur_page = $CI->input->get($this->query_string_segment);
-
- // Prep the current page - no funny business!
- $this->cur_page = (int) $this->cur_page;
+ $this->cur_page = (int) $CI->input->get($this->query_string_segment);
}
}
- else
+ elseif ($CI->uri->segment($this->uri_segment) != $base_page)
{
- if ($CI->uri->segment($this->uri_segment) != $base_page)
- {
- $this->cur_page = $CI->uri->segment($this->uri_segment);
-
- // Prep the current page - no funny business!
- $this->cur_page = (int) $this->cur_page;
- }
+ $this->cur_page = (int) $CI->uri->segment($this->uri_segment);
}
- // Set current page to 1 if using page numbers instead of offset
- if ($this->use_page_numbers AND $this->cur_page == 0)
+ // Set current page to 1 if it's not valid or if using page numbers instead of offset
+ if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers AND $this->cur_page == 0))
{
$this->cur_page = $base_page;
}
@@ -176,11 +167,6 @@ class CI_Pagination {
show_error('Your number of links must be a positive number.');
}
- if ( ! is_numeric($this->cur_page))
- {
- $this->cur_page = $base_page;
- }
-
// Is the page number beyond the result range?
// If so we show the last page
if ($this->use_page_numbers)
@@ -310,4 +296,4 @@ class CI_Pagination {
// END Pagination Class
/* End of file Pagination.php */
-/* Location: ./system/libraries/Pagination.php */ \ No newline at end of file
+/* Location: ./system/libraries/Pagination.php */