add ability to specify the language on the paginator.

This commit is contained in:
Taylor Otwell 2011-11-22 23:40:10 -06:00
parent 16a21422fb
commit dfb3d35f16
1 changed files with 22 additions and 3 deletions

View File

@ -53,6 +53,13 @@ class Paginator {
*/
protected $appendage;
/**
* The language that should be used when creating the pagination links.
*
* @var string
*/
protected $language;
/**
* The "dots" element used in the pagination slider.
*
@ -274,7 +281,7 @@ protected function element($element, $page, $text, $disabled)
{
$class = "{$element}_page";
if (is_null($text)) $text = Lang::line("pagination.{$element}")->get();
if (is_null($text)) $text = Lang::line("pagination.{$element}")->get($this->language);
// Each consumer of this method provides a "disabled" Closure which can
// be used to determine if the element should be a span element or an
@ -348,9 +355,9 @@ protected function range($start, $end)
*/
protected function link($page, $text, $class)
{
$url = URI::current().'?page='.$page.$this->appendage($this->appends);
$query = '?page='.$page.$this->appendage($this->appends);
return HTML::link($url, $text, compact('class'), Request::secure());
return HTML::link(URI::current().$query, $text, compact('class'), Request::secure());
}
/**
@ -385,4 +392,16 @@ public function appends($values)
return $this;
}
/**
* Set the language that should be used when creating the pagination links.
*
* @param string $language
* @return Paginator
*/
public function speaks($language)
{
$this->language = $language;
return $this;
}
}