PHP 模倣 ZOL ページング クラス コード_PHP チュートリアル

WBOY
リリース: 2016-07-21 15:49:43
オリジナル
5705 人が閲覧しました

大小: 3.86 K
尺寸: 289 x 42
浏览: 6 次
点击打开新窗口浏览全图

大小: 3.31 K
尺寸: 215 x 52
浏览: 1 次
点击打开新窗口浏览全图

大小: 5.56 K
尺寸: 500 x 46
浏览: 11 次
点击打开新窗口浏览全图

コードをコピーします コードは次のとおりです:


/**
* 機能: ページネーション クラス
* 著者: phpox
* 時刻: Sat Jul 14 18:15:02 CST 2007
*/

define('PHPOX') または die(header("HTTP/1.1 403 Not Forbidden"));

クラス ページ{
public $infocount;
公開 $pagecount;
公開 $items;
公開 $pageno;
パブリック $start;
パブリック$next;
公開 $prev;
公開 $maxpages;

パブリック関数 __construct($infocount,$items,$pageno){
$this->infocount = $infocount;
$this->items = $items;
$this->ページノ = $ページノ;
$this->pagecount = $this->getpagecount();
$this->justpageno();
$this->start = $this->getstart();
$this->gotorev();
$this->gotonext();
}

プライベート関数 justpageno(){
if (emptyempty($this->pageno) || $this->pageno $this->pageno = 1;
}
if ($this->pageno > $this->pagecount){
$this->pageno = $this->pagecount;
}
}

プライベート関数 gotonext(){
$next = $this->pageno + 1;
if ($next > $this->pagecount){
$this->next = $this->pagecount;
}else {
$this->next = $next;
}

}

プライベート関数 gotoprev(){
$prev = $this->pageno -1;
if ($prev $this->prev = 1;
}else {
$this->prev = $prev;
}
}

プライベート関数 getpagecount(){
return ceil($this->infocount / $this->items);
}

プライベート関数 getstart(){
if ($this->pageno 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 .= "現在の页{$this->ページ番号}/{$this->ページ数} ";
$out .= "共有{$this->infocount}条情報 ";
$out .= "首页 ";
$out .= "上一页 ";
$out .= "下一页 ";
$out .= "尾页 ";
$out .= "跳转到:";
$out .= "n";
$out を返す;
}

/**
* スタイル 1(html)
*/
function htmlshowpage($path,$list,$film){
$out = '';
$out .= "每页显示{$this->items}条情報 ";
$out .= "現在の页{$this->ページ番号}/{$this->ページ数} ";
$out .= "共有{$this->infocount}条情報 ";
$out .= "首页 ";
$out .= "上一页 ";
$out .= "下一页 ";
$out .= "尾页 ";
$out .= "跳转到:";
$out .= "n";
$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 ? '1 ...' : '').
($this->pageno > 1 ? '<<' : '');
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $this->pageno ? ''.$i.'' :''.$i.'';
}

$multipage .= ($this->pageno < $pages ? '>>' : '').
($to < $pages ? '... '.$realpages.'' : '').
($pages > $page ? '' : '');

$multipage = $multipage ? '' : '';
}
return $multipage;
}

/**
* 样式3(zol)
*/
public function zol($mpurl)
{
$mpurl .= strpos($mpurl, '?') !== false ? '&' : '?';
$code = '
';
$code .= '
'.$this->pageno.'/'.$this->pagecount.'页 每页'.$this->items.''.$this->infocount.'款产品
';
$code .= '';
$code .= '';
if ($this->pageno == $this->prev)
{
$code .= "";
}
else
{
$code .= "";
}
$i = 10 ;
$k = 1;
if ($this->pageno {
$this->pageno = 1;
}
if ($this->pageno > $this->pagecount)
{
$this->pageno = $this->pagecount;
}
$s = $this->pageno-2;
if ($s {
$s = 1;
}
$e = $this->pageno+2;
if ($e {
$e = 5;
}
if ($e > $this->pagecount)
{
$e = $this->pagecount;
}
for ($j=$s;$j<=$e;$j++)
{
if ($this->pageno == $j)
{
$code .= '';
}
else
{
$code .= "";
}
else
{
$code .= "";
}
$code .= '';
$code .= '
<<上一页<<上一页'.$j.'$j";
}
}
if ($this->pageno == $this->pagecount)
{
$code .= "
下一页>>下一页>>
';
$code .= '
';
$code を返します;
}
}

www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/319499.html技術記事复制代码 代码如下: ?php /*** 機能: ページネーション クラス * 著者: phpox * 時刻: Sat Jul 14 18:15:02 CST 2007*/ 定義('PHPOX') または die(header("HTTP/1.1 403 Not Forbidden"));クラス...
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!