1 | <?php |
||
10 | class Grid |
||
11 | { |
||
12 | |||
13 | const SORT_ASC = 'ASC'; |
||
14 | const SORT_DESC = 'DESC'; |
||
15 | |||
16 | const EVENT_PREPARE = 'grid.prepare'; |
||
17 | const EVENT_CREATE = 'grid.create'; |
||
18 | |||
19 | /** @var GridConfig */ |
||
20 | protected $config; |
||
21 | |||
22 | /** @var bool */ |
||
23 | protected $prepared = false; |
||
24 | |||
25 | /** @var Sorter */ |
||
26 | protected $sorter; |
||
27 | |||
28 | /** @var GridInputProcessor */ |
||
29 | protected $input_processor; |
||
30 | |||
31 | protected $filtering; |
||
32 | |||
33 | public function __construct(GridConfig $config) |
||
44 | |||
45 | /** |
||
46 | * @return string |
||
47 | */ |
||
48 | protected function getMainTemplate() |
||
52 | |||
53 | |||
54 | public function prepare() |
||
74 | |||
75 | protected function initializeComponents() |
||
79 | |||
80 | protected function prepareColumns() |
||
86 | |||
87 | /** |
||
88 | * Provides unique name for each grid on the page |
||
89 | * |
||
90 | * @return null |
||
91 | */ |
||
92 | protected function provideName() |
||
108 | |||
109 | /** |
||
110 | * Returns true if columns must be sorted. |
||
111 | * |
||
112 | * @return bool |
||
113 | */ |
||
114 | protected function needToSortColumns() |
||
123 | |||
124 | private function sorting(FieldConfig $a, FieldConfig $b) |
||
128 | |||
129 | /** |
||
130 | * Sorts columns according to its order. |
||
131 | */ |
||
132 | protected function sortColumns() |
||
136 | |||
137 | /** |
||
138 | * Returns data sorting manager. |
||
139 | * |
||
140 | * @return Sorter |
||
141 | */ |
||
142 | public function getSorter() |
||
149 | |||
150 | /** |
||
151 | * Returns instance of GridInputProcessor. |
||
152 | * |
||
153 | * @return GridInputProcessor |
||
154 | */ |
||
155 | public function getInputProcessor() |
||
162 | |||
163 | /** |
||
164 | * @return GridConfig |
||
165 | */ |
||
166 | public function getConfig() |
||
170 | |||
171 | public function getViewData() |
||
180 | |||
181 | /** |
||
182 | * Renders grid. |
||
183 | * |
||
184 | * @return View|string |
||
185 | */ |
||
186 | public function render() |
||
206 | |||
207 | /** |
||
208 | * Returns footer component. |
||
209 | * |
||
210 | * @return TFoot|null |
||
211 | */ |
||
212 | public function footer() |
||
216 | |||
217 | /** |
||
218 | * Returns header component. |
||
219 | * |
||
220 | * @return THead|null |
||
221 | */ |
||
222 | public function header() |
||
226 | |||
227 | /** |
||
228 | * Returns data filtering manager. |
||
229 | * |
||
230 | * @return Filtering |
||
231 | */ |
||
232 | public function getFiltering() |
||
239 | |||
240 | /** |
||
241 | * Renders grid object when it is treated like a string. |
||
242 | * |
||
243 | * @return string |
||
244 | */ |
||
245 | public function __toString() |
||
249 | } |
||
250 |