From 2cdee7aff1a29ace26e1d45f729b899910837044 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 21 Jul 2011 07:20:11 -0700 Subject: [PATCH] Refactoring pagination class. --- system/paginator.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/system/paginator.php b/system/paginator.php index 83cc36a8..9388dcc5 100644 --- a/system/paginator.php +++ b/system/paginator.php @@ -50,6 +50,7 @@ class Paginator { $this->per_page = $per_page; $this->results = $results; $this->total = $total; + $this->page = static::page($this->last_page()); } @@ -136,33 +137,37 @@ class Paginator { /** * Generate the "previous" HTML link. * - * @param string $value + * @param string $language * @return string */ - public function previous($value = '« Previous') + public function previous($language = null) { + $text = Lang::line('pagination.previous')->get($language); + if ($this->page > 1) { - return HTML::link(Request::uri().'?page='.($this->page - 1), $value, array('class' => 'prev_page')).' '; + return HTML::link(Request::uri().'?page='.($this->page - 1), $text, array('class' => 'prev_page')).' '; } - return HTML::span($value, array('class' => 'disabled prev_page')).' '; + return HTML::span($text, array('class' => 'disabled prev_page')).' '; } /** * Generate the "next" HTML link. * - * @param string $value + * @param string $language * @return string */ - public function next($value = 'Next »') + public function next($language = null) { + $text = Lang::line('pagination.next')->get($language); + if ($this->page < $this->last_page()) { - return HTML::link(Request::uri().'?page='.($this->page + 1), $value, array('class' => 'next_page')); + return HTML::link(Request::uri().'?page='.($this->page + 1), $text, array('class' => 'next_page')); } - return HTML::span($value, array('class' => 'disabled next_page')); + return HTML::span($text, array('class' => 'disabled next_page')); } /**