Skip to content

Commit

Permalink
Adding automatic use of $options for $disabledOptions in PaginatorHel…
Browse files Browse the repository at this point in the history
…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 01cf40b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cake/libs/view/helpers/paginator.php
Expand Up @@ -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) {
Expand Down
36 changes: 36 additions & 0 deletions cake/tests/cases/libs/view/helpers/paginator.test.php
Expand Up @@ -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
*
Expand Down

0 comments on commit 01cf40b

Please sign in to comment.