From a5e13f9bf78e0cf139b905d131075a146430ce0a Mon Sep 17 00:00:00 2001 From: Aaron Kuzemchak Date: Sun, 4 Sep 2011 16:39:47 -0400 Subject: utilizing ternary syntax to clean up some conditionals --- system/libraries/Pagination.php | 46 ++++++----------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) (limited to 'system') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index cdaacf2d4..f190d55fd 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -130,14 +130,7 @@ class CI_Pagination { } // Set the base page index for starting page number - if ($this->use_page_numbers) - { - $base_page = 1; - } - else - { - $base_page = 0; - } + $base_page = ($this->use_page_numbers) ? 1 : 0; // Determine the current page number. $CI =& get_instance(); @@ -234,14 +227,7 @@ class CI_Pagination { // Render the "previous" link if ($this->prev_link !== FALSE AND $this->cur_page != 1) { - if ($this->use_page_numbers) - { - $i = $uri_page_number - 1; - } - else - { - $i = $uri_page_number - $this->per_page; - } + $i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page; if ($i == 0 && $this->first_url != '') { @@ -261,14 +247,7 @@ class CI_Pagination { // Write the digit links for ($loop = $start -1; $loop <= $end; $loop++) { - if ($this->use_page_numbers) - { - $i = $loop; - } - else - { - $i = ($loop * $this->per_page) - $this->per_page; - } + $i = ($this->use_page_numbers) ? $loop : ($loop * $this->per_page) - $this->per_page; if ($i >= $base_page) { @@ -298,14 +277,7 @@ class CI_Pagination { // Render the "next" link if ($this->next_link !== FALSE AND $this->cur_page < $num_pages) { - if ($this->use_page_numbers) - { - $i = $this->cur_page + 1; - } - else - { - $i = ($this->cur_page * $this->per_page); - } + $i = ($this->use_page_numbers) ? $this->cur_page + 1 : $this->cur_page * $this->per_page; $output .= $this->next_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->next_link.''.$this->next_tag_close; } @@ -313,14 +285,8 @@ class CI_Pagination { // Render the "Last" link if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages) { - if ($this->use_page_numbers) - { - $i = $num_pages; - } - else - { - $i = (($num_pages * $this->per_page) - $this->per_page); - } + $i = ($this->use_page_numbers) ? $num_pages : ($num_pages * $this->per_page) - $this->per_page; + $output .= $this->last_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->last_link.''.$this->last_tag_close; } -- cgit v1.2.3-24-g4f1b