Code:
Copy CodeThe code is as follows:
/**
* Think of the middle as a fixed length ruler that can slide
*
* Think of $this->_totalshowpages as a fixed length ruler that can slide,
* Then $this->_totalpages is a given length of wood, the ruler in this
* Slide on the wooden block. Two types of situations:
* 1. Ruler length is greater than the length of the block, then directly output all the page numbers;
* 2. Ruler length is less than the length of the block, then only find the output of 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 that the page display length 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 code implementation of the first old idea:
Copy CodeThe code is as follows:
/**
* Step by 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;
}