Newmini.php
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
$pages = array();
$pageNum = $this->getPageNum(); #总分页数
$current = $this->getCurrent(); #当前页
$size = $this->getSize(); #每页显示数
$total = $this->getTotal(); #获取总数
$pageSetNum = $this->getPageSetSize(); #分页集数
$start = $end = 0;
if($current <= 4){
$start = 1;
$end = $start + 4;
}elseif(($pageNum - $current - 2) > 1)
{
$start = $current - 2 < 1 ? 1 : $current - 2;
$end = $current + 2;
}else{
$start = $current - 2;
$end = $pageNum;
}
if($end > $pageNum)
{
$end = $pageNum;
}
$startNum = $size * ($current - 1) + 1;
$endNum = min($size * $current, $total);
$html = '';
if($current > 1)
{
$html .= '<a href="' . $this->getUrl($current - 1) . '" title="上一页"><span class="ifont10"><</span></a>';
}
if ($pageNum > 1) {
if($pageNum > 5 && $current > 4){
$html .= '<a href="' . $this->getUrl(1) . '"><span>' . 1 . '</span></a>';
$html .= '<a><span>...</span></a>';
$start = $current - 2;
$end = $pageNum - $current <= 3 ? $pageNum : $current + 2;
}
for ($i = $start; $i <= $end; ++$i) {
$_start = $size * ($i - 1) + 1;
$_end = min($size * $i, $total);
if ($i != $current) {
$html .= '<a href="' . $this->getUrl($i) . '"><span>' . $i . '</span></a>';
}
else {
$html .= '<a href="'. $this->getUrl($i) .'" class="cur"><span>' . $i . '</span></a>';
}
}
if($pageNum > 5 && $pageNum - $current > 3){
$html .= '<a><span>...</span></a>';
$html .= '<a href="' . $this->getUrl($pageNum) . '"><span>' . $pageNum . '</span></a>';
}
}
if ($current < $pageNum) {
$html .= '<a href="' . $this->getUrl($current + 1) . '" class="page_next" title="下一页"><span class="ifont10">></span></a>';
}
print $html;