Permalink
Browse files

Adding automatic use of $options for $disabledOptions in PaginatorHel…

…per::next() and PaginatorHelper::prev(). Thanks to 'joaquin_win' for the initial patch. Refs #83
  • Loading branch information...
markstory committed Sep 15, 2009
1 parent a499c98 commit 01cf40bf12403af5a2750912e2ddccb232f592bb
Showing with 39 additions and 0 deletions.
  1. +3 −0 cake/libs/view/helpers/paginator.php
  2. +36 −0 cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -327,6 +327,9 @@ function __pagingLink($which, $title = null, $options = array(), $disabledTitle
);
$options = array_merge($_defaults, (array)$options);
$paging = $this->params($options['model']);
+ if (empty($disabledOptions)) {
+ $disabledOptions = $options;
+ }
if (!$this->{$check}($options['model']) && (!empty($disabledTitle) || !empty($disabledOptions))) {
if (!empty($disabledTitle) && $disabledTitle !== true) {
@@ -678,6 +678,42 @@ function testPagingLinks() {
$this->assertTags($result, $expected);
}
+/**
+ * test that __pagingLink methods use $options when $disabledOptions is an empty value.
+ * allowing you to use shortcut syntax
+ *
+ * @return void
+ **/
+ function testPagingLinksOptionsReplaceEmptyDisabledOptions() {
+ $this->Paginator->params['paging'] = array(
+ 'Client' => array(
+ '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()
+ ),
+ 'options' => array(
+ 'page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array()
+ )
+ )
+ );
+ $result = $this->Paginator->prev('<< Previous', array('escape' => false));
+ $expected = array(
+ 'span' => array('class' => 'prev'),
+ 'preg:/<< Previous/',
+ '/span'
+ );
+ $this->assertTags($result, $expected);
+
+ $result = $this->Paginator->next('Next >>', array('escape' => false));
+ $expected = array(
+ 'a' => array('href' => '/index/page:2', 'class' => 'next'),
+ 'preg:/Next >>/',
+ '/a'
+ );
+ $this->assertTags($result, $expected);
+ }
+
/**
* testPagingLinksNotDefaultModel
*

0 comments on commit 01cf40b

Please sign in to comment.