Skip to content
This repository
Browse code

prev() and next() methods of PaginatorHelper now possible to place th…

…e 'tag' option to 'false' for disable the wrapper.
  • Loading branch information...
commit d0d15701b391a1ab672bf7e8f01764b801ded312 1 parent 26e3184
Sebastián Marcos Arce authored November 16, 2012
32  lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
@@ -865,6 +865,14 @@ public function testPagingLinks() {
865 865
 		);
866 866
 		$this->assertTags($result, $expected);
867 867
 
  868
+		$result = $this->Paginator->prev('<< Previous', array('tag' => false), null, array('class' => 'disabled'));
  869
+		$expected = array(
  870
+			'a' => array('href' => '/index/page:1', 'rel' => 'prev', 'class' => 'prev'),
  871
+			'&lt;&lt; Previous',
  872
+			'/a'
  873
+		);
  874
+		$this->assertTags($result, $expected);
  875
+
868 876
 		$result = $this->Paginator->next('Next');
869 877
 		$expected = array(
870 878
 			'span' => array('class' => 'next'),
@@ -885,6 +893,14 @@ public function testPagingLinks() {
885 893
 		);
886 894
 		$this->assertTags($result, $expected);
887 895
 
  896
+		$result = $this->Paginator->next('Next', array('tag' => false));
  897
+		$expected = array(
  898
+			'a' => array('href' => '/index/page:3', 'rel' => 'next', 'class' => 'next'),
  899
+			'Next',
  900
+			'/a'
  901
+		);
  902
+		$this->assertTags($result, $expected);
  903
+
888 904
 		$result = $this->Paginator->prev('<< Previous', array('escape' => true));
889 905
 		$expected = array(
890 906
 			'span' => array('class' => 'prev'),
@@ -944,6 +960,14 @@ public function testPagingLinks() {
944 960
 		);
945 961
 		$this->assertTags($result, $expected);
946 962
 
  963
+		$result = $this->Paginator->prev('<< Previous', array('tag' => false), '<strong>Disabled</strong>');
  964
+		$expected = array(
  965
+			'span' => array('class' => 'prev'),
  966
+			'&lt;strong&gt;Disabled&lt;/strong&gt;',
  967
+			'/span'
  968
+		);
  969
+		$this->assertTags($result, $expected);
  970
+
947 971
 		$this->Paginator->request->params['paging'] = array(
948 972
 			'Client' => array(
949 973
 				'page' => 1,
@@ -1016,6 +1040,14 @@ public function testPagingLinks() {
1016 1040
 		);
1017 1041
 		$this->assertTags($result, $expected);
1018 1042
 
  1043
+		$result = $this->Paginator->next('Next', array(), null, array('tag' => false));
  1044
+		$expected = array(
  1045
+			'span' => array('class' => 'next'),
  1046
+			'Next',
  1047
+			'/span'
  1048
+		);
  1049
+		$this->assertTags($result, $expected);
  1050
+
1019 1051
 		$this->Paginator->request->params['paging'] = array(
1020 1052
 			'Client' => array(
1021 1053
 				'page' => 2, 'current' => 1, 'count' => 13, 'prevPage' => true,
10  lib/Cake/View/Helper/PaginatorHelper.php
@@ -247,7 +247,7 @@ public function sortDir($model = null, $options = array()) {
247 247
  *
248 248
  * ### Options:
249 249
  *
250  
- * - `tag` The tag wrapping tag you want to use, defaults to 'span'
  250
+ * - `tag` The tag wrapping tag you want to use, defaults to 'span'. Set this to false to disable this option
251 251
  * - `escape` Whether you want the contents html entity encoded, defaults to true
252 252
  * - `model` The model to use, defaults to PaginatorHelper::defaultModel()
253 253
  *
@@ -271,7 +271,7 @@ public function prev($title = '<< Previous', $options = array(), $disabledTitle
271 271
  *
272 272
  * ### Options:
273 273
  *
274  
- * - `tag` The tag wrapping tag you want to use, defaults to 'span'
  274
+ * - `tag` The tag wrapping tag you want to use, defaults to 'span'. Set this to false to disable this option
275 275
  * - `escape` Whether you want the contents html entity encoded, defaults to true
276 276
  * - `model` The model to use, defaults to PaginatorHelper::defaultModel()
277 277
  *
@@ -468,12 +468,16 @@ protected function _pagingLink($which, $title = null, $options = array(), $disab
468 468
 			${$key} = $options[$key];
469 469
 			unset($options[$key]);
470 470
 		}
471  
-		$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
472 471
 
473 472
 		if ($this->{$check}($model)) {
  473
+			$url = array_merge(array('page' => $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url);
  474
+			if ($tag === false) {
  475
+				return $this->link($title, $url, array_merge($options, compact('escape', 'model', 'class')));
  476
+			}
474 477
 			return $this->Html->tag($tag, $this->link($title, $url, array_merge($options, compact('escape', 'model'))), compact('class'));
475 478
 		} else {
476 479
 			unset($options['rel']);
  480
+			$tag = $tag ? $tag : $_defaults['tag'];
477 481
 			return $this->Html->tag($tag, $title, array_merge($options, compact('escape', 'class')));
478 482
 		}
479 483
 	}

0 notes on commit d0d1570

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