diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index fae687ae6..6eb646d29 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -312,7 +312,10 @@ class PaginatorHelper extends AppHelper { */ function __pagingLink($which, $title = null, $options = array(), $disabledTitle = null, $disabledOptions = array()) { $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); $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); 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 { - return $this->Html->tag($tag, $title, $options, $escape); + return $this->Html->tag($tag, $title, array_merge($options, array('class' => $class, 'escape' => $escape))); } } diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 66904a2b1..772f138dc 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -1,6 +1,4 @@ Paginator->params['paging']['Article']['nextPage'] = false; $this->Paginator->params['paging']['Article']['page'] = 1; $result = $this->Paginator->next('Next', array(), true); - $expected = '
Next
'; + $expected = 'Next'; $this->assertEqual($result, $expected); $this->Paginator->params['paging']['Article']['prevPage'] = false; @@ -344,7 +342,7 @@ class PaginatorHelperTest extends CakeTestCase { $this->Paginator->params['paging']['Article']['page'] = 1; $result = $this->Paginator->next('Next'); $expected = array( - 'a' => array('href' => '/admin/users/index/page:2'), + 'a' => array('href' => '/admin/users/index/page:2', 'class' => 'next'), 'Next', '/a' ); @@ -442,7 +440,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('next', array('url' => $options)); $expected = array( - 'a' => array('href' => '/members/posts/index/page:3'), + 'a' => array('href' => '/members/posts/index/page:3', 'class' => 'next'), 'next', '/a' ); @@ -450,7 +448,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('prev', array('url' => $options)); $expected = array( - 'a' => array('href' => '/members/posts/index/page:1'), + 'a' => array('href' => '/members/posts/index/page:1', 'class' => 'prev'), 'prev', '/a' ); @@ -528,14 +526,6 @@ class PaginatorHelperTest extends CakeTestCase { 'options' => array('page' => 1, 'limit' => 3, 'order' => array('Client.name' => 'DESC'), 'conditions' => array())) ); $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( 'span' => array('class' => 'disabled'), '<< Previous', @@ -543,11 +533,19 @@ class PaginatorHelperTest extends CakeTestCase { ); $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']['prevPage'] = true; $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = array( - 'a' => array('href' => '/index/page:1'), + 'a' => array('href' => '/index/page:1', 'class' => 'prev'), '<< Previous', '/a' ); @@ -555,7 +553,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next'); $expected = array( - 'a' => array('href' => '/index/page:3'), + 'a' => array('href' => '/index/page:3', 'class' => 'next'), 'Next', '/a' ); @@ -563,7 +561,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('<< Previous', array('escape' => true)); $expected = array( - 'a' => array('href' => '/index/page:1'), + 'a' => array('href' => '/index/page:1', 'class' => 'prev'), '<< Previous', '/a' ); @@ -571,7 +569,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('<< Previous', array('escape' => false)); $expected = array( - 'a' => array('href' => '/index/page:1'), + 'a' => array('href' => '/index/page:1', 'class' => 'prev'), 'preg:/<< Previous/', '/a' ); @@ -585,25 +583,25 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->prev('<< Previous', null, 'Disabled'); $expected = array( - ' array('class' => 'prev'), '<strong>Disabled</strong>', - '/div' + '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('<< Previous', null, 'Disabled', array('escape' => true)); $expected = array( - ' array('class' => 'prev'), '<strong>Disabled</strong>', - '/div' + '/span' ); $this->assertTags($result, $expected); $result = $this->Paginator->prev('<< Previous', null, 'Disabled', array('escape' => false)); $expected = array( - ' array('class' => 'prev'), 'assertTags($result, $expected); @@ -617,7 +615,7 @@ class PaginatorHelperTest extends CakeTestCase { $this->Paginator->params['paging']['Client']['prevPage'] = true; $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $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', '/a' ); @@ -625,7 +623,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next'); $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', '/a' ); @@ -638,7 +636,7 @@ class PaginatorHelperTest extends CakeTestCase { )); $result = $this->Paginator->prev('Prev'); $expected = array( - 'a' => array('href' => '/index/page:1/limit:10'), + 'a' => array('href' => '/index/page:1/limit:10', 'class' => 'prev'), 'Prev', '/a', ); @@ -669,13 +667,13 @@ class PaginatorHelperTest extends CakeTestCase { ); $result = $this->Paginator->next('Next', array('model' => 'Client')); $expected = array( - 'a' => array('href' => '/index/page:2'), 'Next', '/a' + 'a' => array('href' => '/index/page:2', 'class' => 'next'), 'Next', '/a' ); $this->assertTags($result, $expected); $result = $this->Paginator->next('Next', array('model' => 'Server'), 'No Next', array('model' => 'Server')); $expected = array( - ' array('class' => 'next'), 'No Next', '/span' ); $this->assertTags($result, $expected); } @@ -1591,7 +1589,7 @@ class PaginatorHelperTest extends CakeTestCase { Router::reload(); Router::parse('/'); Router::setRequestInfo(array( - array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true'), 'bare' => 0), + array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true'), 'bare' => 0), array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array()) )); @@ -1607,7 +1605,7 @@ class PaginatorHelperTest extends CakeTestCase { $result = $this->Paginator->next('Next'); $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', '/a' );