From e003bd6ea9a74c52b35595cdd859e1546d2e0577 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Dec 2010 10:48:38 -0500 Subject: [PATCH] Adding rel attributes for first and last links. These attribute values are part of the html5 spec, and fit with the intention of #370 --- cake/libs/view/helpers/paginator.php | 8 +++++--- .../libs/view/helpers/paginator.test.php | 20 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index f217d8fae..5966d11c0 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -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 )); diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 671c4f46a..7b600819f 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -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( ' 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( ' 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( ' 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( ' 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( ' 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);