无为清净楼资源网 Design By www.qnjia.com

复制代码 代码如下:
<?php
/**

作者:潇湘博客

时间:
2009-11-26

php技术群:
37304662

使用方法:
include_once'Pager.class.php';
$pager=new Pager();
if(isset($_GET['page']))
$pager->setCurrentPage($_GET['page']);
else
$pager->setCurrentPage(1);

$pager->setRecorbTotal(1000);
$pager->setBaseUri("page.php?");
echo $pager->execute();

**/
class Pager{
/**
*int总页数
**/
protected $pageTotal;
/**
*int上一页
**/
protected $previous;
/**
*int下一页
**/
protected $next;
/**
*int中间页起始序号
**/
protected $startPage;
/**
*int中间页终止序号
**/
protected $endPage;
/**
*int记录总数
**/
protected $recorbTotal;
/**
*int每页显示记录数
**/
protected $pageSize;
/**
*int当前显示页
**/
protected $currentPage;
/**
*string基url地址
**/
protected $baseUri;

/**
*@returnstring获取基url地址
*/
public function getBaseUri(){
return$this->baseUri;
}

/**
*@returnint获取当前显示页
*/
public function getCurrentPage(){
return $this->currentPage;
}

/**
*@returnint获取每页显示记录数
*/
public function getPageSize(){
return $this->pageSize;
}

/**
*@returnint获取记录总数
*/
public function getRecorbTotal(){
return$this->recorbTotal;
}

/**
*@paramstring$baseUri设置基url地址
*/
public function setBaseUri($baseUri){
$this->baseUri=$baseUri;
}

/**
*@paramint$currentPage设置当前显示页
*/
public function setCurrentPage($currentPage){
$this->currentPage=$currentPage;
}

/**
*@paramint$pageSize设置每页显示记录数
*/
public function setPageSize($pageSize){
$this->pageSize=$pageSize;
}

/**
*@paramint$recorbTotal设置获取记录总数
*/
public function setRecorbTotal($recorbTotal){
$this->recorbTotal=$recorbTotal;
}

/**
*构造函数
**/
public function __construct()
{
$this->pageTotal=0;
$this->previous=0;
$this->next=0;
$this->startPage=0;
$this->endPage=0;

$this->pageSize=20;
$this->currentPage=0;
}

/**
*分页算法
**/
private function arithmetic(){
if($this->currentPage<1)
$this->currentPage=1;

$this->pageTotal=floor($this->recorbTotal/$this->pageSize)+($this->recorbTotal%$this->pageSize>0?1:0);

if($this->currentPage>1&&$this->currentPage>$this->pageTotal)
header('location:'.$this->baseUri.'page='.$this->pageTotal);

$this->next=$this->currentPage+1;
$this->previous=$this->currentPage-1;

$this->startPage=($this->currentPage+5)>$this->pageTotal?$this->pageTotal-10:$this->currentPage-5;
$this->endPage=$this->currentPage<5?11:$this->currentPage+5;

if($this->startPage<1)
$this->startPage=1;

if($this->pageTotal<$this->endPage)
$this->endPage=$this->pageTotal;
}

/**
*分页样式
**/


protected function pageStyle(){
$result="共".$this->pageTotal."页";

if($this->currentPage>1)
$result.="<a href=\"".$this->baseUri."page=1\"><font style=\"font-family:webdings\">第1页</font></a> <a href=\"".$this->baseUri."page=$this->previous\"><fontstyle=\"font-family:webdings\">前一页</font></a>";
else
$result.="<font style=\"font-family:webdings\">第1页</font> <font style=\"font-family:webdings\"></font>";

for($i=$this->startPage;$i<=$this->endPage;$i++){
if($this->currentPage==$i)
$result.="<font color=\"#ff0000\">$i</font>";
else
$result.=" <a href=\"".$this->baseUri."page=$i\">$i</a> ";
}

if($this->currentPage!=$this->pageTotal){
$result.="<a href=\"".$this->baseUri."page=$this->next\"><font style=\"font-family:webdings\">后一页</font></a> ";
$result.="<a href=\"".$this->baseUri."page=$this->pageTotal\"><font style=\"font-family:webdings\">最后1页</font></a>";
}else{
$result.="<font style=\"font-family:webdings\">最后1页</font> <font style=\"font-family:webdings\"></font>";
}
return $result;
}



/**
*执行分页
**/
public function execute(){
if($this->baseUri!=""&&$this->recorbTotal==0)
return"";
$this->arithmetic();
return $this->pageStyle();
}
}
?>

标签:
php,分页

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。