mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #963 from sarce/paginator-tag
prev() and next() methods of PaginatorHelper now possible to place the 'tag' option to 'false' for disable the wrapper.
This commit is contained in:
commit
165035faa8
2 changed files with 39 additions and 3 deletions
|
@ -865,6 +865,14 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Paginator->prev('<< Previous', array('tag' => false), null, array('class' => 'disabled'));
|
||||
$expected = array(
|
||||
'a' => array('href' => '/index/page:1', 'rel' => 'prev', 'class' => 'prev'),
|
||||
'<< Previous',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Paginator->next('Next');
|
||||
$expected = array(
|
||||
'span' => array('class' => 'next'),
|
||||
|
@ -885,6 +893,14 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Paginator->next('Next', array('tag' => false));
|
||||
$expected = array(
|
||||
'a' => array('href' => '/index/page:3', 'rel' => 'next', 'class' => 'next'),
|
||||
'Next',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Paginator->prev('<< Previous', array('escape' => true));
|
||||
$expected = array(
|
||||
'span' => array('class' => 'prev'),
|
||||
|
@ -944,6 +960,14 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Paginator->prev('<< Previous', array('tag' => false), '<strong>Disabled</strong>');
|
||||
$expected = array(
|
||||
'span' => array('class' => 'prev'),
|
||||
'<strong>Disabled</strong>',
|
||||
'/span'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->request->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 1,
|
||||
|
@ -1016,6 +1040,14 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Paginator->next('Next', array(), null, array('tag' => false));
|
||||
$expected = array(
|
||||
'span' => array('class' => 'next'),
|
||||
'Next',
|
||||
'/span'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->request->params['paging'] = array(
|
||||
'Client' => array(
|
||||
'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true,
|
||||
|
|
|
@ -247,7 +247,7 @@ class PaginatorHelper extends AppHelper {
|
|||
*
|
||||
* ### Options:
|
||||
*
|
||||
* - `tag` The tag wrapping tag you want to use, defaults to 'span'
|
||||
* - `tag` The tag wrapping tag you want to use, defaults to 'span'. Set this to false to disable this option
|
||||
* - `escape` Whether you want the contents html entity encoded, defaults to true
|
||||
* - `model` The model to use, defaults to PaginatorHelper::defaultModel()
|
||||
*
|
||||
|
@ -271,7 +271,7 @@ class PaginatorHelper extends AppHelper {
|
|||
*
|
||||
* ### Options:
|
||||
*
|
||||
* - `tag` The tag wrapping tag you want to use, defaults to 'span'
|
||||
* - `tag` The tag wrapping tag you want to use, defaults to 'span'. Set this to false to disable this option
|
||||
* - `escape` Whether you want the contents html entity encoded, defaults to true
|
||||
* - `model` The model to use, defaults to PaginatorHelper::defaultModel()
|
||||
*
|
||||
|
@ -468,12 +468,16 @@ class PaginatorHelper extends AppHelper {
|
|||
${$key} = $options[$key];
|
||||
unset($options[$key]);
|
||||
}
|
||||
$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
|
||||
|
||||
if ($this->{$check}($model)) {
|
||||
$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
|
||||
if ($tag === false) {
|
||||
return $this->link($title, $url, array_merge($options, compact('escape', 'model', 'class')));
|
||||
}
|
||||
return $this->Html->tag($tag, $this->link($title, $url, array_merge($options, compact('escape', 'model'))), compact('class'));
|
||||
} else {
|
||||
unset($options['rel']);
|
||||
$tag = $tag ? $tag : $_defaults['tag'];
|
||||
return $this->Html->tag($tag, $title, array_merge($options, compact('escape', 'class')));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue