検索
ホームページphp教程php手册PHP 模倣 ZOL ページング クラス コード

PHP 模倣 ZOL ページング クラス コード

Jun 13, 2016 pm 12:26 PM
cphpコード著者ページネーション関数コピー時間親切


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



/**
* 関数: ページネーション クラス
* 作成者: 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->pageno = $pageno;
$this->pagecount = $this->getpagecount();
$this->justpageno();
$this->start = $this->getstart();
$this->gotoprev();
$this->gotonext();
}

プライベート関数 justpageno(){
if (emptyempty($this->pageno) || $this->pageno $this-> ;ページノ = 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 maxpages : $realpages;

if($page > $pages) {
$from = 1;
$to = $pages;
} else {
$from = $this->pageno - $offset;
$to = $from + $page - 1;
if($from $to = $this->pageno + 1 - $from;
$from = 1;
if($to - $from $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 $multipage .= $i == $this->pageno ? '
'.$i.'' :''.$i.'';
}

$multipage .= ($this->pageno pageno + 1).'" class="p_redirect">>>' : '').
($to ... '.$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->ページ 2;
if ($e {
$e = 5;
}
if ($e > $this->pagecount)
{
$e = $this->pagecount;
}
for ($j=$s;$j{
if ($this->pageno == $j)
{
$code .= '';
}
else
{
$code .= "";
}
}
if ($this->pageno == $this->pagecount)
{
$code .= "";
}
else
{
$code .= "";
}
$code .= '';
$code .= '
'.$j.'$j下一页>>下一页>>
';
$code .= '
';
$code を返します;
}
}

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

mPDF

mPDF

mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser は、オンライン試験を安全に受験するための安全なブラウザ環境です。このソフトウェアは、あらゆるコンピュータを安全なワークステーションに変えます。あらゆるユーティリティへのアクセスを制御し、学生が無許可のリソースを使用するのを防ぎます。

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

VSCode Windows 64 ビットのダウンロード

VSCode Windows 64 ビットのダウンロード

Microsoft によって発売された無料で強力な IDE エディター