?? pagercontrol.php
字號:
<?php
/*
版權(quán)歸原作者
漢化:slender
我們的目標
做專業(yè)的blog中心!
http://phpstu.uni.cc
*/
class PagerControl
{
var $baseURL;
var $name;
var $total;
var $page;
function PagerControl( $baseURL, $name, $total, $page=0 )
{
$this->baseURL = $baseURL;
$this->name = $name;
$this->total = $total;
$this->page = $page;
}
function printInfo()
{
$top = ($this->page+1)*PER_PAGE;
if ( $top>$this->total )
$top = $this->total;
echo '<div class="PagerControl" align="center">'.($this->page*PER_PAGE+1).'-'.$top.'/'.$this->total.'</div>';
}
function printControl()
{
?>
<div class="PagerControl" align="center">
<?
$totalPages = (int)($this->total/PER_PAGE);
if ( ($this->total%PER_PAGE)>0 )
$totalPages++;
if ( $this->page>0 )
{
?>
<a href="<?= $this->baseURL ?>&<?= $this->name ?>=<?= 0 ?>"><<</a>
<a href="<?= $this->baseURL ?>&<?= $this->name ?>=<?= $this->page-1 ?>"><</a>
<?
}
$min = $this->page-10;
if ( $min<0 )
$min = 0;
$max = $min+20;
if ( $max>$totalPages )
{
$max = $totalPages;
if ( $max>20 )
$min=$max-20;
}
for( $i=$min; $i<$max; $i++ )
{
if ( $i==$this->page )
{
?>
<?= $i+1 ?>
<?
}
else
{
?>
<a href="<?= $this->baseURL ?>&<?= $this->name ?>=<?= $i ?>"><?= $i+1 ?></a>
<?
}
}
if ( $this->page<$totalPages-1 )
{
?>
<a href="<?= $this->baseURL ?>&<?= $this->name ?>=<?= $this->page+1 ?>">></a>
<a href="<?= $this->baseURL ?>&<?= $this->name ?>=<?= $totalPages-1 ?>">>></a>
<?
}
?>
</div>
<?
}
}
?>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -