diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index 6be7d57d6f6..870c942237f 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -67,7 +67,7 @@ class PaginatorHelper extends AppHelper { * - `$options['escape']` Defines if the title field for the link should be escaped (default: true). * - `$options['update']` DOM id of the element updated with the results of the AJAX call. * If this key isn't specified Paginator will use plain HTML links. - * - `$options['indicator']` DOM id of the element that will be shown when doing AJAX requests. **Only supported by + * - `$options['indicator']` DOM id of the element that will be shown when doing AJAX requests. **Only supported by * AjaxHelper** * * @var array @@ -368,7 +368,7 @@ function link($title, $url = array(), $options = array()) { * Merges passed URL options with current pagination state to generate a pagination URL. * * @param array $options Pagination/URL options array - * @param boolean $asArray Return the url as an array, or a URI string + * @param boolean $asArray Return the url as an array, or a URI string * @param string $model Which model to paginate on * @return mixed By default, returns a full pagination URL string for use in non-standard contexts (i.e. JavaScript) * @access public @@ -427,7 +427,7 @@ function __pagingLink($which, $title = null, $options = array(), $disabledTitle $url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url); if ($this->{$check}($model)) { - return $this->link($title, $url, array_merge($options, compact('escape', 'class'))); + return $this->Html->tag($tag, $this->link($title, $url, array_merge($options, compact('escape', 'class')))); } else { return $this->Html->tag($tag, $title, array_merge($options, compact('escape', 'class'))); } @@ -514,7 +514,7 @@ function defaultModel() { * * - `model` The model to use, defaults to PaginatorHelper::defaultModel(); * - `format` The format string you want to use, defaults to 'pages' Which generates output like '1 of 5' - * set to 'range' to generate output like '1 - 3 of 13'. Can also be set to a custom string, containing + * set to 'range' to generate output like '1 - 3 of 13'. Can also be set to a custom string, containing * the following placeholders `%page%`, `%pages%`, `%current%`, `%count%`, `%start%`, `%end%` and any * custom content you would like. * - `separator` The separator string to use, default to ' of ' @@ -592,9 +592,9 @@ function counter($options = array()) { * - `modulus` how many numbers to include on either side of the current page, defaults to 8. * - `separator` Separator content defaults to ' | ' * - `tag` The tag to wrap links in, defaults to 'span' - * - `first` Whether you want first links generated, set to an integer to define the number of 'first' + * - `first` Whether you want first links generated, set to an integer to define the number of 'first' * links to generate - * - `last` Whether you want last links generated, set to an integer to define the number of 'last' + * - `last` Whether you want last links generated, set to an integer to define the number of 'last' * links to generate * * @param mixed $options Options for the numbers, (before, after, model, modulus, separator) diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 87d1c5f0336..9333c4e899e 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -193,7 +193,7 @@ function testSortLinks() { $this->Paginator->params['paging']['Article']['options']['sort'] = null; $result = $this->Paginator->sort('title'); $this->assertPattern('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result); - + $this->Paginator->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc'); $this->Paginator->params['paging']['Article']['options']['sort'] = null; $result = $this->Paginator->sort('Title', 'title', array('direction' => 'desc')); @@ -396,9 +396,11 @@ function testSortAdminLinks() { $this->Paginator->params['paging']['Article']['page'] = 1; $result = $this->Paginator->next('Next'); $expected = array( + ' array('href' => '/admin/users/index/page:2', 'class' => 'next'), 'Next', - '/a' + '/a', + '/span' ); $this->assertTags($result, $expected); @@ -497,17 +499,21 @@ function testUrlGenerationWithPrefixes() { $result = $this->Paginator->next('next', array('url' => $options)); $expected = array( + ' array('href' => '/members/posts/index/page:3', 'class' => 'next'), 'next', - '/a' + '/a', + '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('prev', array('url' => $options)); $expected = array( + ' array('href' => '/members/posts/index/page:1', 'class' => 'prev'), 'prev', - '/a' + '/a', + '/span' ); $this->assertTags($result, $expected); @@ -587,7 +593,7 @@ function testPassedArgsMergingWithUrlOptions() { )); $this->Paginator->params['paging'] = array( 'Article' => array( - 'page' => 1, 'current' => 3, 'count' => 13, + 'page' => 1, 'current' => 3, 'count' => 13, 'prevPage' => false, 'nextPage' => true, 'pageCount' => 8, 'defaults' => array( 'limit' => 3, 'step' => 1, 'order' => array(), 'conditions' => array() @@ -630,9 +636,11 @@ function testPassedArgsMergingWithUrlOptions() { $result = $this->Paginator->next('Next'); $expected = array( + ' array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next'), 'Next', - '/a' + '/a', + '/span' ); $this->assertTags($result, $expected); } @@ -669,33 +677,51 @@ function testPagingLinks() { $this->Paginator->params['paging']['Client']['prevPage'] = true; $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( + ' array('href' => '/index/page:1', 'class' => 'prev'), '<< Previous', - '/a' + '/a', + '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->next('Next'); $expected = array( + ' array('href' => '/index/page:3', 'class' => 'next'), 'Next', - '/a' + '/a', + '/span' + ); + $this->assertTags($result, $expected); + + $result = $this->Paginator->next('Next', array('tag' => 'li')); + $expected = array( + ' array('href' => '/index/page:3', 'class' => 'next'), + 'Next', + '/a', + '/li' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('<< Previous', array('escape' => true)); $expected = array( + ' array('href' => '/index/page:1', 'class' => 'prev'), '<< Previous', - '/a' + '/a', + '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('<< Previous', array('escape' => false)); $expected = array( + ' array('href' => '/index/page:1', 'class' => 'prev'), 'preg:/<< Previous/', - '/a' + '/a', + '/span' ); $this->assertTags($result, $expected); @@ -739,17 +765,21 @@ function testPagingLinks() { $this->Paginator->params['paging']['Client']['prevPage'] = true; $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( + ' array('href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC', 'class' => 'prev'), '<< Previous', - '/a' + '/a', + '/span' ); $this->assertTags($result, $expected, true); $result = $this->Paginator->next('Next'); $expected = array( + ' array('href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC', 'class' => 'next'), 'Next', - '/a' + '/a', + '/span' ); $this->assertTags($result, $expected); @@ -760,15 +790,17 @@ function testPagingLinks() { )); $result = $this->Paginator->prev('Prev'); $expected = array( + ' array('href' => '/index/page:1/limit:10', 'class' => 'prev'), 'Prev', '/a', + '/span' ); $this->assertTags($result, $expected); $this->Paginator->params['paging'] = array( 'Client' => array( - 'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true, + 'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true, 'nextPage' => false, 'pageCount' => 2, 'defaults' => array(), 'options' => array( @@ -779,9 +811,11 @@ function testPagingLinks() { $this->Paginator->options(array('url' => array(12, 'page' => 3))); $result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar'))); $expected = array( + ' array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev'), 'Prev', '/a', + '/span' ); $this->assertTags($result, $expected); } @@ -815,9 +849,11 @@ function testPagingLinksOptionsReplaceEmptyDisabledOptions() { $result = $this->Paginator->next('Next >>', array('escape' => false)); $expected = array( + ' array('href' => '/index/page:2', 'class' => 'next'), 'preg:/Next >>/', - '/a' + '/a', + '/span' ); $this->assertTags($result, $expected); } @@ -846,7 +882,11 @@ function testPagingLinksNotDefaultModel() { ); $result = $this->Paginator->next('Next', array('model' => 'Client')); $expected = array( - 'a' => array('href' => '/index/page:2', 'class' => 'next'), 'Next', '/a' + ' array('href' => '/index/page:2', 'class' => 'next'), + 'Next', + '/a', + '/span' ); $this->assertTags($result, $expected); @@ -1784,9 +1824,11 @@ function testNextLinkUsingDotNotation() { $result = $this->Paginator->next('Next'); $expected = array( + ' array('href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc', 'class' => 'next'), 'Next', - '/a' + '/a', + '/span', ); $this->assertTags($result, $expected); }