Beispiel #1
0
 /**
  * 获取分页处理类
  * @return \tfc\util\Paginator
  */
 public function getPaginator()
 {
     // 总的记录数 <= 0,表示不需要分页
     if (($totalRows = $this->getTotalRows()) <= 0) {
         return null;
     }
     // 每页展示的行数 <= 0,表示不需要分页
     if (($listRows = $this->getListRows()) <= 0) {
         return null;
     }
     $firstRow = max($this->getFirstRow(), 0);
     $currPage = floor($firstRow / $listRows) + 1;
     $paginator = new Paginator($totalRows, $this->getUrl(), PageHelper::getPageVar());
     $paginator->setListPages(PageHelper::getListPages());
     $paginator->setListRows($listRows);
     $paginator->setCurrPage($currPage);
     return $paginator;
 }
Beispiel #2
0
 /**
  * 获取分页处理类
  * @return \tfc\util\Paginator
  */
 public function getPaginator()
 {
     // 总的记录数 <= 0,表示不需要分页
     if (($totalRows = $this->getTotalRows()) <= 0) {
         return null;
     }
     $attributes = isset($this->_tplVars['attributes']) ? (array) $this->_tplVars['attributes'] : array();
     $order = isset($this->_tplVars['order']) ? trim($this->_tplVars['order']) : '';
     $listRows = isset($this->_tplVars['limit']) ? (int) $this->_tplVars['limit'] : 0;
     $firstRow = isset($this->_tplVars['offset']) ? (int) $this->_tplVars['offset'] : 0;
     // 每页展示的行数 <= 0,表示第一页展示所有数据
     if ($listRows <= 0) {
         return null;
     }
     if ($order !== '') {
         $attributes['order'] = $order;
     }
     if ($listRows !== (int) Cfg::getApp('list_rows', 'paginator')) {
         $attributes[PageHelper::getListRowsVar()] = $listRows;
     }
     $firstRow = max($firstRow, 0);
     $currPage = floor($firstRow / $listRows) + 1;
     $url = $this->getUrlManager()->getUrl(Mvc::$action, Mvc::$controller, Mvc::$module, $attributes);
     $paginator = new Paginator($totalRows, $url, PageHelper::getPageVar());
     $paginator->setListPages(PageHelper::getListPages());
     $paginator->setListRows($listRows);
     $paginator->setCurrPage($currPage);
     return $paginator;
 }