summaryrefslogtreecommitdiffstats
path: root/system/libraries/Pagination.php
diff options
context:
space:
mode:
authorAnton Lindqvist <anton@qvister.se>2012-04-25 12:08:37 +0200
committerAnton Lindqvist <anton@qvister.se>2012-04-25 12:08:37 +0200
commit92f10e837d132f9866626d3f2e0a633b22329ebb (patch)
treee3ade8c7dd46f90690455fb2dcc112d6d015c980 /system/libraries/Pagination.php
parent210e664abe857ddd267a7ba8713e2318d3e59a9c (diff)
parentf8ae11598ba058ee02cc4f8c82dbab3420756aae (diff)
Merge branch 'develop' of https://github.com/EllisLab/CodeIgniter into develop
Conflicts: system/libraries/Cache/Cache.php
Diffstat (limited to 'system/libraries/Pagination.php')
-rw-r--r--system/libraries/Pagination.php46
1 files changed, 18 insertions, 28 deletions
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 35ac541e8..0fe73d69f 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Pagination Class
*
@@ -74,13 +72,12 @@ class CI_Pagination {
/**
* Constructor
*
- * @access public
* @param array initialization parameters
*/
public function __construct($params = array())
{
$this->initialize($params);
- log_message('debug', "Pagination Class Initialized");
+ log_message('debug', 'Pagination Class Initialized');
}
// --------------------------------------------------------------------
@@ -88,7 +85,6 @@ class CI_Pagination {
/**
* Initialize Preferences
*
- * @access public
* @param array initialization parameters
* @return void
*/
@@ -116,7 +112,6 @@ class CI_Pagination {
/**
* Generate the pagination links
*
- * @access public
* @return string
*/
public function create_links()
@@ -155,13 +150,13 @@ class CI_Pagination {
$this->cur_page = (int) $CI->input->get($this->query_string_segment);
}
}
- elseif ( ! $this->cur_page AND $CI->uri->segment($this->uri_segment) != $base_page)
+ elseif ( ! $this->cur_page && $CI->uri->segment($this->uri_segment) != $base_page)
{
$this->cur_page = (int) $CI->uri->segment($this->uri_segment);
}
// 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))
+ if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers && $this->cur_page == 0))
{
$this->cur_page = $base_page;
}
@@ -182,12 +177,9 @@ class CI_Pagination {
$this->cur_page = $num_pages;
}
}
- else
+ elseif ($this->cur_page > $this->total_rows)
{
- if ($this->cur_page > $this->total_rows)
- {
- $this->cur_page = ($num_pages - 1) * $this->per_page;
- }
+ $this->cur_page = ($num_pages - 1) * $this->per_page;
}
$uri_page_number = $this->cur_page;
@@ -199,10 +191,10 @@ class CI_Pagination {
// Calculate the start and end numbers. These determine
// which number to start and end the digit links with
- $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
- $end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
+ $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
+ $end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
- // Is pagination being used over GET or POST? If get, add a per_page query
+ // Is pagination being used over GET or POST? If get, add a per_page query
// string. If post, add a trailing slash to the base URL if needed
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
@@ -217,18 +209,18 @@ class CI_Pagination {
$output = '';
// Render the "First" link
- if ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1))
+ if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1))
{
$first_url = ($this->first_url == '') ? $this->base_url : $this->first_url;
$output .= $this->first_tag_open.'<a '.$this->anchor_class.'href="'.$first_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
}
// Render the "previous" link
- if ($this->prev_link !== FALSE AND $this->cur_page != 1)
+ if ($this->prev_link !== FALSE && $this->cur_page != 1)
{
$i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page;
- if ($i == $base_page AND $this->first_url != '')
+ if ($i == $base_page && $this->first_url != '')
{
$output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
}
@@ -274,7 +266,7 @@ class CI_Pagination {
}
// Render the "next" link
- if ($this->next_link !== FALSE AND $this->cur_page < $num_pages)
+ if ($this->next_link !== FALSE && $this->cur_page < $num_pages)
{
$i = ($this->use_page_numbers) ? $this->cur_page + 1 : $this->cur_page * $this->per_page;
@@ -282,7 +274,7 @@ class CI_Pagination {
}
// Render the "Last" link
- if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages)
+ if ($this->last_link !== FALSE && ($this->cur_page + $this->num_links) < $num_pages)
{
$i = ($this->use_page_numbers) ? $num_pages : ($num_pages * $this->per_page) - $this->per_page;
@@ -291,15 +283,13 @@ class CI_Pagination {
// Kill double slashes. Note: Sometimes we can end up with a double slash
// in the penultimate link so we'll kill all double slashes.
- $output = preg_replace("#([^:])//+#", "\\1/", $output);
+ $output = preg_replace('#([^:])//+#', '\\1/', $output);
// Add the wrapper HTML if exists
- $output = $this->full_tag_open.$output.$this->full_tag_close;
-
- return $output;
+ return $this->full_tag_open.$output.$this->full_tag_close;
}
+
}
-// END Pagination Class
/* End of file Pagination.php */
-/* Location: ./system/libraries/Pagination.php */
+/* Location: ./system/libraries/Pagination.php */ \ No newline at end of file