时间:2021-07-01 10:21:17 帮助过:12人阅读
第一种老想法的代码实现:
代码如下:
/**
* 一步步的来
*
* @desc
*
* @Access protected
* @Return void
* @Exception none
*/
protected function _getShowPageNumberTwo()
{
if($this->_curPage < $this->_totalShowPages) {
for($page = 1; $page < $this->_totalShowPages; $page ++) {
$pageHtml .= $this->_getPageHtml($page);
}
$pageHtml .= $this->_getMorePageHtml($this->_totalShowPages);
$pageHtml .= $this->_getNormalPageHtml($this->_totalPages);
} else {
$pageHtml .= $this->_getNormalPageHtml(1);
if($this->_curPage == $this->_totalShowPages) {
$pageHtml .= $this->_getMorePageHtml(1);
} else {
$pageHtml .= $this->_getMorePageHtml($this->_curPage - $this->_totalShowPages);
}
if($this->_curPage + $this->_totalShowPages >= $this->_totalPages) {
for($page = $this->_totalPages - $this->_totalShowPages; $page < = $this->_totalPages; $page ++) {
$pageHtml .= $this->_getPageHtml($page);
}
} else {
$start = $this->_curPage - 2;
$end = $this->_curPage + $this->_totalShowPages - 2;
for($page = $start; $page < $end; $page ++) {
$pageHtml .= $this->_getPageHtml($page);
}
$pageHtml .= $this->_getMorePageHtml($this->_curPage + $this->_totalShowPages - 2);
$pageHtml .= $this->_getNormalPageHtml($this->_totalPages);
}
}
return $pageHtml;
}