From 341908d76ce3419cab02f8663fd4c8739c07b0ed Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 22 Jul 2011 11:34:44 -0700 Subject: [PATCH] Added secure and lang methods to paginator. --- system/paginator.php | 47 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/system/paginator.php b/system/paginator.php index 819dbf7e..c1315fa3 100644 --- a/system/paginator.php +++ b/system/paginator.php @@ -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 @@ private function slider($adjacent) */ 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 "$text "; @@ -145,11 +159,11 @@ public function previous() */ 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 "$text"; @@ -190,10 +204,33 @@ private function range($start, $end) for ($i = $start; $i <= $end; $i++) { - $pages .= ($this->page == $i) ? "$i " : HTML::link(Request::uri().'?page='.$i, $i).' '; + $pages .= ($this->page == $i) ? "$i " : 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