示例#1
0
文件: Page.php 项目: zonquan/cmlphp
 /**
  * 构造函数
  *
  * @param int $totalRows 总行数
  * @param int $listRows 每页显示条数
  * @param string $param分页跳转时带的参数
  *
  * @return void
  */
 public function __construct($totalRows, $listRows = 20, $param = '')
 {
     $this->totalRows = $totalRows;
     $this->listRows = $listRows ? intval($listRows) : 10;
     $this->varPage = Config::get('VAR_PAGE') ? Config::get('VAR_PAGE') : 'p';
     $this->param = $param;
     $this->totalPages = ceil($this->totalRows / $this->listRows);
     $this->coolPages = ceil($this->totalPages / $this->rollPage);
     $this->nowPage = Input::getInt($this->varPage, 2);
     if ($this->nowPage < 1) {
         $this->nowPage = 1;
     } elseif (!empty($this->totalRows) && $this->nowPage > $this->totalPages) {
         $this->nowPage = $this->totalPages;
     }
     $this->firstRow = $this->listRows * ($this->nowPage - 1);
 }
示例#2
0
 /**
  * 构造函数
  *
  * @param int $totalRows 总行数
  * @param int $numPerPage 每页显示条数
  * @param array $param 分页跳转时带的参数 如:['name' => '张三']
  */
 public function __construct($totalRows, $numPerPage = 20, $param = [])
 {
     $this->totalRows = $totalRows;
     $this->numPerPage = $numPerPage ? intval($numPerPage) : 10;
     $this->pageShowVarName = Config::get('var_page') ? Config::get('var_page') : 'p';
     $this->param = $param;
     $this->totalPages = ceil($this->totalRows / $this->numPerPage);
     $this->coolPages = ceil($this->totalPages / $this->barShowPage);
     $this->nowPage = Input::getInt($this->pageShowVarName, 1);
     if ($this->nowPage < 1) {
         $this->nowPage = 1;
     } elseif (!empty($this->totalRows) && $this->nowPage > $this->totalPages) {
         $this->nowPage = $this->totalPages;
     }
     $this->firstRow = $this->numPerPage * ($this->nowPage - 1);
 }
示例#3
0
 /**
  * 分页获取数据
  *
  * @param int $limit 每页返回的条数
  * @param bool $useMaster 是否使用主库 默认读取从库
  *
  * @return array
  */
 public function paginate($limit, $useMaster = false)
 {
     $page = Input::requestInt(Config::get('var_page'), 1);
     $page < 1 && ($page = 1);
     return call_user_func_array([$this, 'select'], [($page - 1) * $limit, $limit, $useMaster]);
 }
示例#4
0
 /**
  * 类加载-检测token值
  *
  *  @return bool
  */
 public static function checkToken()
 {
     $token = Input::postString('CML_TOKEN');
     if (empty($token)) {
         return false;
     }
     if ($token !== self::getToken()) {
         return false;
     }
     unset($_COOKIE['CML_TOKEN']);
     return true;
 }