@@ -80,51 +80,40 @@ class BootstrapPaginatorHelper extends PaginatorHelper {
8080 **/
8181 public function numbers (array $ options = []) {
8282
83- $ options += [
84- 'class ' => ''
83+ $ defaults = [
84+ 'before ' => null , 'after ' => null , 'model ' => $ this ->defaultModel (),
85+ 'modulus ' => 8 , 'first ' => null , 'last ' => null , 'url ' => [],
86+ 'class ' => '' , 'size ' => false
8587 ];
88+ $ options += $ defaults ;
8689
87- $ class = 'pagination ' .$ options ['class ' ] ;
88- unset($ options ['class ' ]);
90+ $ options = $ this ->addClass ($ options , 'pagination ' );
8991
90- if (isset ($ options ['size ' ])) {
91- switch ($ options ['size ' ]) {
92- case 'small ' :
93- $ class .= ' pagination-sm ' ;
94- break ;
95- case 'large ' :
96- $ class .= ' pagination-lg ' ;
97- break ;
98- }
99- unset($ options ['size ' ]) ;
92+ switch ($ options ['size ' ]) {
93+ case 'small ' :
94+ $ options = $ this ->addClass ($ options , 'pagination-sm ' ) ;
95+ break ;
96+ case 'large ' :
97+ $ options = $ this ->addClass ($ options , 'pagination-lg ' ) ;
98+ break ;
10099 }
100+ unset($ options ['size ' ]) ;
101101
102- if (! isset ( $ options ['before ' ])) {
103- $ options ['before ' ] = '<ul class=" ' .$ class . ' "> ' ;
104- }
102+ $ options [ ' before ' ] .= $ this -> Html -> tag ( ' ul ' , null , [ ' class ' => $ options ['class ' ]]);
103+ $ options ['after ' ] = '</ul> ' .$ options [ ' after ' ] ;
104+ unset( $ options [ ' class ' ]);
105105
106- if (!isset ($ options ['after ' ])) {
107- $ options ['after ' ] = '</ul> ' ;
106+ $ params = (array )$ this ->params ($ options ['model ' ]) + ['page ' => 1 ];
107+ if ($ params ['pageCount ' ] <= 1 ) {
108+ return false ;
108109 }
109110
110- return parent ::numbers ($ options );
111-
112- }
113-
114- /**
115- * Generates the numbers for the paginator numbers() method.
116- *
117- * @param \Cake\View\StringTemplate $templater StringTemplate instance.
118- * @param array $params Params from the numbers() method.
119- * @param array $options Options from the numbers() method.
120- * @return string Markup output.
121- */
122- protected function _modulusNumbers ($ templater , $ params , $ options ) {
123-
124- $ options += [
125- 'before ' => '' ,
126- 'after ' => ''
127- ];
111+ $ templater = $ this ->templater ();
112+ if (isset ($ options ['templates ' ])) {
113+ $ templater ->push ();
114+ $ method = is_string ($ options ['templates ' ]) ? 'load ' : 'add ' ;
115+ $ templater ->{$ method }($ options ['templates ' ]);
116+ }
128117
129118 $ first = $ prev = $ next = $ last = '' ;
130119
@@ -171,7 +160,17 @@ protected function _modulusNumbers($templater, $params, $options) {
171160 $ options ['after ' ] = $ next .$ last .$ options ['after ' ];
172161 $ options ['first ' ] = $ options ['last ' ] = false ;
173162
174- return parent ::_modulusNumbers ($ templater , $ params , $ options ) ;
163+ if ($ options ['modulus ' ] !== false && $ params ['pageCount ' ] > $ options ['modulus ' ]) {
164+ $ out = $ this ->_modulusNumbers ($ templater , $ params , $ options );
165+ } else {
166+ $ out = $ this ->_numbers ($ templater , $ params , $ options );
167+ }
168+
169+ if (isset ($ options ['templates ' ])) {
170+ $ templater ->pop ();
171+ }
172+
173+ return $ out ;
175174 }
176175
177176 public function prev ($ title = '<< Previous ' , array $ options = []) {
0 commit comments