Skip to content
This repository
Browse code

Allow specifying tag for current page number. Closes #2892

  • Loading branch information...
commit 61dd1098d381f097c33f30c2bdfca8d252639547 1 parent 57681ff
ADmad authored October 12, 2012
22  lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
@@ -1436,6 +1436,28 @@ public function testNumbers() {
1436 1436
 		);
1437 1437
 		$this->assertTags($result, $expected);
1438 1438
 
  1439
+		$result = $this->Paginator->numbers(array('first' => 1, 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'a'));
  1440
+		$expected = array(
  1441
+			array('li' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/li',
  1442
+			' | ',
  1443
+			array('li' => array('class' => 'active')), array('a' => array()), '2', '/a', '/li',
  1444
+			' | ',
  1445
+			array('li' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/li',
  1446
+			' | ',
  1447
+			array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li',
  1448
+			' | ',
  1449
+			array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li',
  1450
+			' | ',
  1451
+			array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li',
  1452
+			' | ',
  1453
+			array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li',
  1454
+			' | ',
  1455
+			array('li' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/li',
  1456
+			' | ',
  1457
+			array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li',
  1458
+		);
  1459
+		$this->assertTags($result, $expected);
  1460
+
1439 1461
 		$result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link', 'currentClass' => 'active'));
1440 1462
 		$expected = array(
1441 1463
 			array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
12  lib/Cake/View/Helper/PaginatorHelper.php
@@ -650,6 +650,7 @@ public function counter($options = array()) {
650 650
  * - `ellipsis` Ellipsis content, defaults to '...'
651 651
  * - `class` Class for wrapper tag
652 652
  * - `currentClass` Class for wrapper tag on current active page, defaults to 'current'
  653
+ * - `currentTag` Tag to use for current page number, defaults to null
653 654
  *
654 655
  * @param array $options Options for the numbers, (before, after, model, modulus, separator)
655 656
  * @return string numbers string.
@@ -664,7 +665,8 @@ public function numbers($options = array()) {
664 665
 
665 666
 		$defaults = array(
666 667
 			'tag' => 'span', 'before' => null, 'after' => null, 'model' => $this->defaultModel(), 'class' => null,
667  
-			'modulus' => '8', 'separator' => ' | ', 'first' => null, 'last' => null, 'ellipsis' => '...', 'currentClass' => 'current'
  668
+			'modulus' => '8', 'separator' => ' | ', 'first' => null, 'last' => null, 'ellipsis' => '...',
  669
+			'currentClass' => 'current', 'currentTag' => null
668 670
 		);
669 671
 		$options += $defaults;
670 672
 
@@ -678,7 +680,7 @@ public function numbers($options = array()) {
678 680
 		extract($options);
679 681
 		unset($options['tag'], $options['before'], $options['after'], $options['model'],
680 682
 			$options['modulus'], $options['separator'], $options['first'], $options['last'],
681  
-			$options['ellipsis'], $options['class'], $options['currentClass']
  683
+			$options['ellipsis'], $options['class'], $options['currentClass'], $options['currentTag']
682 684
 		);
683 685
 
684 686
 		$out = '';
@@ -714,7 +716,11 @@ public function numbers($options = array()) {
714 716
 			if ($class) {
715 717
 				$currentClass .= ' ' . $class;
716 718
 			}
717  
-			$out .= $this->Html->tag($tag, $params['page'], array('class' => $currentClass));
  719
+			if ($currentTag) {
  720
+				$out .= $this->Html->tag($tag, $this->Html->tag($currentTag, $params['page']), array('class' => $currentClass));
  721
+			} else {
  722
+				$out .= $this->Html->tag($tag, $params['page'], array('class' => $currentClass));
  723
+			}
718 724
 			if ($i != $params['pageCount']) {
719 725
 				$out .= $separator;
720 726
 			}

0 notes on commit 61dd109

Please sign in to comment.
Something went wrong with that request. Please try again.