DISCUZ 分页代码

2018-09-07 12:01

阅读:579

  复制代码 代码如下:<?php
/*
[Discuz!](C)2001-2006ComsenzInc.
ThisisNOTafreeware,useissubjecttolicenseterms

$RCSfile:global.func.php,v$
$Revision:1.83.2.7$
$Date:2006/10/2708:08:18$
*/

functionmulti($num,$perpage,$curpage,$mpurl,$maxpages=0){
$multipage=;
$mpurl.=strpos($mpurl,?)?&:?;
if($num>$perpage){
$page=10;
$offset=2;

$realpages=@ceil($num/$perpage);
$pages=$maxpages&&$maxpages<$realpages?$maxpages:$realpages;

if($page>$pages){
$from=1;
$to=$pages;
}else{
$from=$curpage-$offset;
$to=$from+$page-1;
if($from<1){
$to=$curpage+1-$from;
$from=1;
if($to-$from<$page){
$to=$page;
}
}elseif($to>$pages){
$from=$pages-$page+1;
$to=$pages;
}
}

$multipage=($curpage-$offset>1&&$pages>$page?<aclass=p_redirecthref=.$mpurl.page=1>?</a>:).
($curpage>1?<aclass=p_redirecthref=.$mpurl.page=.($curpage-1).>??</a>:);
for($i=$from;$i<=$to;$i++){
$multipage.=$i==$curpage?<aclass=p_curpage>.$i.</a>:
<ahref=.$mpurl.page=.$i.class=p_num>.$i.</a>;
}

$multipage.=($curpage<$pages?<aclass=p_redirecthref=.$mpurl.page=.($curpage+1).>??</a>:).
($to<$pages?<aclass=p_redirecthref=.$mpurl.page=.$pages.>?</a>:).
($curpage==$maxpages?<aclass=p_redirecthref=misc.php?action=maxpages&pages=.$maxpages.>??</a>:).
($pages>$page?<aclass=p_pagesstyle=padding:0px><inputclass=p_inputtype=textname=custompageonKeyDown=if(event.keyCode==13){window.location=\.$mpurl.page=\+this.value;returnfalse;}></a>:);

$multipage=$multipage?<divclass=p_bar><aclass=p_total>.$num.</a><aclass=p_pages>.$curpage./.$realpages.</a>.$multipage.</div>:;
}
return$multipage;
}
?>


评论


亲,登录后才可以留言!