Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '1.3-misc' of dev@code.cakephp.org:cakephp into 1.3-misc

  • Loading branch information...
commit 4a08bd120ddaa101f960db049cf5a5c96b89f860 2 parents 4704a8c + 002a01a
@markstory markstory authored
View
11 cake/libs/view/helpers/paginator.php
@@ -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.
@@ -101,6 +101,15 @@ function __construct($config = array()) {
}
/**
+ * 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
*
* @param string $model Optional model name. Uses the default if none is specified.
View
67 cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -198,7 +198,7 @@ function testSortLinks() {
}
-/**
+/**
* testSortLinksUsingDirectionOption method
*
* @access public
@@ -208,7 +208,7 @@ function testSortLinksUsingDirectionOption(){
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())
@@ -552,6 +552,51 @@ function testOptions() {
}
/**
+ * 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
*
* @access public
@@ -690,8 +735,8 @@ function testPagingLinks() {
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 @@ function testNumbers() {
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 @@ function testNumbers() {
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 @@ function testNumbers() {
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 @@ function testNumbers() {
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 @@ function testNumbers() {
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 @@ function testNumbers() {
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 @@ function testNumbers() {
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(
Please sign in to comment.
Something went wrong with that request. Please try again.