Fixing url parameters set with options() or beforeRender not being merged on next() / prev().

Tests added. Fixes #129
This reverses the change made in efa36abdf0 which broke this behavior.
This commit is contained in:
Mark Story 2009-12-22 19:05:06 -05:00
parent c00cebb0c3
commit 1a387e6b8a
2 changed files with 23 additions and 3 deletions

View file

@ -411,10 +411,10 @@ class PaginatorHelper extends AppHelper {
${$key} = $options[$key];
unset($options[$key]);
}
$urlParams = array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step));
$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
if ($this->{$check}($model)) {
return $this->link($title, $urlParams, array_merge($options, compact('escape', 'class', 'url')));
return $this->link($title, $url, array_merge($options, compact('escape', 'class')));
} else {
return $this->Html->tag($tag, $title, array_merge($options, compact('escape', 'class')));
}

View file

@ -585,6 +585,18 @@ class PaginatorHelperTest extends CakeTestCase {
array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'pass' => array('2'), 'named' => array('foo' => 'bar'), 'form' => array(), 'url' => array('url' => 'articles/index/2/foo:bar'), 'bare' => 0),
array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/', 'here' => '/articles/', 'webroot' => '/', 'passedArgs' => array(0 => '2', 'foo' => 'bar'))
));
$this->Paginator->params['paging'] = array(
'Article' => array(
'page' => 1, 'current' => 3, 'count' => 13,
'prevPage' => false, 'nextPage' => true, 'pageCount' => 8,
'defaults' => array(
'limit' => 3, 'step' => 1, 'order' => array(), 'conditions' => array()
),
'options' => array(
'page' => 1, 'limit' => 3, 'order' => array(), 'conditions' => array()
)
)
);
$this->Paginator->params['pass'] = array(2);
$this->Paginator->params['named'] = array('foo' => 'bar');
@ -615,6 +627,14 @@ class PaginatorHelperTest extends CakeTestCase {
array('span' => array()), array('a' => array('href' => '/articles/index/2/page:7/foo:bar')), '7', '/a', '/span',
);
$this->assertTags($result, $expected);
$result = $this->Paginator->next('Next');
$expected = array(
'a' => array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next'),
'Next',
'/a'
);
$this->assertTags($result, $expected);
}
/**
@ -757,7 +777,7 @@ class PaginatorHelperTest extends CakeTestCase {
)
);
$this->Paginator->options(array('url' => array(12, 'page' => 3)));
$result = $this->Paginator->prev('Prev', array('url' => array(12, 'foo' => 'bar')));
$result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar')));
$expected = array(
'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev'),
'Prev',