getCurrentPage() - $this->pageNumberLength - 1 < 1)) { return; } return ''.($caption ? $caption : 1).'' . ($caption ? '' : '...'); } public function lastPage($caption = '') { if ((!$caption && $this->_currentPage > $this->getTotalPage() - $this->pageNumberLength - 1)) { return; } return ($caption ? '' : ' ... ') . ''.($caption ? $caption : $this->_totalPage).''; } public function pageNumber($length = null) { if ($length) { $this->pageNumberLength = $length; } else { $length = $this->pageNumberLength; } $str = null; for ($i = $this->getCurrentPage() - $length; $i < $this->getCurrentPage() + $length + 1; $i++) { if ($i < 1 || $i > $this->getTotalPage()) continue; $str .= '
  • getCurrentPage() == $i ? ' class="active"' : '').'>'.$i.'
  • '; } return $str; } public function getFullBar() { if (!$this->getTotalRecord()) { return ''; } $st = ($this->_currentPage - 1) * $this->_pageSize + 1; $et = $this->_currentPage * $this->_pageSize; $et = $et > $this->_totalRecord ? $this->_totalRecord : $et; return <<{$this->prevPage()}
  • {$this->firstPage()}
  • {$this->pageNumber(3)}
  • {$this->lastPage()}
  • {$this->nextPage()}
  • EOF; } public function getMiniBar() { if (!$this->getTotalRecord()) { return ''; } return <<{$this->getTotalRecord()} 件商品 {$this->getCurrentPage()}/{$this->getTotalPage()} {$this->prevPage()} {$this->nextPage()} EOF; } public function getInputBox() { return << EOF; } public function go($page) { switch ($page) { case 'first': $page = 1; break; case 'last': $page = $this->getTotalPage(); break; case 'next': $page = $this->getCurrentPage() >= $this->getTotalPage() ? $this->getCurrentPage() : $this->getCurrentPage()+1; break; case 'prev': $page = $this->getCurrentPage() <= 1 ? $this->getCurrentPage() : $this->getCurrentPage()-1; break; } if ($this->getAjaxFunc()) { return 'javascript:'.$this->getAjaxFunc().'('.$page.')"'; } else { return Suco_Controller_Router_Route_Abstract::decode(Suco_Application::instance()->getRouter() ->reverse('&page=' . ($page > 1 ? $page : ''))); } } }