Skip to content
Browse files

Merge pull request #4 from weluse/master

Using Routers Match to provide flexible attributes
  • Loading branch information...
2 parents a832865 + b701f0b commit bd7bf6fd0ce58bbeb51f8404f1e6af35aa8c14b1 @nathanwienand committed
Showing with 39 additions and 13 deletions.
  1. +39 −13 extensions/helper/Paginator.php
View
52 extensions/helper/Paginator.php
@@ -165,12 +165,18 @@ public function first(array $options = array()) {
if (!empty($options)) {
$this->config($options);
}
+
if ($this->_page > 1) {
- $url = array(
- 'controller' => $this->_controller,
- 'action' => $this->_action,
+ $config = array(
'page' => 1
);
+
+ $url = \lithium\net\http\Router::match(
+ $config + $this->_context->_config['request']->params,
+ $this->_context->_config['request'],
+ array('absolute' => true)
+ );
+
return $this->_context->html->link($this->_config['firstText'], $url);
}
return $this->_config['firstTextDisabled'];
@@ -187,11 +193,16 @@ public function prev(array $options = array()) {
$this->config($options);
}
if ($this->_page > 1) {
- $url = array(
- 'controller' => $this->_controller,
- 'action' => $this->_action,
+ $config = array(
'page' => ($this->_page - 1)
);
+
+ $url = \lithium\net\http\Router::match(
+ $config + $this->_context->_config['request']->params,
+ $this->_context->_config['request'],
+ array('absolute' => true)
+ );
+
return $this->_context->html->link($this->_config['prevText'], $url);
}
return $this->_config['prevTextDisabled'];
@@ -208,11 +219,16 @@ public function next(array $options = array()) {
$this->config($options);
}
if ($this->_total > ($this->_limit * $this->_page)) {
- $url = array(
- 'controller' => $this->_controller,
- 'action' => $this->_action,
+ $config = array(
'page' => ($this->_page + 1)
);
+
+ $url = \lithium\net\http\Router::match(
+ $config + $this->_context->_config['request']->params,
+ $this->_context->_config['request'],
+ array('absolute' => true)
+ );
+
return $this->_context->html->link($this->_config['nextText'], $url);
}
return $this->_config['nextTextDisabled'];
@@ -230,11 +246,16 @@ public function last(array $options = array()) {
}
$end = floor(($this->_total / $this->_limit) + 1);
if ($end > $this->_page) {
- $url = array(
- 'controller' => $this->_controller,
- 'action' => $this->_action,
+ $config = array(
'page' => $end
);
+
+ $url = \lithium\net\http\Router::match(
+ $config + $this->_context->_config['request']->params,
+ $this->_context->_config['request'],
+ array('absolute' => true)
+ );
+
return $this->_context->html->link($this->_config['lastText'], $url);
}
return $this->_config['lastTextDisabled'];
@@ -264,7 +285,12 @@ public function numbers(array $options = array()) {
'action' => $this->_action
);
for ($i = $start; $i <= $end; $i++) {
- $url['page'] = $i;
+ $config = array('page' => $i);
+ $url = \lithium\net\http\Router::match(
+ $config + $this->_context->_config['request']->params,
+ $this->_context->_config['request'],
+ array('absolute' => true)
+ );
if ($this->_page == $i) {
$buffer .= $this->_config['separator'].$this->_context->html->link($i, $url, array('style' => $this->_config['activePageStyle']));
} else {

0 comments on commit bd7bf6f

Please sign in to comment.
Something went wrong with that request. Please try again.