Revision 1, 1.3 KB
(checked in by andrewgunn, 14 years ago)
|
Added original EVE-Killboard.net source code.
|
Line | |
---|
1 | <? |
---|
2 | class PageSplitter |
---|
3 | { |
---|
4 | function PageSplitter( $max, $split ) |
---|
5 | { |
---|
6 | $this->max_ = $max; |
---|
7 | $this->split_ = $split; |
---|
8 | } |
---|
9 | |
---|
10 | function getSplit() |
---|
11 | { |
---|
12 | return $this->split_; |
---|
13 | } |
---|
14 | |
---|
15 | function generate() |
---|
16 | { |
---|
17 | if ( $this->max_ / $this->split_ <= 1 ) |
---|
18 | return; |
---|
19 | |
---|
20 | $html = "<br><p><b>[</b> Page: "; |
---|
21 | $endpage = ceil( $this->max_ / $this->split_ ); |
---|
22 | if ( $_GET['page'] ) { |
---|
23 | $url = preg_replace( "/&page=([0-9]?[0-9]?[0-9])/", "", |
---|
24 | $_SERVER['QUERY_STRING'] ); |
---|
25 | $page = $_GET['page']; |
---|
26 | } else { |
---|
27 | $url = $_SERVER['QUERY_STRING']; |
---|
28 | $page = 1; |
---|
29 | } |
---|
30 | for ( $i = 1; $i <= $endpage; $i++ ) { |
---|
31 | |
---|
32 | if ( $i != $page ) { |
---|
33 | if ( $i == 1 || $i == $endpage || ( ( $i >= $page - 1 && $i <= $page + 1 ) ) ) { |
---|
34 | if ( $i != 1 ) |
---|
35 | $html .= "<a href=\"?".$url."&page=".$i."\">".$i."</a> "; |
---|
36 | else |
---|
37 | $html .= "<a href=\"?".$url."\">".$i."</a> "; |
---|
38 | } elseif ( $i < $page && !$dotted ) { |
---|
39 | $dotted = true; |
---|
40 | $html .= "<b>.. </b>"; |
---|
41 | } elseif ( $i > $page && !$ldotted ) { |
---|
42 | $ldotted = true; |
---|
43 | $html .= "<b>.. </b>"; |
---|
44 | } |
---|
45 | } |
---|
46 | else |
---|
47 | $html .= "<b>".$i."</b> "; |
---|
48 | } |
---|
49 | $html .= "<b>]</b>"; |
---|
50 | return $html; |
---|
51 | } |
---|
52 | } |
---|
53 | ?> |
---|