summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Sowell <robin.sowell@ellislab.com>2010-05-24 18:20:03 +0200
committerRobin Sowell <robin.sowell@ellislab.com>2010-05-24 18:20:03 +0200
commit2a6c1da49b38abb8767192a064b8c6b01d1e421e (patch)
tree003698ac67da531534728931c057ad2acf475806
parent23e796f7561832a929c1a78c1fb60667563b0756 (diff)
Added $prefix, $suffix and $first_url properties to Pagination library.
-rw-r--r--system/libraries/Pagination.php36
-rw-r--r--user_guide/changelog.html1
2 files changed, 31 insertions, 6 deletions
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index d6321f41c..ccd3e8261 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -27,6 +27,9 @@
class CI_Pagination {
var $base_url = ''; // The page we are linking to
+ var $prefix = ''; // A custom prefix added to the path.
+ var $suffix = ''; // A custom suffix added to the path.
+
var $total_rows = ''; // Total number of items (database results)
var $per_page = 10; // Max number of items you want shown per page
var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page
@@ -42,6 +45,7 @@ class CI_Pagination {
var $first_tag_close = '&nbsp;';
var $last_tag_open = '&nbsp;';
var $last_tag_close = '';
+ var $first_url = ''; // Alternative URL for the First Page.
var $cur_tag_open = '&nbsp;<strong>';
var $cur_tag_close = '</strong>';
var $next_tag_open = '&nbsp;';
@@ -185,15 +189,25 @@ class CI_Pagination {
// Render the "First" link
if ($this->cur_page > ($this->num_links + 1))
{
- $output .= $this->first_tag_open.'<a href="'.$this->base_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
+ $first_url = ($this->first_url == '') ? $this->base_url : $this->first_url;
+ $output .= $this->first_tag_open.'<a href="'.$first_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
}
// Render the "previous" link
if ($this->cur_page != 1)
{
$i = $uri_page_number - $this->per_page;
- if ($i == 0) $i = '';
- $output .= $this->prev_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
+
+ if ($i == 0 && $this->first_url != '')
+ {
+ $output .= $this->prev_tag_open.'<a href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
+ }
+ else
+ {
+ $i = ($i == 0) ? '' : $this->prefix.$i.$this->suffix;
+ $output .= $this->prev_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
+ }
+
}
// Write the digit links
@@ -210,7 +224,17 @@ class CI_Pagination {
else
{
$n = ($i == 0) ? '' : $i;
- $output .= $this->num_tag_open.'<a href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close;
+
+ if ($n == '' && $this->first_url != '')
+ {
+ $output .= $this->num_tag_open.'<a href="'.$this->first_url.'">'.$loop.'</a>'.$this->num_tag_close;
+ }
+ else
+ {
+ $n = ($n == '') ? '' : $this->prefix.$n.$this->suffix;
+
+ $output .= $this->num_tag_open.'<a href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close;
+ }
}
}
}
@@ -218,14 +242,14 @@ class CI_Pagination {
// Render the "next" link
if ($this->cur_page < $num_pages)
{
- $output .= $this->next_tag_open.'<a href="'.$this->base_url.($this->cur_page * $this->per_page).'">'.$this->next_link.'</a>'.$this->next_tag_close;
+ $output .= $this->next_tag_open.'<a href="'.$this->base_url.$this->prefix.($this->cur_page * $this->per_page).$this->suffix.'">'.$this->next_link.'</a>'.$this->next_tag_close;
}
// Render the "Last" link
if (($this->cur_page + $this->num_links) < $num_pages)
{
$i = (($num_pages * $this->per_page) - $this->per_page);
- $output .= $this->last_tag_open.'<a href="'.$this->base_url.$i.'">'.$this->last_link.'</a>'.$this->last_tag_close;
+ $output .= $this->last_tag_open.'<a href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->last_link.'</a>'.$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 08c98157b..1aa06d388 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -78,6 +78,7 @@ Hg Tag: </p>
</ul>
<li>Libraries
<ul>
+ <li>Added <var>$prefix</var>, <var>$suffix</var> and <var>$first_url</var> properties to Pagination library.</li>
<li>Added <a href="./libraries/security.html">Security library</a>, which now contains the <dfn>xss_clean</dfn> function, <dfn>filename_security</dfn> function and other security related functions.</li>
<li>Added CSRF (Cross-site Reference Forgery) protection to the <a href="./libraries/security.html">Security library</a>.</li>
<li>Added <var>$parse_exec_vars</var> property to Output library.</li>