summaryrefslogtreecommitdiffstats
path: root/system/libraries/Pagination.php
diff options
context:
space:
mode:
authorTimothy Warren <tim@timshomepage.net>2012-01-24 22:37:20 +0100
committerTimothy Warren <tim@timshomepage.net>2012-01-24 22:37:20 +0100
commit8f9e93dd37ae0090c9b4117138cd3135bfe3f67a (patch)
tree3f49040d696e760381642f2d2ffa407cee1dc039 /system/libraries/Pagination.php
parentde15a0b7377db0ef3b1d43508401be3c2927c0ff (diff)
parent96db8f91c34c18119548cacc4692362f51e70407 (diff)
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into develop
Diffstat (limited to 'system/libraries/Pagination.php')
-rw-r--r--system/libraries/Pagination.php18
1 files changed, 12 insertions, 6 deletions
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 008c15192..35ac541e8 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -18,7 +18,7 @@
*
* @package CodeIgniter
* @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 1.0
@@ -128,7 +128,7 @@ class CI_Pagination {
}
// Calculate the total number of pages
- $num_pages = ceil($this->total_rows / $this->per_page);
+ $num_pages = (int) ceil($this->total_rows / $this->per_page);
// Is there only one page? Hm... nothing more to do here then.
if ($num_pages === 1)
@@ -142,6 +142,12 @@ class CI_Pagination {
// Determine the current page number.
$CI =& get_instance();
+ // See if we are using a prefix or suffix on links
+ if ($this->prefix != '' OR $this->suffix != '')
+ {
+ $this->cur_page = (int) str_replace(array($this->prefix, $this->suffix), '', $CI->uri->segment($this->uri_segment));
+ }
+
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
if ($CI->input->get($this->query_string_segment) != $base_page)
@@ -149,7 +155,7 @@ class CI_Pagination {
$this->cur_page = (int) $CI->input->get($this->query_string_segment);
}
}
- elseif ($CI->uri->segment($this->uri_segment) != $base_page)
+ elseif ( ! $this->cur_page AND $CI->uri->segment($this->uri_segment) != $base_page)
{
$this->cur_page = (int) $CI->uri->segment($this->uri_segment);
}
@@ -160,7 +166,7 @@ class CI_Pagination {
$this->cur_page = $base_page;
}
- $this->num_links = (int)$this->num_links;
+ $this->num_links = (int) $this->num_links;
if ($this->num_links < 1)
{
@@ -222,13 +228,13 @@ class CI_Pagination {
{
$i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page;
- if (($i == 0 OR ($this->use_page_numbers && $i == 1)) AND $this->first_url != '')
+ if ($i == $base_page AND $this->first_url != '')
{
$output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
}
else
{
- $i = ($i == 0) ? '' : $this->prefix.$i.$this->suffix;
+ $i = ($i == $base_page) ? '' : $this->prefix.$i.$this->suffix;
$output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
}