1 | <?php |
||
8 | class PaginationView |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * @var Pagination |
||
13 | */ |
||
14 | protected $pagination; |
||
15 | |||
16 | /** |
||
17 | * @var Router |
||
18 | */ |
||
19 | protected $router; |
||
20 | |||
21 | /** |
||
22 | * @var string CSS class name for list. |
||
23 | */ |
||
24 | protected $listCssClass = 'pagination'; |
||
25 | |||
26 | /** |
||
27 | * @var array Parameter list for each pagination link. |
||
28 | */ |
||
29 | protected $linkOptions = []; |
||
30 | |||
31 | /** |
||
32 | * @var string CSS class name for first page button. |
||
33 | */ |
||
34 | public $firstPageCssClass = 'first'; |
||
35 | |||
36 | /** |
||
37 | * @var string CSS class name for last page button. |
||
38 | */ |
||
39 | public $lastPageCssClass = 'last'; |
||
40 | |||
41 | /** |
||
42 | * @var string CSS class name for previous page button. |
||
43 | */ |
||
44 | public $prevPageCssClass = 'prev'; |
||
45 | |||
46 | /** |
||
47 | * @var string CSS class name for next page button. |
||
48 | */ |
||
49 | public $nextPageCssClass = 'next'; |
||
50 | |||
51 | /** |
||
52 | * @var string CSS class name for active page button |
||
53 | */ |
||
54 | public $activePageCssClass = 'active'; |
||
55 | |||
56 | /** |
||
57 | * @var string CSS class for disabled page button. |
||
58 | */ |
||
59 | public $disabledPageCssClass = 'disabled'; |
||
60 | |||
61 | /** |
||
62 | * @var int Max number of buttons to show. |
||
63 | */ |
||
64 | public $maxButtonCount = 10; |
||
65 | |||
66 | /** |
||
67 | * @var bool Whether to show a link to the first page. |
||
68 | */ |
||
69 | public $showFirstPageLink = false; |
||
70 | |||
71 | /** |
||
72 | * @var bool Whether to show a link to the last page |
||
73 | */ |
||
74 | public $showLastPageLink = false; |
||
75 | |||
76 | /** |
||
77 | * @var bool Whether to show a link to the previous page. |
||
78 | */ |
||
79 | public $showPrevPageLink = true; |
||
80 | |||
81 | /** |
||
82 | * @var bool Whether to show a link to the next page |
||
83 | */ |
||
84 | public $showNextPageLink = true; |
||
85 | |||
86 | /** |
||
87 | * @var string Next page default label. Will be used if [[showNextPageLink]] |
||
88 | * set to true. |
||
89 | */ |
||
90 | public $nextPageLabel = '›'; |
||
91 | |||
92 | /** |
||
93 | * @var string Precious page default label. Will be used if |
||
94 | * [[showPrevPageLink]] set to true. |
||
95 | */ |
||
96 | public $prevPageLabel = '‹'; |
||
97 | |||
98 | /** |
||
99 | * @var string First page default label. Will be used if |
||
100 | * [[showFirstPageLink]] set to true. |
||
101 | */ |
||
102 | public $firstPageLabel = '«'; |
||
103 | |||
104 | /** |
||
105 | * @var string Last page default label. Will be used if |
||
106 | * [[showLastPageLink]] set to true. |
||
107 | */ |
||
108 | public $lastPageLabel = '»'; |
||
109 | |||
110 | /** |
||
111 | * PaginationView constructor. |
||
112 | * |
||
113 | * @param RequestStack $request |
||
114 | * @param Router $router |
||
115 | */ |
||
116 | public function __construct( |
||
128 | |||
129 | /** |
||
130 | * Render pagination block. |
||
131 | * |
||
132 | * @return string |
||
133 | * @throws \Exception |
||
134 | */ |
||
135 | public function renderPageButtons() |
||
208 | |||
209 | /** |
||
210 | * Render single pagination block button. |
||
211 | * |
||
212 | * @param string $label |
||
213 | * @param int $page |
||
214 | * @param string $class |
||
215 | * @param bool $disabled |
||
216 | * @param bool $active |
||
217 | * |
||
218 | * @return string |
||
219 | */ |
||
220 | protected function createPageButton( |
||
244 | |||
245 | /** |
||
246 | * Create link for pagination button. |
||
247 | * |
||
248 | * @param int $pageIndex |
||
249 | * @param int $pageSize |
||
250 | * @param bool $absoluteUrl |
||
251 | * |
||
252 | * @return string |
||
253 | */ |
||
254 | public function createButtonLink($pageIndex, $pageSize, $absoluteUrl = true) |
||
278 | |||
279 | |||
280 | /** |
||
281 | * Creates string representation of class attribute from array. |
||
282 | * |
||
283 | * @param string $attributeName |
||
284 | * @param array $attributeData |
||
285 | * |
||
286 | * @return string |
||
287 | */ |
||
288 | protected function prepareClassAttribute(array $attributeData) { |
||
295 | |||
296 | /** |
||
297 | * Calculate current pagination pages range. |
||
298 | * |
||
299 | * @return array |
||
300 | */ |
||
301 | protected function getPageRange() |
||
322 | |||
323 | /** |
||
324 | * @param Pagination $pagination |
||
325 | */ |
||
326 | public function setPagination(Pagination $pagination) |
||
330 | |||
331 | |||
332 | /** |
||
333 | * Encodes data for using as html attribute value. |
||
334 | * |
||
335 | * @param mixed $data |
||
336 | * |
||
337 | * @return string |
||
338 | */ |
||
339 | public function jsonEncode($data) |
||
350 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: