|
1 | 1 | <?php |
2 | 2 | $translate = $this->plugin('translate'); |
3 | | -$get = $_GET; |
4 | | -if(isset($get['page'])): |
5 | | - $currentPage = htmlspecialchars($get['page']); |
6 | | - if(!is_numeric($currentPage)): |
7 | | - $currentPage = 1; |
8 | | - endif; |
9 | | -else: |
10 | | - $currentPage = 1; |
11 | | -endif; |
12 | 3 | ?> |
13 | | - |
14 | | -<!-- pagination --> |
| 4 | +<nav class="pagination" role="navigation" aria-label="pagination"> |
15 | 5 | <?php if ($totalCount): ?> |
16 | | -<div class="section section--default"> |
17 | | - <div class="container"> |
18 | | - <div class="text--center"> |
19 | | - <ul class="pagination"> |
20 | | - <?php if ($currentPage != 1): ?> |
21 | | - <?php |
22 | | - $get['page'] = $currentPage-1; |
23 | | - $get_result = http_build_query($get); |
24 | | - $previousPageUrl = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH).'?'.$get_result; |
25 | | - ?> |
26 | | - <li class="pagination__item"> |
27 | | - <a href="<?php echo $previousPageUrl;?>" class="pagination__prev"><span class="visuallyhidden">Vorige</span></a> |
28 | | - </li> |
29 | | - <?php endif;?> |
30 | | - <?php if ($currentPage > 3): ?> |
31 | | - <?php |
32 | | - $get['page'] = 1; |
33 | | - $get_result = http_build_query($get); |
34 | | - $previousPageUrl = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH).'?'.$get_result; |
35 | | - ?> |
36 | | - <li class="pagination__item"> |
37 | | - <a href="<?php echo $previousPageUrl;?>" class="pagination__btn"><?php echo 1; ?></a> ... |
38 | | - </li> |
39 | | - <?php endif;?> |
40 | | - <?php if ($currentPage > 2): ?> |
41 | | - <?php |
42 | | - $get['page'] = $currentPage-2; |
43 | | - $get_result = http_build_query($get); |
44 | | - $previousPageUrl = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH).'?'.$get_result; |
45 | | - ?> |
46 | | - <li class="pagination__item"> |
47 | | - <a href="<?php echo $previousPageUrl;?>" class="pagination__btn"><?php echo $currentPage-2; ?></a> |
48 | | - </li> |
49 | | - <?php endif;?> |
50 | | - <?php if ($currentPage > 1): ?> |
51 | | - <?php |
52 | | - $get['page'] = $currentPage-1; |
53 | | - $get_result = http_build_query($get); |
54 | | - $previousPageUrl = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH).'?'.$get_result; |
55 | | - ?> |
56 | | - <li class="pagination__item"> |
57 | | - <a href="<?php echo $previousPageUrl;?>" class="pagination__btn"><?php echo $currentPage-1; ?></a> |
58 | | - </li> |
59 | | - <?php endif; ?> |
| 6 | + <?php if ($currentPage != 1): ?> |
| 7 | + <?php echo $this->hyperlink($translate('Previous'), $previousPageUrl, ['class' => 'pagination-previous', 'title' => $translate('Previous'), 'aria-label' => $translate('Previous')]); ?> |
| 8 | + <?php endif; ?> |
60 | 9 |
|
61 | | - <li class="pagination__item"> |
62 | | - <a href="#" class="pagination__btn active"><?php echo $currentPage; ?></a> |
63 | | - </li> |
| 10 | + <form method="GET" action=""> |
| 11 | + <?php echo $this->queryToHiddenInputs(['page']); ?> |
| 12 | + <input type="text" name="page" class="page-input-top" value="<?php echo $currentPage; ?>" size="4" <?php echo ($pageCount == 1) ? 'readonly' : ''; ?> aria-label="<?php echo $translate('Page'); ?>"> |
| 13 | + <span class="page-count"><?php echo sprintf($translate('of %s'), $pageCount); ?></span> |
| 14 | + </form> |
64 | 15 |
|
65 | | - <?php if ($currentPage < $pageCount): ?> |
66 | | - <?php |
67 | | - $get['page'] = $currentPage+1; |
68 | | - $get_result = http_build_query($get); |
69 | | - $nextPageUrl = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH).'?'.$get_result; |
70 | | - ?> |
71 | | - <li class="pagination__item"> |
72 | | - <a href="<?php echo $nextPageUrl;?>" class="pagination__btn"><?php echo $currentPage+1; ?></a> |
73 | | - </li> |
74 | | - <?php endif;?> |
75 | | - <?php if ($currentPage < $pageCount-1): ?> |
76 | | - <?php |
77 | | - $get['page'] = $currentPage+2; |
78 | | - $get_result = http_build_query($get); |
79 | | - $nextPageUrl = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH).'?'.$get_result; |
80 | | - ?> |
81 | | - <li class="pagination__item"> |
82 | | - <a href="<?php echo $nextPageUrl;?>" class="pagination__btn"><?php echo $currentPage+2; ?></a> |
83 | | - </li> |
84 | | - <?php endif;?> |
85 | | - <?php if ($currentPage < $pageCount-3): ?> |
86 | | - <?php |
87 | | - $get['page'] = $pageCount; |
88 | | - $get_result = http_build_query($get); |
89 | | - $nextPageUrl = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH).'?'.$get_result; |
90 | | - ?> |
91 | | - <li class="pagination__item"> |
92 | | - ... |
93 | | - <a href="<?php echo $nextPageUrl;?>" class="pagination__btn"><?php echo $pageCount; ?></a> |
94 | | - </li> |
95 | | - <?php endif;?> |
96 | | - <?php if ($currentPage < $pageCount): ?> |
97 | | - <li class="pagination__item"> |
98 | | - <a href="<?php echo $nextPageUrl;?>" class="pagination__next"><span class="visuallyhidden">Volgende</span></a> |
99 | | - </li> |
100 | | - <?php endif; ?> |
| 16 | + <?php if ($currentPage < $pageCount): ?> |
| 17 | + <?php echo $this->hyperlink($translate('Next'), $nextPageUrl, ['class' => 'pagination-next', 'title' => $translate('Next'), 'aria-label' => $translate('Next')]); ?> |
| 18 | + <?php endif; ?> |
101 | 19 |
|
102 | | - </ul> |
103 | | - </div> |
104 | | - </div> |
105 | | -</div> |
| 20 | + <?php |
| 21 | + $from = $offset + 1; |
| 22 | + $to = ($currentPage < $pageCount) ? $offset + $perPage : $totalCount; |
| 23 | + ?> |
106 | 24 | <?php else: ?> |
107 | 25 | <?php echo $translate('0 results'); ?> |
108 | 26 | <?php endif; ?> |
| 27 | +</nav> |
0 commit comments