Esempio n. 1
0
 /**
  * 构造方法
  * 
  * @param int $total         总数
  * @param int $page          第几页
  * @param int $count         每页多少项
  * @param int $last_page     上一次请页的页面
  * @param int $next_since_id 当前请求最后一个ID
  * @param int $prev_since_id 当前请求第一个ID
  */
 public function __construct($total, $count = 20, $page = false, $last_page = false, $next_since_id = false, $prev_since_id = false)
 {
     $this->total = $total;
     $this->page = $page;
     $this->last_page = $last_page;
     $this->count = $count;
     $this->next_since_id = $next_since_id;
     $this->prev_since_id = $prev_since_id;
     if ($this->page === false) {
         $this->page = Arg::get('p', FILTER_VALIDATE_INT, ['min_range' => 1]) ?: 1;
     }
     if ($this->next_since_id === false) {
         $this->next_since_id = Arg::get('next_since_id', FILTER_VALIDATE_INT) ?: 0;
     }
     if ($this->prev_since_id === false) {
         $this->next_since_id = Arg::get('prev_since_id', FILTER_VALIDATE_INT) ?: 0;
     }
     if (!$this->last_page === false) {
         $this->last_page = Arg::get('last_page', FILTER_VALIDATE_INT, ['min_range' => 1]) ?: 0;
     }
     $this->page_total = ceil($this->total / $this->count);
 }