@@ -78,6 +78,11 @@ class PaginatorHelper extends Helper {
78
78
'prevDisabled ' => '<li class="prev disabled"><span>{{text}}</span></li> ' ,
79
79
'counterRange ' => '{{start}} - {{end}} of {{count}} ' ,
80
80
'counterPages ' => '{{page}} of {{pages}} ' ,
81
+ 'first ' => '<li class="first"><a rel="first" href="{{url}}">{{text}}</a></li> ' ,
82
+ 'last ' => '<li class="last"><a rel="last" href="{{url}}">{{text}}</a></li> ' ,
83
+ 'number ' => '<li><a href="{{url}}">{{text}}</a></li> ' ,
84
+ 'ellipsis ' => '... ' ,
85
+ 'separator ' => ' | ' ,
81
86
];
82
87
83
88
/**
@@ -276,9 +281,6 @@ protected function _toggledLink($text, $enabled, $options, $templates) {
276
281
]);
277
282
}
278
283
279
- if (!empty ($ this ->options ['url ' ])) {
280
- $ options ['url ' ] = array_merge ($ this ->options ['url ' ], $ options ['url ' ]);
281
- }
282
284
$ url = array_merge (
283
285
$ options ['url ' ],
284
286
['page ' => $ paging ['page ' ] + $ options ['step ' ]]
@@ -469,6 +471,10 @@ public function url($options = array(), $asArray = false, $model = null) {
469
471
'sort ' => $ paging ['sort ' ],
470
472
'direction ' => $ paging ['direction ' ],
471
473
];
474
+
475
+ if (!empty ($ this ->options ['url ' ])) {
476
+ $ url = array_merge ($ this ->options ['url ' ], $ url );
477
+ }
472
478
$ url = array_merge (array_filter ($ url ), $ options );
473
479
474
480
if (!empty ($ url ['page ' ]) && $ url ['page ' ] == 1 ) {
@@ -768,55 +774,51 @@ public function numbers($options = array()) {
768
774
*
769
775
* ### Options:
770
776
*
771
- * - `tag` The tag wrapping tag you want to use, defaults to 'span'
772
- * - `after` Content to insert after the link/tag
773
777
* - `model` The model to use defaults to PaginatorHelper::defaultModel()
774
- * - `separator` Content between the generated links, defaults to ' | '
775
- * - `ellipsis` Content for ellipsis, defaults to '...'
778
+ * - `escape` Whether or not to HTML escape the text.
776
779
*
777
780
* @param string|integer $first if string use as label for the link. If numeric, the number of page links
778
781
* you want at the beginning of the range.
779
782
* @param array $options An array of options.
780
783
* @return string numbers string.
781
784
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::first
782
785
*/
783
- public function first ($ first = '<< first ' , $ options = array () ) {
786
+ public function first ($ first = '<< first ' , $ options = [] ) {
784
787
$ options = array_merge (
785
- array (
786
- 'tag ' => 'span ' ,
787
- 'after ' => null ,
788
- 'model ' => $ this ->defaultModel (),
789
- 'separator ' => ' | ' ,
790
- 'ellipsis ' => '... ' ,
791
- 'class ' => null
792
- ),
793
- (array )$ options );
788
+ ['model ' => $ this ->defaultModel (), 'escape ' => true ],
789
+ (array )$ options
790
+ );
794
791
795
- $ params = array_merge (array ('page ' => 1 ), (array )$ this ->params ($ options ['model ' ]));
792
+ $ params = array_merge (
793
+ ['page ' => 1 ],
794
+ (array )$ this ->params ($ options ['model ' ])
795
+ );
796
796
unset($ options ['model ' ]);
797
797
798
798
if ($ params ['pageCount ' ] <= 1 ) {
799
799
return false ;
800
800
}
801
- extract ($ options );
802
- unset($ options ['tag ' ], $ options ['after ' ], $ options ['model ' ], $ options ['separator ' ], $ options ['ellipsis ' ], $ options ['class ' ]);
803
801
804
802
$ out = '' ;
805
803
806
804
if (is_int ($ first ) && $ params ['page ' ] >= $ first ) {
807
- if ($ after === null ) {
808
- $ after = $ ellipsis ;
809
- }
805
+ $ ellipsis = $ this ->_templater ->format ('ellipsis ' , []);
806
+ $ separator = $ this ->_templater ->format ('separator ' , []);
810
807
for ($ i = 1 ; $ i <= $ first ; $ i ++) {
811
- $ out .= $ this ->Html ->tag ($ tag , $ this ->link ($ i , array ('page ' => $ i ), $ options ), compact ('class ' ));
808
+ $ out .= $ this ->_templater ->format ('number ' , [
809
+ 'url ' => $ this ->url (['page ' => $ i ]),
810
+ 'text ' => $ i
811
+ ]);
812
812
if ($ i != $ first ) {
813
813
$ out .= $ separator ;
814
814
}
815
815
}
816
- $ out .= $ after ;
817
816
} elseif ($ params ['page ' ] > 1 && is_string ($ first )) {
818
- $ options += array ('rel ' => 'first ' );
819
- $ out = $ this ->Html ->tag ($ tag , $ this ->link ($ first , array ('page ' => 1 ), $ options ), compact ('class ' )) . $ after ;
817
+ $ first = $ options ['escape ' ] ? h ($ first ) : $ first ;
818
+ $ out .= $ this ->_templater ->format ('first ' , [
819
+ 'url ' => $ this ->url (['page ' => 1 ]),
820
+ 'text ' => $ first
821
+ ]);
820
822
}
821
823
return $ out ;
822
824
}
0 commit comments