Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add option for 'current' class to PaginationHelper::numbers().

  • Loading branch information...
commit d7b06194a4cb3198f431f963c99cc3ae3c08420b 1 parent 752711e
@majna majna authored
View
44 lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
@@ -1297,6 +1297,50 @@ public function testNumbers() {
array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
);
$this->assertTags($result, $expected);
+
+ $result = $this->Paginator->numbers(array('first' => 1, 'currentClass' => 'active'));
+ $expected = array(
+ array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'active')), '2', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
+ ' | ',
+ array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
+
+ $result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link', 'currentClass' => 'active'));
+ $expected = array(
+ array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'active page-link')), '2', '/span',
+ ' | ',
+ array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
+ ' | ',
+ array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
+ );
+ $this->assertTags($result, $expected);
$result = $this->Paginator->numbers(array('last' => 1));
$expected = array(
View
7 lib/Cake/View/Helper/PaginatorHelper.php
@@ -642,6 +642,8 @@ public function counter($options = array()) {
* - `last` Whether you want last links generated, set to an integer to define the number of 'last'
* links to generate.
* - `ellipsis` Ellipsis content, defaults to '...'
+ * - `class` Class for wrapper tag
+ * - `currentClass` Class for wrapper tag on current active page, defaults to 'current'
*
* @param mixed $options Options for the numbers, (before, after, model, modulus, separator)
* @return string numbers string.
@@ -656,7 +658,7 @@ public function numbers($options = array()) {
$defaults = array(
'tag' => 'span', 'before' => null, 'after' => null, 'model' => $this->defaultModel(), 'class' => null,
- 'modulus' => '8', 'separator' => ' | ', 'first' => null, 'last' => null, 'ellipsis' => '...',
+ 'modulus' => '8', 'separator' => ' | ', 'first' => null, 'last' => null, 'ellipsis' => '...', 'currentClass' => 'current'
);
$options += $defaults;
@@ -670,7 +672,7 @@ public function numbers($options = array()) {
extract($options);
unset($options['tag'], $options['before'], $options['after'], $options['model'],
$options['modulus'], $options['separator'], $options['first'], $options['last'],
- $options['ellipsis'], $options['class']
+ $options['ellipsis'], $options['class'], $options['currentClass']
);
$out = '';
@@ -704,7 +706,6 @@ public function numbers($options = array()) {
. $separator;
}
- $currentClass = 'current';
if ($class) {
$currentClass .= ' ' . $class;
}
Please sign in to comment.
Something went wrong with that request. Please try again.