File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -251,21 +251,19 @@ public function getMessage($msgno, $msglist = null){
251
251
* @throws GetMessagesFailedException
252
252
*/
253
253
public function paginate ($ per_page = 5 , $ page = null , $ page_name = 'imap_page ' ){
254
- $ this ->page = $ page > $ this ->page ? $ page : $ this ->page ;
255
- $ this ->limit = $ per_page ;
256
-
257
- $ messages = $ this ->get ();
258
- if (($ count = $ messages ->count ()) > 0 ) {
259
- $ limit = $ this ->limit > $ count ? $ count : $ this ->limit ;
260
- $ collection = array_fill (0 , $ messages ->total () - $ limit , true );
261
- $ messages ->each (function ($ message ) use (&$ collection ){
262
- $ collection [] = $ message ;
263
- });
264
- }else {
265
- $ collection = array_fill (0 , $ messages ->total (), true );
254
+ if (
255
+ $ page === null
256
+ && isset ($ _GET [$ page_name ])
257
+ && $ _GET [$ page_name ] > 0
258
+ ) {
259
+ $ this ->page = intval ($ _GET [$ page_name ]);
260
+ } elseif ($ page > 0 ) {
261
+ $ this ->page = $ page ;
266
262
}
267
263
268
- return MessageCollection::make ($ collection )->paginate ($ per_page , $ this ->page , $ page_name );
264
+ $ this ->limit = $ per_page ;
265
+
266
+ return $ this ->get ()->paginate ($ per_page , $ this ->page , $ page_name );
269
267
}
270
268
271
269
/**
You can’t perform that action at this time.
0 commit comments