Merge branch '1.3' of github.com:cakephp/cakephp1x into 1.3

This commit is contained in:
Mark Story 2010-02-07 15:20:00 -05:00
commit 843d3c7095
2 changed files with 64 additions and 22 deletions

View file

@ -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 @@ class PaginatorHelper extends AppHelper {
* 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 @@ class PaginatorHelper extends AppHelper {
$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 @@ class PaginatorHelper extends AppHelper {
*
* - `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 @@ class PaginatorHelper extends AppHelper {
* - `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)

View file

@ -193,7 +193,7 @@ class PaginatorHelperTest extends CakeTestCase {
$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 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->params['paging']['Article']['page'] = 1;
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => array('href' => '/admin/users/index/page:2', 'class' => 'next'),
'Next',
'/a'
'/a',
'/span'
);
$this->assertTags($result, $expected);
@ -497,17 +499,21 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->next('next', array('url' => $options));
$expected = array(
'<span',
'a' => 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(
'<span',
'a' => array('href' => '/members/posts/index/page:1', 'class' => 'prev'),
'prev',
'/a'
'/a',
'/span'
);
$this->assertTags($result, $expected);
@ -587,7 +593,7 @@ class PaginatorHelperTest extends CakeTestCase {
));
$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 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => array('href' => '/articles/index/2/page:2/foo:bar', 'class' => 'next'),
'Next',
'/a'
'/a',
'/span'
);
$this->assertTags($result, $expected);
}
@ -669,33 +677,51 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->params['paging']['Client']['prevPage'] = true;
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
$expected = array(
'<span',
'a' => array('href' => '/index/page:1', 'class' => 'prev'),
'&lt;&lt; Previous',
'/a'
'/a',
'/span'
);
$this->assertTags($result, $expected);
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => 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(
'<li',
'a' => array('href' => '/index/page:3', 'class' => 'next'),
'Next',
'/a',
'/li'
);
$this->assertTags($result, $expected);
$result = $this->Paginator->prev('<< Previous', array('escape' => true));
$expected = array(
'<span',
'a' => array('href' => '/index/page:1', 'class' => 'prev'),
'&lt;&lt; Previous',
'/a'
'/a',
'/span'
);
$this->assertTags($result, $expected);
$result = $this->Paginator->prev('<< Previous', array('escape' => false));
$expected = array(
'<span',
'a' => array('href' => '/index/page:1', 'class' => 'prev'),
'preg:/<< Previous/',
'/a'
'/a',
'/span'
);
$this->assertTags($result, $expected);
@ -739,17 +765,21 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->params['paging']['Client']['prevPage'] = true;
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
$expected = array(
'<span',
'a' => array('href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC', 'class' => 'prev'),
'&lt;&lt; Previous',
'/a'
'/a',
'/span'
);
$this->assertTags($result, $expected, true);
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => 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 @@ class PaginatorHelperTest extends CakeTestCase {
));
$result = $this->Paginator->prev('Prev');
$expected = array(
'<span',
'a' => 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 @@ class PaginatorHelperTest extends CakeTestCase {
$this->Paginator->options(array('url' => array(12, 'page' => 3)));
$result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar')));
$expected = array(
'<span',
'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'class' => 'prev'),
'Prev',
'/a',
'/span'
);
$this->assertTags($result, $expected);
}
@ -815,9 +849,11 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->next('Next >>', array('escape' => false));
$expected = array(
'<span',
'a' => array('href' => '/index/page:2', 'class' => 'next'),
'preg:/Next >>/',
'/a'
'/a',
'/span'
);
$this->assertTags($result, $expected);
}
@ -846,7 +882,11 @@ class PaginatorHelperTest extends CakeTestCase {
);
$result = $this->Paginator->next('Next', array('model' => 'Client'));
$expected = array(
'a' => array('href' => '/index/page:2', 'class' => 'next'), 'Next', '/a'
'<span',
'a' => array('href' => '/index/page:2', 'class' => 'next'),
'Next',
'/a',
'/span'
);
$this->assertTags($result, $expected);
@ -1784,9 +1824,11 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->next('Next');
$expected = array(
'<span',
'a' => array('href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc', 'class' => 'next'),
'Next',
'/a'
'/a',
'/span',
);
$this->assertTags($result, $expected);
}