您好,欢迎访问一九零五行业门户网

分页类——尾部页码导航

分页类——尾部页码导航 currentpage=$currentpage; $this->totalpage=$totalpage; if($this->totalpage if($this->currentpage==1){//当前页是第一页 $str='上一页'.$this->currenttag(); for ($i = 2; $i totalpage; $i++) { $str=$str.$this->commontag($i); } $str=$str.$this->next(); }elseif ($this->currentpage==$this->totalpage){//已跳至最后一页 $str=$this->up(); for ($i = 1; $i totalpage-1; $i++) { $str=$str.$this->commontag($i); } $str=$str.$this->currenttag(); $str=$str.$this->next(); }else{ $str=$this->up(); for($i=1; $icurrentpage; $i++){ $str=$str.$this->commontag($i); } $str=$str.$this->currenttag();//生成当前页标签 for ($i = $this->currentpage+1; $i totalpage; $i++) { $str=$str.$this->commontag($i); } $str=$str.$this->next(); } }elseif ($this->totalpage>10){//页码大于10 if($this->currentpage==1){//8+2 $str='上一页'.$this->currenttag(); for ($i = 2; $i $str=$str.$this->commontag($i); } $str=$str.'...';//添加省略号 $str=$str.$this->commontag($this->totalpage-1); $str=$str.$this->commontag($this->totalpage); }elseif($this->currentpage==$this->totalpage) {//当前为最后一页 $str=$this->up(); $str=$str.$this->commontag(1); $str=$str.'...';//添加省略号 for ($i = $this->totalpage-6; $i totalpage; $i++) { $str=$str.$this->commontag($i); } $str=$str.$this->currenttag(); $str=$str.$this->next(); }else { if ($this->currentpage $str=$this->up(); for ($i = 1; $i currentpage; $i++) { $str=$str.$this->commontag($i); } $str=$str.$this->currenttag(); for ($i = $this->currentpage+1; $i $str=$str.$this->commontag($i); } $str=$str.'...';//添加省略号 $str=$str.$this->commontag($this->totalpage); $str=$str.$this->next(); }else { if ($this->currentpage>=$this->totalpage-4) { $str=$this->up(); $str=$str.$this->commontag(1); $str=$str.'...';//添加省略号 for ($i = $this->totalpage-6; $i currentpage; $i++) { $str=$str.$this->commontag($i); } $str=$str.$this->currenttag(); for ($i = $this->currentpage+1; $i totalpage; $i++) { $str=$str.$this->commontag($i); } $str=$str.$this->next(); }elseif ($this->currentpagetotalpage-4){//1+5+1 $str=$this->up(); $str=$str.$this->commontag(1); $str=$str.'...';//添加省略号 $str=$str.$this->commontag($this->currentpage-2); $str=$str.$this->commontag($this->currentpage-1); $str=$str.$this->currenttag(); $str=$str.$this->commontag($this->currentpage+1); $str=$str.$this->commontag($this->currentpage+2); $str=$str.'...';//添加省略号 $str=$str.$this->commontag($this->totalpage); $str=$str.$this->next(); } }; } }elseif ($this->totalpage throw new exception(页面不可能小于1); } return $str; } /** * 一般标签 * @param int $param 页码 * @return string */ function commontag($param) { return ''.$param.''; } /** * 生成当前页标签 * @param int $param 页码 * @return string */ function currenttag() { return ''.$this->currentpage.''; } /** * 生成下一页标签 * @param int $param 下一页页码 * @return string */ function next() { if ($this->currentpage==$this->totalpage) { return '下一页'; } return 'currentpage+1).'>下一页'; } /** * 生成上一页标签 * @param int $param 上一页页码 * @return string */ function up() { if ($this->currentpage==1){ return '上一页'; }else{ return 'currentpage-1).'>上一页'; } } /** * 实例化cmttail, * 功能:生成comment的尾部分页导航 * @param string $currentpage 当前页码 * @param string $totalpage 总页数 * @return string 返回html标签字符串 */ static function go($currentpage, $totalpage) { $p=new cmttail(); return $p->__do($currentpage, $totalpage); }}
复制代码
其它类似信息

推荐信息