mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Merge branch '1.3-misc' of dev@code.cakephp.org:cakephp into 1.3-misc
This commit is contained in:
commit
4a08bd120d
2 changed files with 66 additions and 12 deletions
|
@ -77,7 +77,7 @@ class PaginatorHelper extends AppHelper {
|
|||
* Constructor for the helper. Sets up the helper that is used for creating 'AJAX' links.
|
||||
*
|
||||
* Use `var $helpers = array('Paginator' => array('ajax' => 'CustomHelper'));` to set a custom Helper
|
||||
* or choose a non JsHelper Helper. If you want to use a specific library with JsHelper declare JsHelper and its
|
||||
* or choose a non JsHelper Helper. If you want to use a specific library with JsHelper declare JsHelper and its
|
||||
* adapter before including PaginatorHelper in your helpers array.
|
||||
*
|
||||
* The chosen custom helper must implement a `link()` method.
|
||||
|
@ -100,6 +100,15 @@ class PaginatorHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Before render callback. Overridden to merge passed args with url options.
|
||||
*/
|
||||
function beforeRender() {
|
||||
$this->options['url'] = array_merge($this->params['pass'], $this->params['named']);
|
||||
|
||||
parent::beforeRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current paging parameters from the resultset for the given model
|
||||
*
|
||||
|
|
|
@ -198,7 +198,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* testSortLinksUsingDirectionOption method
|
||||
*
|
||||
* @access public
|
||||
|
@ -208,7 +208,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
Router::reload();
|
||||
Router::parse('/');
|
||||
Router::setRequestInfo(array(
|
||||
array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(),
|
||||
array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(),
|
||||
'form' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true'), 'bare' => 0),
|
||||
array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/', 'here' => '/accounts/',
|
||||
'webroot' => '/', 'passedArgs' => array())
|
||||
|
@ -551,6 +551,51 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$this->assertEqual($expected, $this->Paginator->params['paging']);
|
||||
}
|
||||
|
||||
/**
|
||||
* testPassedArgsMergingWithUrlOptions method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testPassedArgsMergingWithUrlOptions() {
|
||||
Router::reload();
|
||||
Router::parse('/');
|
||||
Router::setRequestInfo(array(
|
||||
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['pass'] = array(2);
|
||||
$this->Paginator->params['named'] = array('foo' => 'bar');
|
||||
$this->Paginator->beforeRender();
|
||||
|
||||
$result = $this->Paginator->sort('title');
|
||||
$expected = array(
|
||||
'a' => array('href' => '/articles/index/2/page:1/foo:bar/sort:title/direction:asc'),
|
||||
'Title',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Paginator->numbers();
|
||||
$expected = array(
|
||||
array('span' => array('class' => 'current')), '1', '/span',
|
||||
' | ',
|
||||
array('span' => array()), array('a' => array('href' => '/articles/index/2/page:2/foo:bar')), '2', '/a', '/span',
|
||||
' | ',
|
||||
array('span' => array()), array('a' => array('href' => '/articles/index/2/page:3/foo:bar')), '3', '/a', '/span',
|
||||
' | ',
|
||||
array('span' => array()), array('a' => array('href' => '/articles/index/2/page:4/foo:bar')), '4', '/a', '/span',
|
||||
' | ',
|
||||
array('span' => array()), array('a' => array('href' => '/articles/index/2/page:5/foo:bar')), '5', '/a', '/span',
|
||||
' | ',
|
||||
array('span' => array()), array('a' => array('href' => '/articles/index/2/page:6/foo:bar')), '6', '/a', '/span',
|
||||
' | ',
|
||||
array('span' => array()), array('a' => array('href' => '/articles/index/2/page:7/foo:bar')), '7', '/a', '/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testPagingLinks method
|
||||
*
|
||||
|
@ -690,8 +735,8 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
function testPagingLinksOptionsReplaceEmptyDisabledOptions() {
|
||||
$this->Paginator->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false,
|
||||
'nextPage' => true, 'pageCount' => 5,
|
||||
'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false,
|
||||
'nextPage' => true, 'pageCount' => 5,
|
||||
'defaults' => array(
|
||||
'limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()
|
||||
),
|
||||
|
@ -919,7 +964,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('span' => array()), array('a' => array('href' => '/index/page:15')), 'last', '/a', '/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 1, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
'defaults' => array('limit' => 3, 'step' => 1, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()),
|
||||
|
@ -946,7 +991,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 14, 'current' => 3, 'count' => 30, 'prevPage' => false, 'nextPage' => 2, 'pageCount' => 15,
|
||||
|
@ -1201,7 +1246,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('span' => array()), array('a' => array('href' => '/index/page:4/sort:Client.name/direction:DESC')), '4', '/a', '/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
|
||||
$this->Paginator->params['paging'] = array('Client' => array(
|
||||
'page' => 4895, 'current' => 10, 'count' => 48962, 'prevPage' => 1, 'nextPage' => 1, 'pageCount' => 4897,
|
||||
|
@ -1258,7 +1303,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 5, 'last' => 5, 'separator' => ' - '));
|
||||
$expected = array(
|
||||
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
|
||||
|
@ -1284,7 +1329,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$this->Paginator->params['paging']['Client']['page'] = 4893;
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
|
||||
$expected = array(
|
||||
|
@ -1313,7 +1358,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$this->Paginator->params['paging']['Client']['page'] = 58;
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
|
||||
$expected = array(
|
||||
|
@ -1348,7 +1393,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$this->Paginator->params['paging']['Client']['page'] = 5;
|
||||
$result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
|
||||
$expected = array(
|
||||
|
|
Loading…
Add table
Reference in a new issue