@@ -26,13 +26,13 @@ class PagingBase
2626 * 第一个数字按钮,当前页数减去偏移页数
2727 * @var int
2828 */
29- protected $ firstNumBtn = 0 ;
29+ protected $ firstPage = 0 ;
3030
3131 /**
3232 * 最后一个数字按钮
3333 * @var int
3434 */
35- protected $ lastNumBtn = 0 ;
35+ protected $ lastPage = 0 ;
3636
3737 /**
3838 * 偏移页数 floor($this->btnNum/2)
@@ -125,12 +125,6 @@ protected function handleOptions($options, $text)
125125
126126 $ this ->options = array_merge ($ this ->options ,$ options );
127127
128- // foreach ($this->options as $key => $value) {
129- // if (property_exists($this, $key)) {
130- // $this->$key = $value;
131- // }
132- // }
133-
134128 //文本配置
135129 if ( $ text ) {
136130 $ this ->text = array_merge ($ this ->text , $ text );
@@ -168,29 +162,29 @@ protected function handleLogic()
168162 $ btnNum = $ this ->getOption ('btnNum ' , 5 );
169163
170164 // 计算
171- $ this ->pageTotal = ceil ($ this ->getOption ('total ' )/$ this ->getOption ('pageSize ' ));
172- $ this ->offsetPage = floor ($ btnNum /2 );//偏移页数
173- $ this ->prevPage = $ page - 1 ; // 上一页
174- $ this ->nextPage = $ page + 1 ; // 下一页
175- $ this ->firstNumBtn = $ page - $ this ->offsetPage ; //第一个数字按钮,当前页数减去偏移页数;
176- $ this ->lastNumBtn = $ page + $ this ->offsetPage ; //最后一个数字按钮
165+ $ this ->pageTotal = ceil ($ this ->getOption ('total ' )/$ this ->getOption ('pageSize ' ));
166+ $ this ->offsetPage = floor ($ btnNum /2 );//偏移页数
167+ $ this ->prevPage = $ page - 1 ; // 上一页
168+ $ this ->nextPage = $ page + 1 ; // 下一页
169+ $ this ->firstPage = $ page - $ this ->offsetPage ; //第一个数字按钮,当前页数减去偏移页数;
170+ $ this ->lastPage = $ page + $ this ->offsetPage ; //最后一个数字按钮
177171
178172 //当第一个数字按钮小于1时;
179- if ($ this ->firstNumBtn < 1 ) {
180- $ this ->firstNumBtn = 1 ;
181- $ this ->lastNumBtn = $ btnNum ;
173+ if ($ this ->firstPage < 1 ) {
174+ $ this ->firstPage = 1 ;
175+ $ this ->lastPage = $ btnNum ;
182176 }
183177
184178 //当最后一个数字按钮大于总页数时;通常情况下
185- if ($ this ->lastNumBtn > $ this ->pageTotal ) {
186- $ this ->lastNumBtn = $ this ->pageTotal ;
187- $ this ->firstNumBtn = $ this ->pageTotal - $ btnNum + 1 ;
179+ if ($ this ->lastPage > $ this ->pageTotal ) {
180+ $ this ->lastPage = $ this ->pageTotal ;
181+ $ this ->firstPage = $ this ->pageTotal - $ btnNum + 1 ;
188182 }
189183
190184 //当总页数小于翻页的数字按钮个数时;
191185 if ($ btnNum > $ this ->pageTotal ) {
192- $ this ->lastNumBtn = $ this ->pageTotal ;
193- $ this ->firstNumBtn = 1 ;
186+ $ this ->lastPage = $ this ->pageTotal ;
187+ $ this ->firstPage = 1 ;
194188 }
195189 }
196190
@@ -247,12 +241,12 @@ public function getText()
247241 public function getData ()
248242 {
249243 return [
250- 'pageTotal ' => $ this ->pageTotal ,
251- 'offsetPage ' => $ this ->offsetPage ,
252- 'prevPage ' => $ this ->prevPage ,
253- 'nextPage ' => $ this ->nextPage ,
254- 'firstNumBtn ' => $ this ->firstNumBtn ,
255- 'lastNumBtn ' => $ this ->lastNumBtn ,
244+ 'pageTotal ' => $ this ->pageTotal ,
245+ 'offsetPage ' => $ this ->offsetPage ,
246+ 'prevPage ' => $ this ->prevPage ,
247+ 'nextPage ' => $ this ->nextPage ,
248+ 'firstPage ' => $ this ->firstPage ,
249+ 'lastPage ' => $ this ->lastPage ,
256250 ];
257251 }
258252
@@ -268,4 +262,8 @@ public function get($key, $default=null)
268262 // return isset($this->data[$key]) ? $this->data[$key] : $default;
269263 }
270264
265+ public function __get ($ name )
266+ {
267+ return $ this ->get ($ name );
268+ }
271269}
0 commit comments