/
pagination.php
104 lines (87 loc) · 4.21 KB
/
pagination.php
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Metaways Infosystems GmbH, 2012
* @copyright Aimeos (aimeos.org), 2015-2024
*/
$enc = $this->encoder();
$multi = $this->config( 'client/html/catalog/multiroute', false );
$linkKey = $multi && $this->param( 'path' ) || $this->param( 'f_catid' ) ? 'client/html/catalog/tree/url' : 'client/html/catalog/lists/url';
$sort = $this->param( 'f_sort', $this->config( 'client/html/catalog/lists/sort', 'relevance' ) );
$infiniteScroll = $this->config( 'client/html/catalog/lists/infinite-scroll', false );
$params = $this->get( 'params', [] );
$sortname = ltrim( $sort, '-' );
$nameDir = $priceDir = '';
if( $sort === 'name' ) {
$nameSort = $this->translate( 'client', '▼ Name' ); $nameDir = '-';
} else if( $sort === '-name' ) {
$nameSort = $this->translate( 'client', '▲ Name' );
} else {
$nameSort = $this->translate( 'client', 'Name' );
}
if( $sort === 'price' ) {
$priceSort = $this->translate( 'client', '▼ Price' ); $priceDir = '-';
} else if( $sort === '-price' ) {
$priceSort = $this->translate( 'client', '▲ Price' );
} else {
$priceSort = $this->translate( 'client', 'Price' );
}
?>
<nav class="pagination">
<div class="sort" aria-label="<?= $enc->attr( $this->translate( 'client', 'Sort by' ) ) ?>">
<span><?= $enc->html( $this->translate( 'client', 'Sort by' ), $enc::TRUST ) ?>:</span>
<ul>
<li>
<?php $url = $this->link( $linkKey, ['f_sort' => 'relevance'] + $params ) ?>
<a class="option-relevance <?= ( $sort === 'relevance' ? 'active' : '' ) ?>" href="<?= $enc->attr( $url ) ?>">
<?= $enc->html( $this->translate( 'client', 'Relevance' ), $enc::TRUST ) ?>
</a>
</li>
<li>
<?php $url = $this->link( $linkKey, ['f_sort' => '-ctime'] + $params ) ?>
<a class="option-ctime <?= ( $sort === '-ctime' ? 'active' : '' ) ?>" href="<?= $enc->attr( $url ) ?>">
<?= $enc->html( $this->translate( 'client', 'Latest' ), $enc::TRUST ) ?>
</a>
</li>
<li>
<?php $url = $this->link( $linkKey, ['f_sort' => $nameDir . 'name'] + $params ) ?>
<a class="option-name <?= ( $sortname === 'name' ? 'active' : '' ) ?>" href="<?= $enc->attr( $url ) ?>">
<?= $enc->html( $nameSort, $enc::TRUST ) ?>
</a>
</li>
<li>
<?php $url = $this->link( $linkKey, ['f_sort' => $priceDir . 'price'] + $params ) ?>
<a class="option-price <?= ( $sortname === 'price' ? 'active' : '' ) ?>" href="<?= $enc->attr( $url ) ?>">
<?= $enc->html( $priceSort, $enc::TRUST ) ?>
</a>
</li>
<li>
<?php $url = $this->link( $linkKey, ['f_sort' => '-rating'] + $params ) ?>
<a class="option-rating <?= ( $sort === '-rating' ? 'active' : '' ) ?>" href="<?= $enc->attr( $url ) ?>">
<?= $enc->html( $this->translate( 'client', 'Rating' ), $enc::TRUST ) ?>
</a>
</li>
</ul>
</div>
<?php if( !$infiniteScroll && $this->last > 1 ) : ?>
<div class="browser" aria-label="<?= $enc->attr( $this->translate( 'client', 'Go to page' ) ) ?>">
<?php $url = $this->link( $linkKey, ['l_page' => 1] + $params ) ?>
<a class="first" href="<?= $enc->attr( $url ) ?>" title="<?= $enc->attr( $this->translate( 'client', 'First' ) ) ?>">
<?= $enc->html( $this->translate( 'client', '◀◀' ), $enc::TRUST ) ?>
</a>
<?php $url = $this->link( $linkKey, ['l_page' => $this->prev] + $params ) ?>
<a class="prev" href="<?= $enc->attr( $url ) ?>" title="<?= $enc->attr( $this->translate( 'client', 'Previous' ) ) ?>">
<?= $enc->html( $this->translate( 'client', '◀' ), $enc::TRUST ) ?>
</a>
<span><?= $enc->html( sprintf( $this->translate( 'client', 'Page %1$d of %2$d' ), $this->current, $this->last ) ) ?></span>
<?php $url = $this->link( $linkKey, ['l_page' => $this->next] + $params ) ?>
<a class="next" href="<?= $enc->attr( $url ) ?>" title="<?= $enc->attr( $this->translate( 'client', 'Next' ) ) ?>">
<?= $enc->html( $this->translate( 'client', '▶' ), $enc::TRUST ) ?>
</a>
<?php $url = $this->link( $linkKey, ['l_page' => $this->last] + $params ) ?>
<a class="last" href="<?= $enc->attr( $url ) ?>" title="<?= $enc->attr( $this->translate( 'client', 'Last' ) ) ?>">
<?= $enc->html( $this->translate( 'client', '▶▶' ), $enc::TRUST ) ?>
</a>
</div>
<?php endif ?>
</nav>