代码如下 | 复制代码 |
class page{ var $page_name="page"; var $next_page='下一页'; var $pre_page='上一页'; var $first_page='首页'; var $last_page='尾页'; var $pre_bar='<<'; var $next_bar='>>'; var $format_left=''; var $format_right=''; var $pagebarnum=5; var $totalpage=0; var $nowindex=1; var $url=""; var $offset=0; var $rewrite = array();
{ if(is_array($array)){ if(!array_key_exists('total',$array))$this->error(__function__,'need a param of total'); $total=intval($array['total']); $perpage=(array_key_exists('perpage',$array))?intval($array['perpage']):10; $nowindex=(array_key_exists('nowindex',$array))?intval($array['nowindex']):''; $url=(array_key_exists('url',$array))?$array['url']:''; $action = (array_key_exists('action', $array)) ? $array['action'] : ''; }else{ $total=$array; $perpage=10; $nowindex=''; $url=''; $action = ''; } if((!is_int($total))||($total<0))$this->error(__function__,$total.' is not a positive integer!'); if((!is_int($perpage))||($perpage<=0))$this->error(__function__,$perpage.' is not a positive integer!'); if(!empty($array['page_name']))$this->set('page_name',$array['page_name']); $this->_set_nowindex($nowindex); $this->_set_url($url); $this->totalpage=ceil($total/$perpage); $this->offset=($this->nowindex-1)*$perpage; $this->action = $action; function set($var,$value) if(in_array($var,get_object_vars($this))) $this->$var=$value; else { $this->error(__function__,$var." does not belong to pb_page!"); } } function next_page($style=''){ function pre_page($style=''){ function first_page($style=''){ function last_page($style=''){ return ''.$this->last_page.''; } return $this->_get_link($this->_get_url($this->totalpage),$this->last_page,$style); }
{ $plus=ceil($this->pagebarnum/2); if($this->pagebarnum-$plus+$this->nowindex>$this->totalpage)$plus=($this->pagebarnum-$this->totalpage+$this->nowindex); $begin=$this->nowindex-$plus+1; $begin=($begin>=1)?$begin:1; $return=''; for($i=$begin;$i<$begin+$this->pagebarnum;$i++) { if($i<=$this->totalpage){ if($i!=$this->nowindex) $return.=$this->_get_text($this->_get_link($this->_get_url($i),$i,$style)); else $return.=$this->_get_text(''.$i.''); }else{ break; } $return.=" "; } unset($begin); return $return; } /** * 获取显示跳转按钮的代码 * * @return string */ function select() { $return=' for($i=1;$i<=$this->totalpage;$i++) { if($i==$this->nowindex){ $return.=''; }else{ $return.=''; } } unset($i);
return $return; }
/** * 获取mysql教程 语句中limit需要的值 * * @return string */ function offset() { return $this->offset; }
/** * 控制分页显示风格(你可以增加相应的风格) * * @param int $mode * @return string */ function show($mode=1) { switch ($mode) { case '1': $this->next_page='下一页'; $this->pre_page='上一页'; return $this->pre_page().$this->nowbar().$this->next_page().'第'.$this->select().'页'; break; case '2': $this->next_page='下一页'; $this->pre_page='上一页'; $this->first_page='首页'; $this->last_page='尾页'; return $this->first_page().$this->pre_page().'[第'.$this->nowindex.'页]'.$this->next_page().$this->last_page().'第'.$this->select().'页'; break; case '3': $this->next_page='下一页'; $this->pre_page='上一页'; $this->first_page='首页'; $this->last_page='尾页'; return $this->first_page("page_box")."".$this->pre_page("page_box")."".$this->nowbar("page_box_a","page_box_b")."".$this->next_page("page_box")."".$this->last_page("page_box").""; break; case '4': $this->next_page='下一页'; $this->pre_page='上一页'; return $this->pre_page().$this->nowbar().$this->next_page(); break; case '5': return $this->pre_bar().$this->pre_page().$this->nowbar().$this->next_page().$this->next_bar(); break; }
} function _set_url($url="") { if(!empty($url)){ $this->url=$url.((stristr($url,'?'))?'&':'?').$this->page_name."="; }else{ if(empty($_server['query_string'])){ $this->url=$_server['request_uri']."?".$this->page_name."="; }else{ if(stristr($_server['query_string'],$this->page_name.'=')){ $this->url=str_replace($this->page_name.'='.$this->nowindex,'',$_server['request_uri']); $last=$this->url[strlen($this->url)-1]; if($last=='?'||$last=='&'){ $this->url.=$this->page_name."="; }else{ $this->url.='&'.$this->page_name."="; } }else{ $this->url=$_server['request_uri'].'&'.$this->page_name.'='; } } } }
{ if(empty($nowindex)){ if(isset($_get[$this->page_name])){ $this->nowindex=intval($_get[$this->page_name]); } }else{ $this->nowindex=intval($nowindex); } } function _get_url($pageno=1) } function _get_text($str) { return $this->format_left.$str.$this->format_right; } function _get_link($url,$text,$style=''){ $style=(empty($style))?'':'class="'.$style.'"'; return ''.$text.''; }
{ die('error in file '.__file__.' ,function '.$function.'() :'.$errormsg); } } |
我的博物馆故事 官方安卓版v1.61.2
我的博物馆故事是一款以消除为主题的经营养成类手游,在这里玩家
专业模拟飞行10 手机版v12.2.4
专业模拟飞行10安卓版是一款飞行休闲手游,顶尖的物理飞行引擎
动物起义战斗模拟器二琳同款 最新版v4.1.1
动物起义战斗模拟器是一个非常有趣的模拟类游戏,玩家可以召唤各
迷你世界七周年 安卓手机版v1.43.0
迷你世界7周年是一款由《迷你世界》官方推出的庆祝特别版本,在
劫后公司无限资源版 v1.0.5.1
劫后公司内置菜单版是游戏的破解版本,在该版本中为玩家提供了内