1 | <?php |
||
32 | class LinkPager extends Widget |
||
33 | { |
||
34 | /** |
||
35 | * @var Pagination the pagination object that this pager is associated with. |
||
36 | * You must set this property in order to make LinkPager work. |
||
37 | */ |
||
38 | public $pagination; |
||
39 | /** |
||
40 | * @var array HTML attributes for the pager container tag. |
||
41 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
42 | */ |
||
43 | public $options = ['class' => 'pagination']; |
||
44 | /** |
||
45 | * @var array HTML attributes which will be applied to all link containers |
||
46 | * @since 2.0.13 |
||
47 | */ |
||
48 | public $linkContainerOptions = []; |
||
49 | /** |
||
50 | * @var array HTML attributes for the link in a pager container tag. |
||
51 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
52 | */ |
||
53 | public $linkOptions = []; |
||
54 | /** |
||
55 | * @var string the CSS class for the each page button. |
||
56 | * @since 2.0.7 |
||
57 | */ |
||
58 | public $pageCssClass; |
||
59 | /** |
||
60 | * @var string the CSS class for the "first" page button. |
||
61 | */ |
||
62 | public $firstPageCssClass = 'first'; |
||
63 | /** |
||
64 | * @var string the CSS class for the "last" page button. |
||
65 | */ |
||
66 | public $lastPageCssClass = 'last'; |
||
67 | /** |
||
68 | * @var string the CSS class for the "previous" page button. |
||
69 | */ |
||
70 | public $prevPageCssClass = 'prev'; |
||
71 | /** |
||
72 | * @var string the CSS class for the "next" page button. |
||
73 | */ |
||
74 | public $nextPageCssClass = 'next'; |
||
75 | /** |
||
76 | * @var string the CSS class for the active (currently selected) page button. |
||
77 | */ |
||
78 | public $activePageCssClass = 'active'; |
||
79 | /** |
||
80 | * @var string the CSS class for the disabled page buttons. |
||
81 | */ |
||
82 | public $disabledPageCssClass = 'disabled'; |
||
83 | /** |
||
84 | * @var array the options for the disabled tag to be generated inside the disabled list element. |
||
85 | * In order to customize the html tag, please use the tag key. |
||
86 | * |
||
87 | * ```php |
||
88 | * $disabledListItemSubTagOptions = ['tag' => 'div', 'class' => 'disabled-div']; |
||
89 | * ``` |
||
90 | * @since 2.0.11 |
||
91 | */ |
||
92 | public $disabledListItemSubTagOptions = []; |
||
93 | /** |
||
94 | * @var int maximum number of page buttons that can be displayed. Defaults to 10. |
||
95 | */ |
||
96 | public $maxButtonCount = 10; |
||
97 | /** |
||
98 | * @var string|bool the label for the "next" page button. Note that this will NOT be HTML-encoded. |
||
99 | * If this property is false, the "next" page button will not be displayed. |
||
100 | */ |
||
101 | public $nextPageLabel = '»'; |
||
102 | /** |
||
103 | * @var string|bool the text label for the previous page button. Note that this will NOT be HTML-encoded. |
||
104 | * If this property is false, the "previous" page button will not be displayed. |
||
105 | */ |
||
106 | public $prevPageLabel = '«'; |
||
107 | /** |
||
108 | * @var string|bool the text label for the "first" page button. Note that this will NOT be HTML-encoded. |
||
109 | * If it's specified as true, page number will be used as label. |
||
110 | * Default is false that means the "first" page button will not be displayed. |
||
111 | */ |
||
112 | public $firstPageLabel = false; |
||
113 | /** |
||
114 | * @var string|bool the text label for the "last" page button. Note that this will NOT be HTML-encoded. |
||
115 | * If it's specified as true, page number will be used as label. |
||
116 | * Default is false that means the "last" page button will not be displayed. |
||
117 | */ |
||
118 | public $lastPageLabel = false; |
||
119 | /** |
||
120 | * @var bool whether to register link tags in the HTML header for prev, next, first and last page. |
||
121 | * Defaults to `false` to avoid conflicts when multiple pagers are used on one page. |
||
122 | * @see http://www.w3.org/TR/html401/struct/links.html#h-12.1.2 |
||
123 | * @see registerLinkTags() |
||
124 | */ |
||
125 | public $registerLinkTags = false; |
||
126 | /** |
||
127 | * @var bool Hide widget when only one page exist. |
||
128 | */ |
||
129 | public $hideOnSinglePage = true; |
||
130 | /** |
||
131 | * @var bool whether to render current page button as disabled. |
||
132 | * @since 2.0.12 |
||
133 | */ |
||
134 | public $disableCurrentPageButton = false; |
||
135 | |||
136 | |||
137 | /** |
||
138 | * Initializes the pager. |
||
139 | */ |
||
140 | 17 | public function init() |
|
148 | |||
149 | /** |
||
150 | * Executes the widget. |
||
151 | * This overrides the parent implementation by displaying the generated page buttons. |
||
152 | * @return string the result of widget execution to be outputted. |
||
153 | */ |
||
154 | 17 | public function run() |
|
161 | |||
162 | /** |
||
163 | * Registers relational link tags in the html header for prev, next, first and last page. |
||
164 | * These links are generated using [[\yii\data\Pagination::getLinks()]]. |
||
165 | * @see http://www.w3.org/TR/html401/struct/links.html#h-12.1.2 |
||
166 | */ |
||
167 | protected function registerLinkTags() |
||
174 | |||
175 | /** |
||
176 | * Renders the page buttons. |
||
177 | * @return string the rendering result |
||
178 | */ |
||
179 | 17 | protected function renderPageButtons() |
|
227 | |||
228 | /** |
||
229 | * Renders a page button. |
||
230 | * You may override this method to customize the generation of page buttons. |
||
231 | * @param string $label the text label for the button |
||
232 | * @param int $page the page number |
||
233 | * @param string $class the CSS class for the page button. |
||
234 | * @param bool $disabled whether this page button is disabled |
||
235 | * @param bool $active whether this page button is active |
||
236 | * @return string the rendering result |
||
237 | */ |
||
238 | 7 | protected function renderPageButton($label, $page, $class, $disabled, $active) |
|
259 | |||
260 | /** |
||
261 | * @return array the begin and end pages that need to be displayed. |
||
262 | */ |
||
263 | 7 | protected function getPageRange() |
|
276 | } |
||
277 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.