相思资源网 Design By www.200059.com

php仿ZOL分页类代码

php仿ZOL分页类代码

php仿ZOL分页类代码
复制代码 代码如下:
<?php

/**
* 功能:分页类
* 作者:phpox
* 时间:Sat Jul 14 18:15:02 CST 2007
*/

defined('PHPOX') or die(header("HTTP/1.1 403 Not Forbidden"));

class page{
public $infocount;
public $pagecount;
public $items;
public $pageno;
public $start;
public $next;
public $prev;
public $maxpages;

public function __construct($infocount,$items,$pageno){
$this->infocount = $infocount;
$this->items = $items;
$this->pageno = $pageno;
$this->pagecount = $this->getpagecount();
$this->justpageno();
$this->start = $this->getstart();
$this->gotoprev();
$this->gotonext();
}

private function justpageno(){
if (emptyempty($this->pageno) || $this->pageno < 1){
$this->pageno = 1;
}
if ($this->pageno > $this->pagecount){
$this->pageno = $this->pagecount;
}
}

private function gotonext(){
$next = $this->pageno + 1;
if ($next > $this->pagecount){
$this->next = $this->pagecount;
}else {
$this->next = $next;
}

}

private function gotoprev(){
$prev = $this->pageno -1;
if ($prev < 1){
$this->prev = 1;
}else {
$this->prev = $prev;
}
}

private function getpagecount(){
return ceil($this->infocount / $this->items);
}

private function getstart(){
if ($this->pageno <= 1){
return 0;
}else {
return ($this->pageno - 1) * $this->items;
}
}

/**
* 样式0(php)
*/
public function showpage($ctlname,$actname,$args = null){
if ($args !== null){
if (is_array($args)){
$str = '&'.encode_url_args($args);
}
}
$out = '';
$out .= "每页显示{$this->items}条信息 ";
$out .= "当前页<strong><font color=\"#FF0000\">{$this->pageno}</font>/{$this->pagecount}</strong> ";
$out .= "共有{$this->infocount}条信息 ";
$out .= "<a href='?ctl={$ctlname}&act={$actname}&p=1$str'>首页</a> ";
$out .= "<a href='?ctl={$ctlname}&act={$actname}&p={$this->prev}$str'>上一页</a> ";
$out .= "<a href='?ctl={$ctlname}&act={$actname}&p={$this->next}$str'>下一页</a> ";
$out .= "<a href='?ctl={$ctlname}&act={$actname}&p={$this->pagecount}$str'>尾页</a> ";
$out .= "跳转到:";
$out .= "<select id=\"page\" name=\"page\" onchange=\"javascript:window.location='?ctl={$ctlname}&act={$actname}$str&p='+this.options[this.selectedIndex].value;\">\n";
$out .= " <option value=\"1\">请选择</option>\n";
for ($i = 1;$i <= $this->pagecount;$i++){
$out .= " <option value=\"$i\">第{$i}页</option>\n";
}
$out .= "</select>\n";
return $out;
}

/**
* 样式1(html)
*/
function htmlshowpage($path,$list,$film){
$out = '';
$out .= "每页显示{$this->items}条信息 ";
$out .= "当前页<strong><font color=\"#FF0000\">{$this->pageno}</font>/{$this->pagecount}</strong> ";
$out .= "共有{$this->infocount}条信息 ";
$out .= "<a href='{$path}$list/{$film}_1.html'>首页</a> ";
$out .= "<a href='{$path}$list/{$film}_{$this->prev}.html'>上一页</a> ";
$out .= "<a href='{$path}$list/{$film}_{$this->next}.html'>下一页</a> ";
$out .= "<a href='{$path}$list/{$film}_{$this->pagecount}.html'>尾页</a> ";
$out .= "跳转到:";
$out .= "<select id=\"page\" name=\"page\" onchange=\"javascript:window.location='{$path}html/$list/{$film}_'+this.options[this.selectedIndex].value +'.html'\">\n";
$out .= " <option value=\"1\">请选择</option>\n";
for ($i = 1;$i <= $this->pagecount;$i++){
$out .= " <option value=\"$i\">第{$i}页</option>\n";
}
$out .= "</select>\n";
return $out;
}

/**
* 样式2(discuz)
*/
function multi($mpurl,$page = 10) {

$multipage = '';
$mpurl .= strpos($mpurl, '?') !== false ? '&' : '?';
$realpages = 1;
if($this->infocount > $this->items) {
$offset = 2;

$realpages = @ceil($this->infocount / $this->items);
$pages = $this->maxpages && $this->maxpages < $realpages ? $this->maxpages : $realpages;

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

$multipage = ($this->pageno - $offset > 1 && $pages > $page ? '<a href="'.$mpurl.'page=1" class="first">1 ...</a>' : '').
($this->pageno > 1 ? '<a href="'.$mpurl.'page='.($this->pageno - 1).'" class="p_redirect"><<</a>' : '');
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $this->pageno ? '<a class="p_curpage"><strong>'.$i.'</strong></a>' :'<a href="'.$mpurl.'page='.$i.'" class="p_num">'.$i.'</a>';
}

$multipage .= ($this->pageno < $pages ? '<a href="'.$mpurl.'page='.($this->pageno + 1).'" class="p_redirect"></a>' : '').
($to < $pages ? '<a href="'.$mpurl.'page='.$pages.'" class="last">... '.$realpages.'</a>' : '').
($pages > $page ? '<kbd><input type="text" name="custompage" size="3" onkeydown="if(event.keyCode==13) {window.location=\''.$mpurl.'page=\'+this.value; return false;}" /></kbd>' : '');

$multipage = $multipage ? '<div class="p_bar"><a class="p_total"> '.$this->infocount.' </a><a class="p_pages"> '.$this->pageno.'/'.$pages.' </a>'.$multipage.'</div>' : '';
}
return $multipage;
}

/**
* 样式3(zol)
*/
public function zol($mpurl)
{
$mpurl .= strpos($mpurl, '?') !== false ? '&' : '?';
$code = '<div class="f22 mt10 hei14">';
$code .= '<div style="line-height:30px">第<font class="a_hong14b">'.$this->pageno.'</font><font class="a_hei14">/'.$this->pagecount.'</font>页 每页<font class="a_hei14">'.$this->items.'</font> 共<font class="a_hong14b">'.$this->infocount.'</font>款产品</div>';
$code .= '<table border="0" align="right" cellpadding="0" cellspacing="3">';
$code .= '<tr>';
if ($this->pageno == $this->prev)
{
$code .= "<td width='64' align='center' class='bd_hui huei14b'><a disabled='disabled' class='a_hui12b'><<上一页</a></td>";
}
else
{
$code .= "<td width='64' align='center' class='bd_lan a_lan14'><a href='{$mpurl}page={$this->prev}' class='a_lan12b'><<上一页</a></td>";
}
$i = 10 ;
$k = 1;
if ($this->pageno < 1)
{
$this->pageno = 1;
}
if ($this->pageno > $this->pagecount)
{
$this->pageno = $this->pagecount;
}
$s = $this->pageno-2;
if ($s <= 0)
{
$s = 1;
}
$e = $this->pageno+2;
if ($e < 5 )
{
$e = 5;
}
if ($e > $this->pagecount)
{
$e = $this->pagecount;
}
for ($j=$s;$j<=$e;$j++)
{
if ($this->pageno == $j)
{
$code .= '<td width="22" bgcolor="#2E6AB1" class="bei14" align="center">'.$j.'</td>';
}
else
{
$code .= "<td width='22' align='center' class='bd_lan a_lan14' onMouseOver=\"this.style.border='1px solid #2062A4'\" onMouseOut=\"this.style.border='1px solid #AACCEE'\" style=\"CURSOR: hand\" onClick=\"javascript:window.location=('{$mpurl}page={$j}')\">$j</td>";
}
}
if ($this->pageno == $this->pagecount)
{
$code .= "<td align='center' width='64' class='bd_hui huei14b'><a disabled='disabled' >下一页</a></td>";
}
else
{
$code .= "<td align='center' width='64' class='bd_lan lan14b'><a href='{$mpurl}page={$this->next}' class='a_lan12b'>下一页</a></td>";
}
$code .= '</tr>';
$code .= '</table>';
$code .= '</div>';
return $code;
}
}

标签:
php,分页类

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

评论“php仿ZOL分页类代码”

暂无php仿ZOL分页类代码的评论...

P70系列延期,华为新旗舰将在下月发布

3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。

而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?

根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。