12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace huolib\tool;
- use think\Config;
- use think\Paginator;
- use think\Session;
- class Page {
-
- public static function paginate($count, $list, $page, $offset, $config = []) {
- $_simple = false;
- $_total = 0;
- if (is_int($count)) {
- $_total = $count;
- }
- $_offset = $offset;
- $_config = array_merge(Config::get('paginate'), $config);
- $_offset = $_offset ?: request()->param('list_rows/d', 0);
- if (empty($_offset)) {
- $_offset = Session::get('list_rows');
- } else {
- Session::set('list_rows', $_offset);
- }
- $_offset = $_offset ?: $_config['list_rows'];
-
- $_class = false !== strpos($_config['type'], '\\')
- ? $_config['type']
- : '\\think\\paginator\\driver\\'.ucwords(
- $_config['type']
- );
- $_page = $page < 1 ? 1 : $page;
- $_config['path'] = isset($_config['path']) ? $_config['path'] : call_user_func([$_class, 'getCurrentPath']);
- return $_class::make($list, $_offset, $_page, $_total, $_simple, $_config);
- }
- }
|