Skip to content

Commit

Permalink
Edit Router::match for generate url
Browse files Browse the repository at this point in the history
  • Loading branch information
Nys Standop committed May 31, 2011
1 parent 97034b0 commit 2077299
Showing 1 changed file with 41 additions and 15 deletions.
56 changes: 41 additions & 15 deletions extensions/helper/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,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'];
Expand All @@ -181,12 +187,17 @@ public function prev(array $options = array()) {
if (!empty($options)) {
$this->config($options);
}
if ($this->_page > 1) {
$url = array(
'controller' => $this->_controller,
'action' => $this->_action,
if ($this->_page > 1) {
$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'];
Expand All @@ -203,11 +214,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'];
Expand All @@ -224,12 +240,17 @@ public function last(array $options = array()) {
$this->config($options);
}
$end = floor(($this->_total / $this->_limit) + 1);
if ($end > $this->_page) {
$url = array(
'controller' => $this->_controller,
'action' => $this->_action,
if ($end > $this->_page) {
$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'];
Expand Down Expand Up @@ -259,7 +280,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 {
Expand Down

0 comments on commit 2077299

Please sign in to comment.