mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
Adding rel attributes for first and last links. These attribute values are part of the html5 spec, and fit with the intention of #370
This commit is contained in:
parent
fd88d57513
commit
e003bd6ea9
2 changed files with 18 additions and 10 deletions
|
@ -743,14 +743,14 @@ class PaginatorHelper extends AppHelper {
|
|||
$options = array_merge(
|
||||
array(
|
||||
'tag' => 'span',
|
||||
'after'=> null,
|
||||
'after' => null,
|
||||
'model' => $this->defaultModel(),
|
||||
'separator' => ' | ',
|
||||
'ellipsis' => '...',
|
||||
'ellipsis' => '...'
|
||||
),
|
||||
(array)$options);
|
||||
|
||||
$params = array_merge(array('page'=> 1), (array)$this->params($options['model']));
|
||||
$params = array_merge(array('page' => 1), (array)$this->params($options['model']));
|
||||
unset($options['model']);
|
||||
|
||||
if ($params['pageCount'] <= 1) {
|
||||
|
@ -773,6 +773,7 @@ class PaginatorHelper extends AppHelper {
|
|||
}
|
||||
$out .= $after;
|
||||
} elseif ($params['page'] > 1) {
|
||||
$options += array('rel' => 'first');
|
||||
$out = $this->Html->tag($tag, $this->link($first, array('page' => 1), $options))
|
||||
. $after;
|
||||
}
|
||||
|
@ -830,6 +831,7 @@ class PaginatorHelper extends AppHelper {
|
|||
}
|
||||
$out = $before . $out;
|
||||
} elseif ($params['page'] < $params['pageCount']) {
|
||||
$options += array('rel' => 'last');
|
||||
$out = $before . $this->Html->tag(
|
||||
$tag, $this->link($last, array('page' => $params['pageCount']), $options
|
||||
));
|
||||
|
|
|
@ -1179,7 +1179,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Paginator->numbers(true);
|
||||
$expected = array(
|
||||
array('span' => array()), array('a' => array('href' => '/index/page:1')), 'first', '/a', '/span',
|
||||
array('span' => array()), array('a' => array('href' => '/index/page:1', 'rel' => 'first')), 'first', '/a', '/span',
|
||||
' | ',
|
||||
array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
|
||||
' | ',
|
||||
|
@ -1199,7 +1199,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
' | ',
|
||||
array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
|
||||
' | ',
|
||||
array('span' => array()), array('a' => array('href' => '/index/page:15')), 'last', '/a', '/span',
|
||||
array('span' => array()), array('a' => array('href' => '/index/page:15', 'rel' => 'last')), 'last', '/a', '/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
@ -1779,7 +1779,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->first('<<', array('tag' => 'li'));
|
||||
$expected = array(
|
||||
'<li',
|
||||
'a' => array('href' => '/index/page:1'),
|
||||
'a' => array('href' => '/index/page:1', 'rel' => 'first'),
|
||||
'<<',
|
||||
'/a',
|
||||
'/li'
|
||||
|
@ -1841,7 +1841,9 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->first();
|
||||
$expected = array(
|
||||
'<span',
|
||||
array('a' => array('href' => FULL_BASE_URL . '/index/page:1/sort:Article.title/direction:DESC')),
|
||||
array('a' => array(
|
||||
'href' => FULL_BASE_URL . '/index/page:1/sort:Article.title/direction:DESC', 'rel' => 'first'
|
||||
)),
|
||||
'<< first',
|
||||
'/a',
|
||||
'/span',
|
||||
|
@ -1858,7 +1860,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->first();
|
||||
$expected = array(
|
||||
'<span',
|
||||
'a' => array('href' => '/index/page:1'),
|
||||
'a' => array('href' => '/index/page:1', 'rel' => 'first'),
|
||||
'<< first',
|
||||
'/a',
|
||||
'/span'
|
||||
|
@ -1888,7 +1890,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->last();
|
||||
$expected = array(
|
||||
'<span',
|
||||
'a' => array('href' => '/index/page:7'),
|
||||
'a' => array('href' => '/index/page:7', 'rel' => 'last'),
|
||||
'last >>',
|
||||
'/a',
|
||||
'/span'
|
||||
|
@ -1947,7 +1949,11 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->last();
|
||||
$expected = array(
|
||||
'<span',
|
||||
array('a' => array('href' => '/index/page:15/sort:Client.name/direction:DESC')), 'last >>', '/a',
|
||||
array('a' => array(
|
||||
'href' => '/index/page:15/sort:Client.name/direction:DESC',
|
||||
'rel' => 'last'
|
||||
)),
|
||||
'last >>', '/a',
|
||||
'/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
|
Loading…
Add table
Reference in a new issue