Commit 341908d7 authored by Taylor Otwell's avatar Taylor Otwell

Added secure and lang methods to paginator.

parent 36d9fe0b
......@@ -37,6 +37,20 @@ class Paginator {
*/
public $last_page;
/**
* The language that should be used when generating page links.
*
* @var string
*/
public $language;
/**
* Indicates if HTTPS links should be generated.
*
* @var bool
*/
public $https = false;
/**
* Create a new Paginator instance.
*
......@@ -128,11 +142,11 @@ class Paginator {
*/
public function previous()
{
$text = Lang::line('pagination.previous')->get();
$text = Lang::line('pagination.previous')->get($this->language);
if ($this->page > 1)
{
return HTML::link(Request::uri().'?page='.($this->page - 1), $text, array('class' => 'prev_page')).' ';
return HTML::link(Request::uri().'?page='.($this->page - 1), $text, array('class' => 'prev_page'), $this->https).' ';
}
return "<span class=\"disabled prev_page\">$text</span> ";
......@@ -145,11 +159,11 @@ class Paginator {
*/
public function next()
{
$text = Lang::line('pagination.next')->get();
$text = Lang::line('pagination.next')->get($this->language);
if ($this->page < $this->last_page)
{
return HTML::link(Request::uri().'?page='.($this->page + 1), $text, array('class' => 'next_page'));
return HTML::link(Request::uri().'?page='.($this->page + 1), $text, array('class' => 'next_page'), $this->https);
}
return "<span class=\"disabled next_page\">$text</span>";
......@@ -190,10 +204,33 @@ class Paginator {
for ($i = $start; $i <= $end; $i++)
{
$pages .= ($this->page == $i) ? "<span class=\"current\">$i</span> " : HTML::link(Request::uri().'?page='.$i, $i).' ';
$pages .= ($this->page == $i) ? "<span class=\"current\">$i</span> " : HTML::link(Request::uri().'?page='.$i, $i, array(), $this->https).' ';
}
return $pages;
}
/**
* Set the language that should be used when generating pagination links.
*
* @param string $language
* @return Paginator
*/
public function lang($language)
{
$this->language = $language;
return $this;
}
/**
* Force the pagination links to use HTTPS.
*
* @return Paginator
*/
public function secure()
{
$this->https = true;
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