From 1a3885babb73870ef99af24297c722d8251480a1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 2 May 2012 10:23:12 +0300 Subject: Fix pagination anchor_class with multiple initializations --- system/libraries/Pagination.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'system/libraries/Pagination.php') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 0fe73d69f..3d2911813 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -94,17 +94,16 @@ class CI_Pagination { { foreach ($params as $key => $val) { - if (isset($this->$key)) + if ($key === 'anchor_class') + { + $this->anchor_class = ($val != '') ? 'class="'.$val.'" ' : ''; + } + elseif (isset($this->$key)) { $this->$key = $val; } } } - - if ($this->anchor_class != '') - { - $this->anchor_class = 'class="'.$this->anchor_class.'" '; - } } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 5645479c622eb36cf9869797896dc0921568c4a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:32:19 +0300 Subject: Clean up the libraries --- system/libraries/Pagination.php | 1 + 1 file changed, 1 insertion(+) (limited to 'system/libraries/Pagination.php') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 3d2911813..58f86fa17 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -73,6 +73,7 @@ class CI_Pagination { * Constructor * * @param array initialization parameters + * @return void */ public function __construct($params = array()) { -- cgit v1.2.3-24-g4f1b From d261b1e89c3d4d5191036d5a5660ef6764e593a0 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:12:16 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/libraries --- system/libraries/Pagination.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'system/libraries/Pagination.php') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 58f86fa17..a91159c98 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -97,7 +97,7 @@ class CI_Pagination { { if ($key === 'anchor_class') { - $this->anchor_class = ($val != '') ? 'class="'.$val.'" ' : ''; + $this->anchor_class = ($val !== '') ? 'class="'.$val.'" ' : ''; } elseif (isset($this->$key)) { @@ -117,7 +117,7 @@ class CI_Pagination { public function create_links() { // If our item count or per-page total is zero there is no need to continue. - if ($this->total_rows == 0 OR $this->per_page == 0) + if ($this->total_rows === 0 OR $this->per_page === 0) { return ''; } @@ -138,25 +138,25 @@ class CI_Pagination { $CI =& get_instance(); // See if we are using a prefix or suffix on links - if ($this->prefix != '' OR $this->suffix != '') + 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) + if ($CI->input->get($this->query_string_segment) !== $base_page) { $this->cur_page = (int) $CI->input->get($this->query_string_segment); } } - elseif ( ! $this->cur_page && $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 && $this->cur_page == 0)) + if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers && $this->cur_page === 0)) { $this->cur_page = $base_page; } @@ -211,22 +211,22 @@ class CI_Pagination { // Render the "First" link if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1)) { - $first_url = ($this->first_url == '') ? $this->base_url : $this->first_url; + $first_url = ($this->first_url === '') ? $this->base_url : $this->first_url; $output .= $this->first_tag_open.'anchor_class.'href="'.$first_url.'">'.$this->first_link.''.$this->first_tag_close; } // Render the "previous" link - if ($this->prev_link !== FALSE && $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 && $this->first_url != '') + if ($i === $base_page && $this->first_url !== '') { $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.''.$this->prev_tag_close; } else { - $i = ($i == $base_page) ? '' : $this->prefix.$i.$this->suffix; + $i = ($i === $base_page) ? '' : $this->prefix.$i.$this->suffix; $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.''.$this->prev_tag_close; } @@ -242,21 +242,21 @@ class CI_Pagination { if ($i >= $base_page) { - if ($this->cur_page == $loop) + if ($this->cur_page === $loop) { $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page } else { - $n = ($i == $base_page) ? '' : $i; + $n = ($i === $base_page) ? '' : $i; - if ($n == '' && $this->first_url != '') + if ($n === '' && $this->first_url !== '') { $output .= $this->num_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$loop.''.$this->num_tag_close; } else { - $n = ($n == '') ? '' : $this->prefix.$n.$this->suffix; + $n = ($n === '') ? '' : $this->prefix.$n.$this->suffix; $output .= $this->num_tag_open.'anchor_class.'href="'.$this->base_url.$n.'">'.$loop.''.$this->num_tag_close; } -- cgit v1.2.3-24-g4f1b