1 | <?php |
||
4 | Class TableColumn |
||
5 | { |
||
6 | public $value; |
||
7 | |||
8 | private $tableInstance; |
||
9 | private $title; |
||
10 | private $attrs; |
||
11 | private $css; |
||
12 | private $filter = false; |
||
13 | private $filterData = null; |
||
14 | |||
15 | /** |
||
16 | * create a new TableColumn instance |
||
17 | * |
||
18 | * @param Table $tableInstance |
||
19 | */ |
||
20 | public function __construct(Table &$tableInstance) |
||
26 | |||
27 | public function __get( $prop ) |
||
31 | |||
32 | /** |
||
33 | * set column title |
||
34 | * |
||
35 | * @param $title |
||
36 | * @return $this |
||
37 | */ |
||
38 | public function title($title) |
||
44 | |||
45 | /** |
||
46 | * bind colunm value. $value can be: |
||
47 | * integer index for none associative array or json |
||
48 | * string index for associative array, json, PDO or ORM result |
||
49 | * a closure that returns a string |
||
50 | * |
||
51 | * @param $value |
||
52 | * @return $this |
||
53 | */ |
||
54 | public function value($value) |
||
60 | |||
61 | /** |
||
62 | * add a attribute to table <td> or <th> |
||
63 | * |
||
64 | * @param $elem |
||
65 | * @param $attr |
||
66 | * @param $value |
||
67 | * @return $this |
||
68 | */ |
||
69 | public function attr($elem, $attr, $value) |
||
75 | |||
76 | /** |
||
77 | * add css to table <td> or <th> |
||
78 | * |
||
79 | * @param $elem |
||
80 | * @param $attr |
||
81 | * @param $value |
||
82 | * @return $this |
||
83 | */ |
||
84 | public function css($elem, $attr, $value) |
||
90 | |||
91 | /** |
||
92 | * add a filter to this column. |
||
93 | * $data can be array (associative or not), json, PDO or ORM result |
||
94 | * |
||
95 | * @param null $data |
||
96 | * @return $this |
||
97 | */ |
||
98 | public function filter($data = null) |
||
106 | |||
107 | /** |
||
108 | * add this column to the table |
||
109 | * |
||
110 | * @return Table |
||
111 | */ |
||
112 | public function add() |
||
116 | |||
117 | /** |
||
118 | * render column header cell <th> |
||
119 | * |
||
120 | * @return mixed |
||
121 | */ |
||
122 | public function renderHeader() |
||
139 | |||
140 | /** |
||
141 | * render column filter |
||
142 | * |
||
143 | * @return string |
||
144 | */ |
||
145 | public function renderFilter() |
||
167 | |||
168 | /** |
||
169 | * render column body cell <td> |
||
170 | * |
||
171 | * @param $row |
||
172 | * @return mixed |
||
173 | */ |
||
174 | public function renderBody( &$row ) |
||
194 | |||
195 | |||
196 | /** |
||
197 | * @param string $str |
||
198 | * @return mixed |
||
199 | */ |
||
200 | private function camelToTitle($str) |
||
207 | |||
208 | |||
209 | /** |
||
210 | * @param string $str |
||
211 | * @return string |
||
212 | */ |
||
213 | private function underscoreToTitle($str) |
||
219 | |||
220 | |||
221 | /** |
||
222 | * @param string $var |
||
223 | * @return boolean |
||
224 | */ |
||
225 | private function isCallable($var) |
||
229 | |||
230 | } |
||
231 |