@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | * @author Adam Binnersley <[email protected]> |
7 | 7 | */ |
8 | -class Pagination{ |
|
8 | +class Pagination { |
|
9 | 9 | |
10 | 10 | public static $current; |
11 | 11 | protected static $page; |
@@ -21,29 +21,29 @@ discard block |
||
21 | 21 | * @param int $numpagesshown The number of pagination buttons to display |
22 | 22 | * @return string Returns the pagination menu |
23 | 23 | */ |
24 | - public static function paging($records, $pageURL, $start = 0, $additional = '', $maxshown = 50, $numpagesshown = 11){ |
|
25 | - if($records > $maxshown){ |
|
26 | - if($start >= 1){self::$current = $start;}else{self::$current = 1;} |
|
24 | + public static function paging($records, $pageURL, $start = 0, $additional = '', $maxshown = 50, $numpagesshown = 11) { |
|
25 | + if ($records > $maxshown) { |
|
26 | + if ($start >= 1) {self::$current = $start; }else {self::$current = 1; } |
|
27 | 27 | self::$lastpage = ceil($records / $maxshown); |
28 | 28 | |
29 | - if(!empty($additional)){$additional = 'search='.$additional.'&';} |
|
29 | + if (!empty($additional)) {$additional = 'search='.$additional.'&'; } |
|
30 | 30 | |
31 | 31 | self::getPage($records, $maxshown, $numpagesshown); |
32 | 32 | $paging = '<ul class="pagination">'; |
33 | - if(self::$current != 1){ |
|
34 | - if(self::$current != 2){$paging.= '<li><a href="'.$pageURL.'?'.$additional.'">«</a></li>';} |
|
35 | - $paging.= '<li><a href="'.$pageURL.'?'.$additional.'page='.($start - 1).'"><</a></li>'; |
|
33 | + if (self::$current != 1) { |
|
34 | + if (self::$current != 2) {$paging .= '<li><a href="'.$pageURL.'?'.$additional.'">«</a></li>'; } |
|
35 | + $paging .= '<li><a href="'.$pageURL.'?'.$additional.'page='.($start - 1).'"><</a></li>'; |
|
36 | 36 | } |
37 | - while(self::$page <= self::$lastpage){ |
|
38 | - if(self::$current == self::$page){$curselect = ' class="active"';}else{$curselect = '';} |
|
39 | - $paging.= '<li'.$curselect.'><a href="'.$pageURL.'?'.$additional.'page='.self::$page.'">'.self::$page.'</a></li>'; |
|
37 | + while (self::$page <= self::$lastpage) { |
|
38 | + if (self::$current == self::$page) {$curselect = ' class="active"'; }else {$curselect = ''; } |
|
39 | + $paging .= '<li'.$curselect.'><a href="'.$pageURL.'?'.$additional.'page='.self::$page.'">'.self::$page.'</a></li>'; |
|
40 | 40 | self::$page = (self::$page + 1); |
41 | 41 | } |
42 | - if(self::$current != self::$lastpage){ |
|
43 | - $paging.= '<li><a href="'.$pageURL.'?'.$additional.'page='.($start + 1).'">></a></li>'; |
|
44 | - if(self::$current != (self::$lastpage - 1)){$paging.= '<li><a href="'.$pageURL.'?'.$additional.'page='.ceil($records / $maxshown).'">»</a></li>';} |
|
42 | + if (self::$current != self::$lastpage) { |
|
43 | + $paging .= '<li><a href="'.$pageURL.'?'.$additional.'page='.($start + 1).'">></a></li>'; |
|
44 | + if (self::$current != (self::$lastpage - 1)) {$paging .= '<li><a href="'.$pageURL.'?'.$additional.'page='.ceil($records / $maxshown).'">»</a></li>'; } |
|
45 | 45 | } |
46 | - $paging.= '</ul>'; |
|
46 | + $paging .= '</ul>'; |
|
47 | 47 | return $paging; |
48 | 48 | } |
49 | 49 | return false; |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | * @param int $numpages The number of pagination buttons to display |
57 | 57 | * return void Nothing is returned |
58 | 58 | */ |
59 | - protected static function getPage($records, $maxshown, $numpages){ |
|
59 | + protected static function getPage($records, $maxshown, $numpages) { |
|
60 | 60 | $show = floor($numpages / 2); |
61 | - if(self::$lastpage > $numpages){ |
|
62 | - if(self::$current > $show){self::$page = self::$current - $show;}else{self::$page = 1;} |
|
61 | + if (self::$lastpage > $numpages) { |
|
62 | + if (self::$current > $show) {self::$page = self::$current - $show; }else {self::$page = 1; } |
|
63 | 63 | |
64 | - if(self::$current < (self::$lastpage - $show)){ |
|
64 | + if (self::$current < (self::$lastpage - $show)) { |
|
65 | 65 | self::$lastpage = self::$current + $show; |
66 | - if(self::$current <= $show){self::$lastpage = self::$current + ($numpages - self::$current);} |
|
66 | + if (self::$current <= $show) {self::$lastpage = self::$current + ($numpages - self::$current); } |
|
67 | 67 | } |
68 | - else{self::$page = self::$current - ($numpages - ((ceil($records / $maxshown) - self::$current)) - 1);} |
|
68 | + else {self::$page = self::$current - ($numpages - ((ceil($records / $maxshown) - self::$current)) - 1); } |
|
69 | 69 | } |
70 | - else{self::$page = 1;} |
|
70 | + else {self::$page = 1; } |
|
71 | 71 | } |
72 | 72 | } |