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
This commit is contained in:
joelmoss 2008-05-13 23:35:47 +00:00
parent dd7aa25a20
commit 09ebd9cbe6
2 changed files with 8 additions and 4 deletions

View file

@ -289,7 +289,7 @@ 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); $_defaults = array('url' => array(), 'step' => 1, 'escape' => true, 'model' => null, 'tag' => 'div');
$options = array_merge($_defaults, (array)$options); $options = array_merge($_defaults, (array)$options);
$paging = $this->params($options['model']); $paging = $this->params($options['model']);
@ -311,7 +311,7 @@ class PaginatorHelper extends AppHelper {
if ($this->{$check}()) { if ($this->{$check}()) {
return $this->link($title, $url, array_merge($options, array('escape' => $escape))); return $this->link($title, $url, array_merge($options, array('escape' => $escape)));
} else { } else {
return $this->Html->div(null, $title, $options, $escape); return $this->Html->tag($tag, $title, $options, $escape);
} }
} }
/** /**

View file

@ -89,8 +89,8 @@ class PaginatorTest extends UnitTestCase {
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$this->Paginator->params['paging']['Article']['prevPage'] = false; $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')); $result = $this->Paginator->prev('prev', array('update'=> 'theList', 'indicator'=> 'loading', 'url'=> array('controller' => 'posts')), null, array('class' => 'disabled', 'tag' => 'span'));
$expected = '<div class="disabled">prev</div>'; $expected = '<span class="disabled">prev</span>';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
@ -204,6 +204,10 @@ class PaginatorTest extends UnitTestCase {
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled')); $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
$expected = '<div class="disabled">&lt;&lt; Previous</div>'; $expected = '<div class="disabled">&lt;&lt; Previous</div>';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled', 'tag' => 'span'));
$expected = '<span class="disabled">&lt;&lt; Previous</span>';
$this->assertEqual($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;