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) |
||
79 | |||
80 | /** |
||
81 | * add css to table <td> or <th> |
||
82 | * |
||
83 | * @param $elem |
||
84 | * @param $attr |
||
85 | * @param $value |
||
86 | * @return $this |
||
87 | */ |
||
88 | public function css($elem, $attr, $value) |
||
94 | |||
95 | /** |
||
96 | * add a filter to this column. |
||
97 | * $data can be array (associative or not), json, PDO or ORM result |
||
98 | * |
||
99 | * @param null $data |
||
100 | * @return $this |
||
101 | */ |
||
102 | public function filter($data = null) |
||
110 | |||
111 | /** |
||
112 | * add this column to the table |
||
113 | * |
||
114 | * @return Table |
||
115 | */ |
||
116 | public function add() |
||
120 | |||
121 | /** |
||
122 | * render column header cell <th> |
||
123 | * |
||
124 | * @return mixed |
||
125 | */ |
||
126 | public function renderHeader() |
||
143 | |||
144 | /** |
||
145 | * render column filter |
||
146 | * |
||
147 | * @return string |
||
148 | */ |
||
149 | public function renderFilter() |
||
171 | |||
172 | /** |
||
173 | * render column body cell <td> |
||
174 | * |
||
175 | * @param $row |
||
176 | * @return mixed |
||
177 | */ |
||
178 | public function renderBody( &$row ) |
||
198 | |||
199 | |||
200 | /** |
||
201 | * @param string $str |
||
202 | * @return mixed |
||
203 | */ |
||
204 | private function camelToTitle($str) |
||
211 | |||
212 | |||
213 | /** |
||
214 | * @param string $str |
||
215 | * @return string |
||
216 | */ |
||
217 | private function underscoreToTitle($str) |
||
223 | |||
224 | |||
225 | /** |
||
226 | * @param string $var |
||
227 | * @return boolean |
||
228 | */ |
||
229 | private function isCallable($var) |
||
233 | |||
234 | } |
||
235 |