Code:
Copy Code code as follows:
/**
* Think of the middle as a fixed-length ruler that can slide
*
* Treat $this->_totalshowpages as a fixed-length ruler that can slide
* Then $this->_totalpages is a block of a given length, a ruler in this
* Slide on THE block. Two kinds of situation:
* 1. The ruler length is larger than the length of the block, then directly output all the page numbers;
* 2. The ruler length is less than the length of the block, then only use to find output this ruler length page
* The starting point of the number-$start, $end;
* @Access protected
* @Return void
* @Exception None
*/
protected function _getshowpagenumber ()
{
$pageHtml = ';
Find $start.
if ($this->_curpage-2 > 1) {
$start = $this->_curpage-2;
} else {
$start = 1;
}
Find $end.
$end = $start + $this->_totalshowpages;
if ($end >= $this->_totalpages) {
$end = $this->_totalpages;
$start = $end-$this->_totalshowpages; Ensure the length of page display is $this->_totalshowpages
}
if ($start!= 1) {
$pageHtml. = $this->_getpagehtml (1);
$preMore = $this->_curpage-$this->_totalshowpages;
if ($preMore < 1) {
$preMore = 1;
}
$pageHtml. = $this->_getmorepagehtml ($preMore);
}
for ($page = $start; $page < $end; $page + +) {
$pageHtml. = $this->_getpagehtml ($page);
}
if ($end!= $this->_totalpages) {
$pageHtml. = $this->_getmorepagehtml ($end);
}
$pageHtml. = $this->_getnormalpagehtml ($this->_totalpages);
return $pageHtml;
}
The first old idea of the code implementation:
Copy Code code as follows:
/**
* Come one step at a step
*
* @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;
}