@@ -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 | } |
| 48 | 48 | return $paging; |
| 49 | 49 | } |
@@ -55,17 +55,17 @@ discard block |
||
| 55 | 55 | * @param int $numpages The number of pagination buttons to display |
| 56 | 56 | * return void Nothing is returned |
| 57 | 57 | */ |
| 58 | - protected static function getPage($records, $maxshown, $numpages){ |
|
| 58 | + protected static function getPage($records, $maxshown, $numpages) { |
|
| 59 | 59 | $show = floor($numpages / 2); |
| 60 | - if(self::$lastpage > $numpages){ |
|
| 61 | - if(self::$current > $show){self::$page = self::$current - $show;}else{self::$page = 1;} |
|
| 60 | + if (self::$lastpage > $numpages) { |
|
| 61 | + if (self::$current > $show) {self::$page = self::$current - $show; }else {self::$page = 1; } |
|
| 62 | 62 | |
| 63 | - if(self::$current < (self::$lastpage - $show)){ |
|
| 63 | + if (self::$current < (self::$lastpage - $show)) { |
|
| 64 | 64 | self::$lastpage = self::$current + $show; |
| 65 | - if(self::$current <= $show){self::$lastpage = self::$current + ($numpages - self::$current);} |
|
| 65 | + if (self::$current <= $show) {self::$lastpage = self::$current + ($numpages - self::$current); } |
|
| 66 | 66 | } |
| 67 | - else{self::$page = self::$current - ($numpages - ((ceil($records / $maxshown) - self::$current)) - 1);} |
|
| 67 | + else {self::$page = self::$current - ($numpages - ((ceil($records / $maxshown) - self::$current)) - 1); } |
|
| 68 | 68 | } |
| 69 | - else{self::$page = 1;} |
|
| 69 | + else {self::$page = 1; } |
|
| 70 | 70 | } |
| 71 | 71 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public static function paging($records, $pageURL, $start = 0, $additional = '', $maxshown = 50, $numpagesshown = 11){ |
| 25 | 25 | if($records > $maxshown){ |
| 26 | - if($start >= 1){self::$current = $start;}else{self::$current = 1;} |
|
| 26 | + if($start >= 1){self::$current = $start;} else{self::$current = 1;} |
|
| 27 | 27 | self::$lastpage = ceil($records / $maxshown); |
| 28 | 28 | |
| 29 | 29 | if(!empty($additional)){$additional = 'search='.$additional.'&';} |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $paging.= '<li><a href="'.$pageURL.'?'.$additional.'page='.($start - 1).'"><</a></li>'; |
| 36 | 36 | } |
| 37 | 37 | while(self::$page <= self::$lastpage){ |
| 38 | - if(self::$current == self::$page){$curselect = ' class="active"';}else{$curselect = '';} |
|
| 38 | + if(self::$current == self::$page){$curselect = ' class="active"';} else{$curselect = '';} |
|
| 39 | 39 | $paging.= '<li'.$curselect.'><a href="'.$pageURL.'?'.$additional.'page='.self::$page.'">'.self::$page.'</a></li>'; |
| 40 | 40 | self::$page = (self::$page + 1); |
| 41 | 41 | } |
@@ -58,14 +58,12 @@ discard block |
||
| 58 | 58 | protected static function getPage($records, $maxshown, $numpages){ |
| 59 | 59 | $show = floor($numpages / 2); |
| 60 | 60 | if(self::$lastpage > $numpages){ |
| 61 | - if(self::$current > $show){self::$page = self::$current - $show;}else{self::$page = 1;} |
|
| 61 | + if(self::$current > $show){self::$page = self::$current - $show;} else{self::$page = 1;} |
|
| 62 | 62 | |
| 63 | 63 | if(self::$current < (self::$lastpage - $show)){ |
| 64 | 64 | self::$lastpage = self::$current + $show; |
| 65 | 65 | if(self::$current <= $show){self::$lastpage = self::$current + ($numpages - self::$current);} |
| 66 | - } |
|
| 67 | - else{self::$page = self::$current - ($numpages - ((ceil($records / $maxshown) - self::$current)) - 1);} |
|
| 68 | - } |
|
| 69 | - else{self::$page = 1;} |
|
| 66 | + } else{self::$page = self::$current - ($numpages - ((ceil($records / $maxshown) - self::$current)) - 1);} |
|
| 67 | + } else{self::$page = 1;} |
|
| 70 | 68 | } |
| 71 | 69 | } |