class My_Lib_page{
//当前页
var $page = 1;
//每页显示条数
var $size = 20;
//总记录数
var $count;
//每栏显示条数
var $lun = 10;
//参数绑订
var $param;
//跳转
var $run;
//name=admin&pwd=2132&sex=1
//$_GET['name'] = admin;
private function setParam(){
$param = $this->param;
unset($param['page']);
if(is_array($param) && !empty($param)){
foreach($param as $key=>$value){
$data[] = $key."/".$value;
}
$this->url = implode("/",$data);
$this->param = $this->url;
$this->url = "/".$this->url;
}else{
if(!empty($param)){
$this->url = $param;
$this->param = $this->url;
$this->url = "/".$this->url;
}
}
}
function pageDate(){
$this->setParam();
$num = ceil($this->lun/2);
$this->page = intval($this->page);
$this->page = $this->page page;
$cpage['countPage'] = ceil($this->count/$this->size); //总页数
$cpage['page'] = $this->page > $cpage['countPage'] ? $cpage['countPage']:$this->page ;
//当前页
//显示总数
$cpage['lun'] = $cpage['countPage'] lun ? $cpage['countPage'] : $this->lun;
//开始页码
$cpage['start'] = $this->page > $num-1 ? $this->page-$num+1 : 1;
$cpage['start'] = ($cpage['start']+$cpage['lun'])>=$cpage['countPage'] ? $cpage['countPage']-$cpage['lun']+1 : $cpage['start'];
//参数显示
$cpage['url'] = $this->url;
//控制跳转
$cpage['run'] = $this->run ? 1 : 0;
$cpage['param'] = is_array($this->param) ? '': "?".$this->param;
return $cpage;
}
}
/*include "../inc/smarty.php";
$cp = new page;
empty($_REQUEST['page']) || $cp->page = $_REQUEST['page'];
$cp->count = 70000;
$cp->param = $_GET;
$cp->size = 100;
$cp->lun = 7;
$cp->run = true;
$data = $cp->pageDate();
$smarty->assign("page",$data);
$smarty->display("cpage.html");
*/
?>