/**
*生成分页
*
*@returnstring
*/
publicfunctiongeneratePages(){
$subPageCss2Str='';
$isShow=false;
if($this->totalPageNum==1){ //只有一页时
if($this->isShowForSimplePage){
$isShow=true;
}
}else{
$isShow=true;
}
if($isShow){
if($this->currentPage>1){
$prewPageUrl=
$this->subPageLink.$this->linkSymbol.($this->currentPage-1);
if($this->isShowFirstLast){
$firstPageUrl=$this->subPageLink.$this->linkSymbol."1";
$subPageCss2Str.='<ahref="'.$firstPageUrl.'"
class="'.$this->pageCss.'"
style="'.$this->pageStyle.'">'.$this->firstPageText.'</a>';
}
$subPageCss2Str.='<ahref="'.$prewPageUrl.'"
class="'.$this->pageCss.'"
style="'.$this->pageStyle.'">'.$this->prePageText.'</a>';
}
$a=$this->construct_num_Page();
for($i=0;$i<count($a);$i++){
$s=$a[$i];
if($s==$this->currentPage){
$subPageCss2Str.='<ahref="#"
class="'.$this->curPageCss.'"
style="'.$this->curPageStyle.'">'.$s.'</a>';
}else{
$url=$this->subPageLink.$this->linkSymbol.$s;
$subPageCss2Str.='<ahref="'.$url.'"
class="'.$this->pageCss.'"style="'.$this->pageStyle.'">'.$s.'</a>';
}
}
if($this->currentPage<$this->totalPageNum){
$nextPageUrl=
$this->subPageLink.$this->linkSymbol.($this->currentPage+1);
$subPageCss2Str.='<ahref="'.$nextPageUrl.'"
class="'.$this->pageCss.'"
style="'.$this->pageStyle.'">'.$this->nextPageText.'</a>';
if($this->isShowFirstLast){
$lastPageUrl=
$this->subPageLink.$this->linkSymbol.$this->totalPageNum;
$subPageCss2Str.='<ahref="'.$lastPageUrl.'"
class="'.$this->pageCss.'"
style="'.$this->pageStyle.'">'.$this->lastPageText.'</a>';
}
}
}
return$subPageCss2Str;
}//EndofgeneratePages()Method
/**
*用来给建立分页的数组初始化的函数。
*
*@returnarray
*/
privatefunctioninitArray(){
for($i=0;$i<$this->showPageNum;$i++){
$this->arrPage[$i]=$i;
}
return$this->arrPage;
}//EndofinitArray()Method
/**
*用来构造显示的条目
*即:[1][2][3][4][5][6][7][8][9][10]
*
*@returnarray
*/
privatefunctionconstruct_num_Page(){
if($this->totalPageNum<$this->showPageNum){
$currentArray=array();
for($i=0;$i<$this->totalPageNum;$i++){
$currentArray[$i]=$i+1;
}
}else{
$currentArray=$this->initArray();
$curArrayLen=count($currentArray);
if($this->currentPage<=$this->curIndexPage){
for($i=0;$i<$curArrayLen;$i++){
$currentArray[$i]=$i+1;
}
}elseif(($this->currentPage<=$this->totalPageNum)&&
($this->currentPage>($this->totalPageNum-$this->showPageNum+
1))){
//构造最后的分页栏,353637383940[下一页][最后一页]总页数为40
for($i=0;$i<$curArrayLen;$i++){
$currentArray[$i]=$this->totalPageNum-
$this->showPageNum+1+$i;
}
}else{
for($i=0;$i<$curArrayLen;$i++){
$currentArray[$i]=$this->currentPage-
$this->curIndexPage+1+$i;
}
}
}
return$currentArray;
}//Endofconstruct_num_Page()Method
}//EndofPagesClass
?>