Commit bad119a4 authored by Taylor Otwell's avatar Taylor Otwell

Refactoring paginator... added paginator->append method.

parent aba4eec8
...@@ -44,6 +44,13 @@ class Paginator { ...@@ -44,6 +44,13 @@ class Paginator {
*/ */
public $language; public $language;
/**
* The values that should be appended to the end of the link query strings.
*
* @var array
*/
public $append = array();
/** /**
* Create a new Paginator instance. * Create a new Paginator instance.
* *
...@@ -124,12 +131,7 @@ class Paginator { ...@@ -124,12 +131,7 @@ class Paginator {
{ {
// The hard-coded "7" is to account for all of the constant elements in a sliding range. // The hard-coded "7" is to account for all of the constant elements in a sliding range.
// Namely: The the current page, the two ellipses, the two beginning pages, and the two ending pages. // Namely: The the current page, the two ellipses, the two beginning pages, and the two ending pages.
if ($this->last_page < 7 + ($adjacent * 2)) return ($this->last_page < 7 + ($adjacent * 2)) ? $this->range(1, $this->last_page) : $this->slider($adjacent);
{
return $this->range(1, $this->last_page);
}
return $this->slider($adjacent);
} }
/** /**
...@@ -237,7 +239,14 @@ class Paginator { ...@@ -237,7 +239,14 @@ class Paginator {
*/ */
private function link($page, $text, $class) private function link($page, $text, $class)
{ {
return HTML::link(Request::uri().'?page='.$page, $text, array('class' => $class), Request::is_secure()); $append = '';
foreach ($this->append as $key => $value)
{
$append .= '&'.$key.'='.$value;
}
return HTML::link(Request::uri().'?page='.$page.$append, $text, array('class' => $class), Request::is_secure());
} }
/** /**
...@@ -252,4 +261,16 @@ class Paginator { ...@@ -252,4 +261,16 @@ class Paginator {
return $this; return $this;
} }
/**
* Set the items that should be appended to the link query strings.
*
* @param array $values
* @return Paginator
*/
public function append($values)
{
$this->append = $values;
return $this;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment