From 09ebd9cbe67554354f0b9d9a17bf11d4d0c3d7a6 Mon Sep 17 00:00:00 2001 From: joelmoss Date: Tue, 13 May 2008 23:35:47 +0000 Subject: [PATCH] Paginator Helper prev and next methods now use the Html::tag helper method, allowing you to pass a tag option to specify what HTML tag the disabled links should be wrapped in. Defaults to div. Fixes #3991 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6862 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/paginator.php | 4 ++-- cake/tests/cases/libs/view/helpers/paginator.test.php | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index be521d68f..9158b0602 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -289,7 +289,7 @@ 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); + $_defaults = array('url' => array(), 'step' => 1, 'escape' => true, 'model' => null, 'tag' => 'div'); $options = array_merge($_defaults, (array)$options); $paging = $this->params($options['model']); @@ -311,7 +311,7 @@ class PaginatorHelper extends AppHelper { if ($this->{$check}()) { return $this->link($title, $url, array_merge($options, array('escape' => $escape))); } else { - return $this->Html->div(null, $title, $options, $escape); + return $this->Html->tag($tag, $title, $options, $escape); } } /** diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 2de80b130..cbae005eb 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -89,8 +89,8 @@ class PaginatorTest extends UnitTestCase { $this->assertEqual($result, $expected); $this->Paginator->params['paging']['Article']['prevPage'] = false; - $result = $this->Paginator->prev('prev', array('update'=> 'theList', 'indicator'=> 'loading', 'url'=> array('controller' => 'posts')), null, array('class' => 'disabled')); - $expected = '
prev
'; + $result = $this->Paginator->prev('prev', array('update'=> 'theList', 'indicator'=> 'loading', 'url'=> array('controller' => 'posts')), null, array('class' => 'disabled', 'tag' => 'span')); + $expected = 'prev'; $this->assertEqual($result, $expected); } @@ -204,6 +204,10 @@ class PaginatorTest extends UnitTestCase { $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $expected = '
<< Previous
'; $this->assertEqual($result, $expected); + + $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled', 'tag' => 'span')); + $expected = '<< Previous'; + $this->assertEqual($result, $expected); $this->Paginator->params['paging']['Client']['page'] = 2; $this->Paginator->params['paging']['Client']['prevPage'] = true;