From 96bb75cd4e9b1cbd82fe7496e9b831054c8228f1 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Mon, 5 Jul 2010 10:54:30 -0400 Subject: Added the ability to suppress first, previous, next and last links by setting their values to FALSE in the pagination library. --- system/libraries/Pagination.php | 28 +++++++++++++++++----------- user_guide/changelog.html | 3 ++- user_guide/libraries/pagination.html | 12 +++++++----- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index ccd3e8261..68c35a57e 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -56,6 +56,7 @@ class CI_Pagination { var $num_tag_close = ''; var $page_query_string = FALSE; var $query_string_segment = 'per_page'; + var $anchor_class = ''; /** * Constructor @@ -70,6 +71,11 @@ class CI_Pagination { $this->initialize($params); } + if ($this->anchor_class != '') + { + $this->anchor_class = 'class="'.$this->anchor_class.'" '; + } + log_message('debug', "Pagination Class Initialized"); } @@ -187,25 +193,25 @@ class CI_Pagination { $output = ''; // Render the "First" link - if ($this->cur_page > ($this->num_links + 1)) + if ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1)) { $first_url = ($this->first_url == '') ? $this->base_url : $this->first_url; - $output .= $this->first_tag_open.''.$this->first_link.''.$this->first_tag_close; + $output .= $this->first_tag_open.'anchor_class.'href="'.$first_url.'">'.$this->first_link.''.$this->first_tag_close; } // Render the "previous" link - if ($this->cur_page != 1) + if ($this->prev_link !== FALSE AND $this->cur_page != 1) { $i = $uri_page_number - $this->per_page; if ($i == 0 && $this->first_url != '') { - $output .= $this->prev_tag_open.''.$this->prev_link.''.$this->prev_tag_close; + $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.''.$this->prev_tag_close; } else { $i = ($i == 0) ? '' : $this->prefix.$i.$this->suffix; - $output .= $this->prev_tag_open.''.$this->prev_link.''.$this->prev_tag_close; + $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.''.$this->prev_tag_close; } } @@ -227,29 +233,29 @@ class CI_Pagination { if ($n == '' && $this->first_url != '') { - $output .= $this->num_tag_open.''.$loop.''.$this->num_tag_close; + $output .= $this->num_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$loop.''.$this->num_tag_close; } else { $n = ($n == '') ? '' : $this->prefix.$n.$this->suffix; - $output .= $this->num_tag_open.''.$loop.''.$this->num_tag_close; + $output .= $this->num_tag_open.'anchor_class.'href="'.$this->base_url.$n.'">'.$loop.''.$this->num_tag_close; } } } } // Render the "next" link - if ($this->cur_page < $num_pages) + if ($this->next_link !== FALSE AND $this->cur_page < $num_pages) { - $output .= $this->next_tag_open.''.$this->next_link.''.$this->next_tag_close; + $output .= $this->next_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.($this->cur_page * $this->per_page).$this->suffix.'">'.$this->next_link.''.$this->next_tag_close; } // Render the "Last" link - if (($this->cur_page + $this->num_links) < $num_pages) + if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages) { $i = (($num_pages * $this->per_page) - $this->per_page); - $output .= $this->last_tag_open.''.$this->last_link.''.$this->last_tag_close; + $output .= $this->last_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->last_link.''.$this->last_tag_close; } // Kill double slashes. Note: Sometimes we can end up with a double slash diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 124a1cb9f..4f86c1e94 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -78,7 +78,8 @@ Hg Tag:

  • Libraries