概述
复制代码 代码如下:
<?php
/*
[Discuz!] (C)2001-2006 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$RCSfile: global.func.php,v $
$Revision: 1.83.2.7 $
$Date: 2006/10/27 08:08:18 $
*/
function multi($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 ? '<a class="p_redirect" href="'.$mpurl.'page=1">|?</a>' : '').
($curpage > 1 ? '<a class="p_redirect" href="'.$mpurl.'page='.($curpage - 1).'">??</a>' : '');
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $curpage ? '<a class="p_curpage">'.$i.'</a>' :
'<a href="'.$mpurl.'page='.$i.'" class="p_num">'.$i.'</a>';
}
$multipage .= ($curpage < $pages ? '<a class="p_redirect" href="'.$mpurl.'page='.($curpage + 1).'">??</a>' : '').
($to < $pages ? '<a class="p_redirect" href="'.$mpurl.'page='.$pages.'">?|</a>' : '').
($curpage == $maxpages ? '<a class="p_redirect" href="misc.php?action=maxpages&pages='.$maxpages.'">??</a>' : '').
($pages > $page ? '<a class="p_pages" style="padding: 0px"><input class="p_input" type="text" name="custompage" onKeyDown="if(event.keyCode==13) {window.location=\''.$mpurl.'page=\'+this.value; return false;}"></a>' : '');
$multipage = $multipage ? '<div class="p_bar"><a class="p_total"> '.$num.' </a><a class="p_pages"> '.$curpage.'/'.$realpages.' </a>'.$multipage.'</div>' : '';
}
return $multipage;
}
?>
/*
[Discuz!] (C)2001-2006 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$RCSfile: global.func.php,v $
$Revision: 1.83.2.7 $
$Date: 2006/10/27 08:08:18 $
*/
function multi($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 ? '<a class="p_redirect" href="'.$mpurl.'page=1">|?</a>' : '').
($curpage > 1 ? '<a class="p_redirect" href="'.$mpurl.'page='.($curpage - 1).'">??</a>' : '');
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $curpage ? '<a class="p_curpage">'.$i.'</a>' :
'<a href="'.$mpurl.'page='.$i.'" class="p_num">'.$i.'</a>';
}
$multipage .= ($curpage < $pages ? '<a class="p_redirect" href="'.$mpurl.'page='.($curpage + 1).'">??</a>' : '').
($to < $pages ? '<a class="p_redirect" href="'.$mpurl.'page='.$pages.'">?|</a>' : '').
($curpage == $maxpages ? '<a class="p_redirect" href="misc.php?action=maxpages&pages='.$maxpages.'">??</a>' : '').
($pages > $page ? '<a class="p_pages" style="padding: 0px"><input class="p_input" type="text" name="custompage" onKeyDown="if(event.keyCode==13) {window.location=\''.$mpurl.'page=\'+this.value; return false;}"></a>' : '');
$multipage = $multipage ? '<div class="p_bar"><a class="p_total"> '.$num.' </a><a class="p_pages"> '.$curpage.'/'.$realpages.' </a>'.$multipage.'</div>' : '';
}
return $multipage;
}
?>
最后
以上就是幽默大炮为你收集整理的DISCUZ 分页代码的全部内容,希望文章能够帮你解决DISCUZ 分页代码所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复