mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Adding default classes to next and prev links.
Switching next() and prev() to use span by default.
This commit is contained in:
parent
533f6e0d36
commit
38a4b619e6
2 changed files with 35 additions and 34 deletions
|
@ -312,7 +312,10 @@ class PaginatorHelper extends AppHelper {
|
||||||
*/
|
*/
|
||||||
function __pagingLink($which, $title = null, $options = array(), $disabledTitle = null, $disabledOptions = array()) {
|
function __pagingLink($which, $title = null, $options = array(), $disabledTitle = null, $disabledOptions = array()) {
|
||||||
$check = 'has' . $which;
|
$check = 'has' . $which;
|
||||||
$_defaults = array('url' => array(), 'step' => 1, 'escape' => true, 'model' => null, 'tag' => 'div');
|
$_defaults = array(
|
||||||
|
'url' => array(), 'step' => 1, 'escape' => true,
|
||||||
|
'model' => null, 'tag' => 'span', 'class' => strtolower($which)
|
||||||
|
);
|
||||||
$options = array_merge($_defaults, (array)$options);
|
$options = array_merge($_defaults, (array)$options);
|
||||||
$paging = $this->params($options['model']);
|
$paging = $this->params($options['model']);
|
||||||
|
|
||||||
|
@ -332,9 +335,9 @@ class PaginatorHelper extends AppHelper {
|
||||||
$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
|
$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
|
||||||
|
|
||||||
if ($this->{$check}($model)) {
|
if ($this->{$check}($model)) {
|
||||||
return $this->link($title, $url, array_merge($options, array('escape' => $escape)));
|
return $this->link($title, $url, array_merge($options, array('escape' => $escape, 'class' => $class)));
|
||||||
} else {
|
} else {
|
||||||
return $this->Html->tag($tag, $title, $options, $escape);
|
return $this->Html->tag($tag, $title, array_merge($options, array('class' => $class, 'escape' => $escape)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/* SVN FILE: $Id$ */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PaginatorHelperTest file
|
* PaginatorHelperTest file
|
||||||
*
|
*
|
||||||
|
@ -119,7 +117,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
$this->Paginator->params['paging']['Article']['nextPage'] = false;
|
$this->Paginator->params['paging']['Article']['nextPage'] = false;
|
||||||
$this->Paginator->params['paging']['Article']['page'] = 1;
|
$this->Paginator->params['paging']['Article']['page'] = 1;
|
||||||
$result = $this->Paginator->next('Next', array(), true);
|
$result = $this->Paginator->next('Next', array(), true);
|
||||||
$expected = '<div>Next</div>';
|
$expected = '<span class="next">Next</span>';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging']['Article']['prevPage'] = false;
|
$this->Paginator->params['paging']['Article']['prevPage'] = false;
|
||||||
|
@ -344,7 +342,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
$this->Paginator->params['paging']['Article']['page'] = 1;
|
$this->Paginator->params['paging']['Article']['page'] = 1;
|
||||||
$result = $this->Paginator->next('Next');
|
$result = $this->Paginator->next('Next');
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/admin/users/index/page:2'),
|
'a' => array('href' => '/admin/users/index/page:2', 'class' => 'next'),
|
||||||
'Next',
|
'Next',
|
||||||
'/a'
|
'/a'
|
||||||
);
|
);
|
||||||
|
@ -442,7 +440,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Paginator->next('next', array('url' => $options));
|
$result = $this->Paginator->next('next', array('url' => $options));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/members/posts/index/page:3'),
|
'a' => array('href' => '/members/posts/index/page:3', 'class' => 'next'),
|
||||||
'next',
|
'next',
|
||||||
'/a'
|
'/a'
|
||||||
);
|
);
|
||||||
|
@ -450,7 +448,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Paginator->prev('prev', array('url' => $options));
|
$result = $this->Paginator->prev('prev', array('url' => $options));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/members/posts/index/page:1'),
|
'a' => array('href' => '/members/posts/index/page:1', 'class' => 'prev'),
|
||||||
'prev',
|
'prev',
|
||||||
'/a'
|
'/a'
|
||||||
);
|
);
|
||||||
|
@ -528,14 +526,6 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
'options' => array('page' => 1, 'limit' => 3, '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', null, null, array('class' => 'disabled'));
|
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||||
$expected = array(
|
|
||||||
'div' => array('class' => 'disabled'),
|
|
||||||
'<< Previous',
|
|
||||||
'/div'
|
|
||||||
);
|
|
||||||
$this->assertTags($result, $expected);
|
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled', 'tag' => 'span'));
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'span' => array('class' => 'disabled'),
|
'span' => array('class' => 'disabled'),
|
||||||
'<< Previous',
|
'<< Previous',
|
||||||
|
@ -543,11 +533,19 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled', 'tag' => 'div'));
|
||||||
|
$expected = array(
|
||||||
|
'div' => array('class' => 'disabled'),
|
||||||
|
'<< Previous',
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$this->Paginator->params['paging']['Client']['page'] = 2;
|
$this->Paginator->params['paging']['Client']['page'] = 2;
|
||||||
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
||||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/index/page:1'),
|
'a' => array('href' => '/index/page:1', 'class' => 'prev'),
|
||||||
'<< Previous',
|
'<< Previous',
|
||||||
'/a'
|
'/a'
|
||||||
);
|
);
|
||||||
|
@ -555,7 +553,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Paginator->next('Next');
|
$result = $this->Paginator->next('Next');
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/index/page:3'),
|
'a' => array('href' => '/index/page:3', 'class' => 'next'),
|
||||||
'Next',
|
'Next',
|
||||||
'/a'
|
'/a'
|
||||||
);
|
);
|
||||||
|
@ -563,7 +561,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', array('escape' => true));
|
$result = $this->Paginator->prev('<< Previous', array('escape' => true));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/index/page:1'),
|
'a' => array('href' => '/index/page:1', 'class' => 'prev'),
|
||||||
'<< Previous',
|
'<< Previous',
|
||||||
'/a'
|
'/a'
|
||||||
);
|
);
|
||||||
|
@ -571,7 +569,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', array('escape' => false));
|
$result = $this->Paginator->prev('<< Previous', array('escape' => false));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/index/page:1'),
|
'a' => array('href' => '/index/page:1', 'class' => 'prev'),
|
||||||
'preg:/<< Previous/',
|
'preg:/<< Previous/',
|
||||||
'/a'
|
'/a'
|
||||||
);
|
);
|
||||||
|
@ -585,25 +583,25 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>');
|
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>');
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'<div',
|
'span' => array('class' => 'prev'),
|
||||||
'<strong>Disabled</strong>',
|
'<strong>Disabled</strong>',
|
||||||
'/div'
|
'/span'
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => true));
|
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => true));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'<div',
|
'span' => array('class' => 'prev'),
|
||||||
'<strong>Disabled</strong>',
|
'<strong>Disabled</strong>',
|
||||||
'/div'
|
'/span'
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => false));
|
$result = $this->Paginator->prev('<< Previous', null, '<strong>Disabled</strong>', array('escape' => false));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'<div',
|
'span' => array('class' => 'prev'),
|
||||||
'<strong', 'Disabled', '/strong',
|
'<strong', 'Disabled', '/strong',
|
||||||
'/div'
|
'/span'
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
@ -617,7 +615,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
$this->Paginator->params['paging']['Client']['prevPage'] = true;
|
||||||
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC'),
|
'a' => array('href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC', 'class' => 'prev'),
|
||||||
'<< Previous',
|
'<< Previous',
|
||||||
'/a'
|
'/a'
|
||||||
);
|
);
|
||||||
|
@ -625,7 +623,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Paginator->next('Next');
|
$result = $this->Paginator->next('Next');
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC'),
|
'a' => array('href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC', 'class' => 'next'),
|
||||||
'Next',
|
'Next',
|
||||||
'/a'
|
'/a'
|
||||||
);
|
);
|
||||||
|
@ -638,7 +636,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
$result = $this->Paginator->prev('Prev');
|
$result = $this->Paginator->prev('Prev');
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/index/page:1/limit:10'),
|
'a' => array('href' => '/index/page:1/limit:10', 'class' => 'prev'),
|
||||||
'Prev',
|
'Prev',
|
||||||
'/a',
|
'/a',
|
||||||
);
|
);
|
||||||
|
@ -669,13 +667,13 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$result = $this->Paginator->next('Next', array('model' => 'Client'));
|
$result = $this->Paginator->next('Next', array('model' => 'Client'));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/index/page:2'), 'Next', '/a'
|
'a' => array('href' => '/index/page:2', 'class' => 'next'), 'Next', '/a'
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Paginator->next('Next', array('model' => 'Server'), 'No Next', array('model' => 'Server'));
|
$result = $this->Paginator->next('Next', array('model' => 'Server'), 'No Next', array('model' => 'Server'));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'<div', 'No Next', '/div'
|
'span' => array('class' => 'next'), 'No Next', '/span'
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
@ -1607,7 +1605,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Paginator->next('Next');
|
$result = $this->Paginator->next('Next');
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => array('href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc'),
|
'a' => array('href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc', 'class' => 'next'),
|
||||||
'Next',
|
'Next',
|
||||||
'/a'
|
'/a'
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue