php google 風格分頁代碼
public function showCtrlPanel_g($halfPer = 5) {
$re = '<div class="pageMore">
<ul>
<li><span>'.$this->lineCount.'條</span></li>
<li><span>'.$this->currentPage.'/'.$this->pageCount.'頁</span></li>';
if($this->currentPage-$halfPer >1){
$re .= '<li><a href="'.$this->fileName.'pageno=1"><span>1</span></a></li>';
if($this->currentPage-$halfPer*2 >1){
$re .= '<li><a href="'.$this->fileName.'pageno='.($this->currentPage-$halfPer*2).'"><span>...</span></a></li>';
}else{
$re .= '<li><a href="'.$this->fileName.'pageno=1"><span>...</span></a></li>';
}
}
for ( $i = $this->currentPage - $halfPer,$i > 1 || $i = 1 , $j = $this->currentPage + $halfPer, $j < $this->pageCount || $j = $this->pageCount;$i <= $j ;$i++ )
{
$re .= $i == $this->currentPage
? '<li class="linkOn"><a href="'.$this->fileName.'pageno='.$i.'"><span>'.$i.'</span></a></li>'." "
: '<li><a href="'.$this->fileName.'pageno='.$i.'"><span>'.$i.'</span></a></li>'." ";
}
if($this->currentPage+$halfPer < $this->pageCount){
if($this->currentPage+$halfPer*2 < $this->pageCount){
$re .= '<li><a href="'.$this->fileName.'pageno='.($this->currentPage+$halfPer*2).'"><span>...</span></a></li>';
}else{
$re .= '<li><a href="'.$this->fileName.'pageno='.$this->pageCount.'"><span>...</span></a></li>';
}
$re .= '<li><a href="'.$this->fileName.'pageno='.$this->pageCount.'"><span>'.$this->pageCount.'</span></a></li>';
}
$re .= '
</ul>
</div>';
return $re;
}