summaryrefslogtreecommitdiffstats
path: root/system/libraries/Pagination.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-03-28 13:44:35 +0200
committerAndrey Andreev <narf@bofh.bg>2012-03-28 13:44:35 +0200
commit26c708514e3ca04a1c373efd166b5c17c31e3796 (patch)
tree8c2241630f236733da08770bcbcf9d17461a0f78 /system/libraries/Pagination.php
parented1aa21dcd5312b2884f140be8c0d2ee94379423 (diff)
parent8f50b6b36cb743be8b70809279e501c20b8e38e2 (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop-db-driver
Diffstat (limited to 'system/libraries/Pagination.php')
-rw-r--r--system/libraries/Pagination.php44
1 files changed, 17 insertions, 27 deletions
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 86b8d79fa..0fe73d69f 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -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