page = max(1, isset($params['page']) ? intval($params['page']) : 1); $this->page_size = empty($params['page_size']) ? (empty($params['number']) ? 10 : intval($params['number'])) : intval($params['page_size']); $this->total = max(1, isset($params['total']) ? intval($params['total']) : 1); $this->bt_number = isset($params['bt_number']) ? intval($params['bt_number']) : 2; $this->where = (isset($params['where']) && is_array($params['where'])) ? $params['where'] : ''; $this->not_fields = (!empty($params['not_fields']) && is_array($params['not_fields'])) ? $params['not_fields'] : []; $this->url = isset($params['url']) ? $params['url'] : ''; $this->tips_msg = empty($params['tips_msg']) ? '' : trim($params['tips_msg']); $this->is_next_bt = (!isset($params['is_next_bt']) || $params['is_next_bt'] == 1) ? 1 : 0; $this->page_total = 1; $this->html = ''; // 插件基础参数不参与条件 $this->not_fields[] = 'pluginsname'; $this->not_fields[] = 'pluginscontrol'; $this->not_fields[] = 'pluginsaction'; /* 参数设置 */ $this->SetParem(); } /** * 参数设置 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2023-01-19 * @desc description */ private function SetParem() { /* 防止超出最大页码数 */ $this->page_total = ceil($this->total/$this->page_size); if($this->page > $this->page_total) $this->page = $this->page_total; /* url是否包含问号 */ $state = stripos($this->url, '?'); /* 额外条件url设置 */ if(!empty($this->where) && is_array($this->where)) { $tmp = true; foreach($this->where as $k=>$v) { if(!in_array($k, $this->not_fields) && !is_array($v)) { // 分页不参与url拼接 if($k == 'page') { continue; } // 数据处理 $k = empty($k) ? $k : htmlspecialchars($k); $v = empty($v) ? $v : htmlspecialchars($v); // 拼接参数 if($tmp) { $this->url .= ($state === false) ? '?' : '&'; $this->url .= $k.'='.$v; $tmp = false; } else { $this->url .= '&'.$k.'='.$v; } } } $this->page_join = ($tmp == false) ? '&' : (($state === false) ? '?' : '&'); } else { $this->page_join = ($state === false) ? '?' : '&'; } } /** * 获取生成好的分页代码 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2023-01-19 * @desc description */ public function GetPageHtml() { $before_disabled = ($this->page > 1) ? '' : ' am-disabled'; $after_disabled = ($this->page > 0 && $this->page < $this->page_total) ? '' : ' am-disabled'; $this->html .= '