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 for the link in a pager container tag. |
||
46 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
47 | */ |
||
48 | public $linkOptions = []; |
||
49 | /** |
||
50 | * @var string the CSS class for the each page button. |
||
51 | * @since 2.0.7 |
||
52 | */ |
||
53 | public $pageCssClass; |
||
54 | /** |
||
55 | * @var string the CSS class for the "first" page button. |
||
56 | */ |
||
57 | public $firstPageCssClass = 'first'; |
||
58 | /** |
||
59 | * @var string the CSS class for the "last" page button. |
||
60 | */ |
||
61 | public $lastPageCssClass = 'last'; |
||
62 | /** |
||
63 | * @var string the CSS class for the "previous" page button. |
||
64 | */ |
||
65 | public $prevPageCssClass = 'prev'; |
||
66 | /** |
||
67 | * @var string the CSS class for the "next" page button. |
||
68 | */ |
||
69 | public $nextPageCssClass = 'next'; |
||
70 | /** |
||
71 | * @var string the CSS class for the active (currently selected) page button. |
||
72 | */ |
||
73 | public $activePageCssClass = 'active'; |
||
74 | /** |
||
75 | * @var string the CSS class for the disabled page buttons. |
||
76 | */ |
||
77 | public $disabledPageCssClass = 'disabled'; |
||
78 | |||
79 | /** |
||
80 | * @var array the options for the disabled tag to be generated inside the disabled list element. |
||
81 | * In order to customize the html tag, please use the tag key. |
||
82 | * |
||
83 | * ```php |
||
84 | * $disabledListItemSubTagOptions = ['tag' => 'div', 'class' => 'disabled-div']; |
||
85 | * ``` |
||
86 | * @since 2.0.11 |
||
87 | */ |
||
88 | public $disabledListItemSubTagOptions = []; |
||
89 | |||
90 | /** |
||
91 | * @var int maximum number of page buttons that can be displayed. Defaults to 10. |
||
92 | */ |
||
93 | public $maxButtonCount = 10; |
||
94 | /** |
||
95 | * @var string|bool the label for the "next" page button. Note that this will NOT be HTML-encoded. |
||
96 | * If this property is false, the "next" page button will not be displayed. |
||
97 | */ |
||
98 | public $nextPageLabel = '»'; |
||
99 | /** |
||
100 | * @var string|bool the text label for the previous page button. Note that this will NOT be HTML-encoded. |
||
101 | * If this property is false, the "previous" page button will not be displayed. |
||
102 | */ |
||
103 | public $prevPageLabel = '«'; |
||
104 | /** |
||
105 | * @var string|bool the text label for the "first" page button. Note that this will NOT be HTML-encoded. |
||
106 | * If it's specified as true, page number will be used as label. |
||
107 | * Default is false that means the "first" page button will not be displayed. |
||
108 | */ |
||
109 | public $firstPageLabel = false; |
||
110 | /** |
||
111 | * @var string|bool the text label for the "last" page button. Note that this will NOT be HTML-encoded. |
||
112 | * If it's specified as true, page number will be used as label. |
||
113 | * Default is false that means the "last" page button will not be displayed. |
||
114 | */ |
||
115 | public $lastPageLabel = false; |
||
116 | /** |
||
117 | * @var bool whether to register link tags in the HTML header for prev, next, first and last page. |
||
118 | * Defaults to `false` to avoid conflicts when multiple pagers are used on one page. |
||
119 | * @see http://www.w3.org/TR/html401/struct/links.html#h-12.1.2 |
||
120 | * @see registerLinkTags() |
||
121 | */ |
||
122 | public $registerLinkTags = false; |
||
123 | /** |
||
124 | * @var bool Hide widget when only one page exist. |
||
125 | */ |
||
126 | public $hideOnSinglePage = true; |
||
127 | |||
128 | |||
129 | /** |
||
130 | * Initializes the pager. |
||
131 | */ |
||
132 | 10 | public function init() |
|
138 | |||
139 | /** |
||
140 | * Executes the widget. |
||
141 | * This overrides the parent implementation by displaying the generated page buttons. |
||
142 | */ |
||
143 | 10 | public function run() |
|
150 | |||
151 | /** |
||
152 | * Registers relational link tags in the html header for prev, next, first and last page. |
||
153 | * These links are generated using [[\yii\data\Pagination::getLinks()]]. |
||
154 | * @see http://www.w3.org/TR/html401/struct/links.html#h-12.1.2 |
||
155 | */ |
||
156 | protected function registerLinkTags() |
||
163 | |||
164 | /** |
||
165 | * Renders the page buttons. |
||
166 | * @return string the rendering result |
||
167 | */ |
||
168 | 10 | protected function renderPageButtons() |
|
214 | |||
215 | /** |
||
216 | * Renders a page button. |
||
217 | * You may override this method to customize the generation of page buttons. |
||
218 | * @param string $label the text label for the button |
||
219 | * @param int $page the page number |
||
220 | * @param string $class the CSS class for the page button. |
||
221 | * @param bool $disabled whether this page button is disabled |
||
222 | * @param bool $active whether this page button is active |
||
223 | * @return string the rendering result |
||
224 | */ |
||
225 | 3 | protected function renderPageButton($label, $page, $class, $disabled, $active) |
|
242 | |||
243 | /** |
||
244 | * @return array the begin and end pages that need to be displayed. |
||
245 | */ |
||
246 | 3 | protected function getPageRange() |
|
259 | } |
||
260 |
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.