1 | <?php |
||
15 | class Header extends AbstractElement |
||
16 | { |
||
17 | /** |
||
18 | * Name of header (should be the same like name in database) |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $name; |
||
23 | |||
24 | /** |
||
25 | * Title of header |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $title; |
||
30 | |||
31 | /** |
||
32 | * Width of the column |
||
33 | * |
||
34 | * @var int |
||
35 | */ |
||
36 | protected $width; |
||
37 | |||
38 | |||
39 | /** |
||
40 | * Name of table alias for defined column |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $tableAlias; |
||
45 | |||
46 | /** |
||
47 | * Cell object |
||
48 | * @var Cell |
||
49 | */ |
||
50 | protected $cell; |
||
51 | |||
52 | /** |
||
53 | * Flag to inform if column should be sortable |
||
54 | * |
||
55 | * @var boolean |
||
56 | */ |
||
57 | protected $sortable = true; |
||
58 | |||
59 | /** |
||
60 | * Check if column is separatable |
||
61 | * |
||
62 | * @var boolean |
||
63 | */ |
||
64 | protected $separatable = false; |
||
65 | |||
66 | /** |
||
67 | * Check if column is editable |
||
68 | * |
||
69 | * @var boolean |
||
70 | */ |
||
71 | protected $editable = false; |
||
72 | |||
73 | |||
74 | /** |
||
75 | * Table of options |
||
76 | * |
||
77 | * @var array |
||
78 | */ |
||
79 | protected $options = array(); |
||
80 | |||
81 | /** |
||
82 | * Static array exchanging ordering (when column is ascending, in data-ordering should be desc) |
||
83 | * |
||
84 | * @var array |
||
85 | */ |
||
86 | protected static $orderReverse = array( |
||
87 | 'asc' => 'desc', |
||
88 | 'desc' => 'asc' |
||
89 | ); |
||
90 | |||
91 | /** |
||
92 | * Array of options |
||
93 | * |
||
94 | * @param string $name |
||
95 | * @param array $options |
||
96 | */ |
||
97 | public function __construct($name, $options = array()) |
||
103 | |||
104 | /** |
||
105 | * Set options like title, width, order, sortable |
||
106 | * |
||
107 | * @param string $name |
||
108 | * @param array $options |
||
109 | * @return Decorator\Header\AbstractHeaderDecorator |
||
110 | */ |
||
111 | public function addDecorator($name, $options = array()) |
||
118 | |||
119 | /** |
||
120 | * Set options like title, width, order |
||
121 | * |
||
122 | * @param array $options |
||
123 | * @return $this |
||
124 | */ |
||
125 | public function setOptions($options) |
||
142 | |||
143 | /** |
||
144 | * Get width of column |
||
145 | * |
||
146 | * @return int |
||
147 | */ |
||
148 | public function getWidth() |
||
152 | |||
153 | /** |
||
154 | * Set width of column |
||
155 | * |
||
156 | * @param int $width |
||
157 | */ |
||
158 | public function setWidth($width) |
||
162 | |||
163 | /** |
||
164 | * Return cell object |
||
165 | * |
||
166 | * @return Cell |
||
167 | */ |
||
168 | public function getCell() |
||
172 | |||
173 | /** |
||
174 | * Set cell object |
||
175 | * |
||
176 | * @param Cell $cell |
||
177 | */ |
||
178 | public function setCell($cell) |
||
182 | |||
183 | /** |
||
184 | * Set name of header |
||
185 | * |
||
186 | * @param string $name |
||
187 | * @return $this |
||
188 | */ |
||
189 | public function setName($name) |
||
194 | |||
195 | /** |
||
196 | * Get name of header |
||
197 | * |
||
198 | * @return string |
||
199 | */ |
||
200 | public function getName() |
||
204 | |||
205 | /** |
||
206 | * Set header title |
||
207 | * |
||
208 | * @param string $title |
||
209 | * @return $this |
||
210 | */ |
||
211 | public function setTitle($title) |
||
216 | |||
217 | /** |
||
218 | * Get header title |
||
219 | * |
||
220 | * @return string |
||
221 | */ |
||
222 | public function getTitle() |
||
226 | |||
227 | /** |
||
228 | * Get sortable flag |
||
229 | * |
||
230 | * @return boolean |
||
231 | */ |
||
232 | public function getSortable() |
||
236 | |||
237 | /** |
||
238 | * Set flat to inform about sortable |
||
239 | * |
||
240 | * @param boolean $sortable |
||
241 | */ |
||
242 | public function setSortable($sortable) |
||
246 | |||
247 | /** |
||
248 | * Get flat to inform about separable |
||
249 | * |
||
250 | * @return boolean |
||
251 | */ |
||
252 | public function getSeparatable() |
||
256 | |||
257 | /** |
||
258 | * Flag to inform about for all cell in header |
||
259 | * |
||
260 | * @param boolean $separatable |
||
261 | */ |
||
262 | public function setSeparatable($separatable) |
||
266 | |||
267 | /** |
||
268 | * |
||
269 | * @return boolean |
||
270 | */ |
||
271 | public function getEditable() |
||
275 | |||
276 | /** |
||
277 | * Flag to inform about for all cell in header |
||
278 | * |
||
279 | * @param boolean $editable |
||
280 | */ |
||
281 | public function setEditable($editable) |
||
285 | |||
286 | /** |
||
287 | * Get list of options |
||
288 | * |
||
289 | * @return array |
||
290 | */ |
||
291 | public function getOptions() |
||
295 | |||
296 | /** |
||
297 | * Get header title |
||
298 | * |
||
299 | * @return string |
||
300 | */ |
||
301 | public function getTableAlias() |
||
305 | |||
306 | /** |
||
307 | * Set reference to table |
||
308 | * |
||
309 | * @param $table |
||
310 | * @return void|\ZfTable\AbstractCommon |
||
311 | */ |
||
312 | public function setTable($table) |
||
317 | |||
318 | /** |
||
319 | * Init header (like asc, desc, column name ) |
||
320 | */ |
||
321 | protected function initRendering() |
||
341 | |||
342 | /** |
||
343 | * Rendering header element |
||
344 | * |
||
345 | * @return string |
||
346 | */ |
||
347 | public function render() |
||
357 | } |
||
358 |
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: