1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the jquery-datatables-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\JQuery\DataTablesBundle\API; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* DataTables column. |
16
|
|
|
* |
17
|
|
|
* @author webeweb <https://github.com/webeweb/> |
18
|
|
|
* @package WBW\Bundle\JQuery\DataTablesBundle\API |
19
|
|
|
*/ |
20
|
|
|
class DataTablesColumn implements DataTablesColumnInterface { |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Cell type. |
24
|
|
|
* |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $cellType; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class name. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private $classname; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Content padding. |
38
|
|
|
* |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
private $contentPadding; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Data. |
45
|
|
|
* |
46
|
|
|
* @var integer|string |
47
|
|
|
*/ |
48
|
|
|
private $data; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Default content. |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
private $defaultContent; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* mapping. |
59
|
|
|
* |
60
|
|
|
* @var DataTablesMappingInterface |
61
|
|
|
*/ |
62
|
|
|
private $mapping; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Name. |
66
|
|
|
* |
67
|
|
|
* @var string |
68
|
|
|
*/ |
69
|
|
|
private $name; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Order data. |
73
|
|
|
* |
74
|
|
|
* @var integer|array |
75
|
|
|
*/ |
76
|
|
|
private $orderData; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Order data type. |
80
|
|
|
* |
81
|
|
|
* @var string |
82
|
|
|
*/ |
83
|
|
|
private $orderDataType; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Order sequence. |
87
|
|
|
* |
88
|
|
|
* @var string |
89
|
|
|
*/ |
90
|
|
|
private $orderSequence; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Orderable. |
94
|
|
|
* |
95
|
|
|
* @var bool |
96
|
|
|
*/ |
97
|
|
|
private $orderable; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Search. |
101
|
|
|
* |
102
|
|
|
* @var DataTablesSearchInterface |
103
|
|
|
*/ |
104
|
|
|
private $search; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Searchable. |
108
|
|
|
* |
109
|
|
|
* @var bool |
110
|
|
|
*/ |
111
|
|
|
private $searchable; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Title. |
115
|
|
|
* |
116
|
|
|
* @var string |
117
|
|
|
*/ |
118
|
|
|
private $title; |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Type. |
122
|
|
|
* |
123
|
|
|
* @var string |
124
|
|
|
*/ |
125
|
|
|
private $type; |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Visible. |
129
|
|
|
* |
130
|
|
|
* @var bool |
131
|
|
|
*/ |
132
|
|
|
private $visible; |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Width. |
136
|
|
|
* |
137
|
|
|
* @var string |
138
|
|
|
*/ |
139
|
|
|
private $width; |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Constructor. |
143
|
|
|
*/ |
144
|
|
|
public function __construct() { |
145
|
|
|
$this->setCellType(self::DATATABLES_CELL_TYPE_TD); |
146
|
|
|
$this->setMapping(new DataTablesMapping()); |
147
|
|
|
$this->setOrderable(true); |
148
|
|
|
$this->setSearchable(true); |
149
|
|
|
$this->setVisible(true); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* {@inheritdoc} |
154
|
|
|
*/ |
155
|
|
|
public function getCellType() { |
156
|
|
|
return $this->cellType; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* {@inheritdoc} |
161
|
|
|
*/ |
162
|
|
|
public function getClassname() { |
163
|
|
|
return $this->classname; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* {@inheritdoc} |
168
|
|
|
*/ |
169
|
|
|
public function getContentPadding() { |
170
|
|
|
return $this->contentPadding; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* {@inheritdoc} |
175
|
|
|
*/ |
176
|
|
|
public function getData() { |
177
|
|
|
return $this->data; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* {@inheritdoc} |
182
|
|
|
*/ |
183
|
|
|
public function getDefaultContent() { |
184
|
|
|
return $this->defaultContent; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* {@inheritdoc} |
189
|
|
|
*/ |
190
|
|
|
public function getMapping() { |
191
|
|
|
return $this->mapping; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* {@inheritdoc} |
196
|
|
|
*/ |
197
|
|
|
public function getName() { |
198
|
|
|
return $this->name; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* {@inheritdoc} |
203
|
|
|
*/ |
204
|
|
|
public function getOrderData() { |
205
|
|
|
return $this->orderData; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* {@inheritdoc} |
210
|
|
|
*/ |
211
|
|
|
public function getOrderDataType() { |
212
|
|
|
return $this->orderDataType; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* {@inheritdoc} |
217
|
|
|
*/ |
218
|
|
|
public function getOrderSequence() { |
219
|
|
|
return $this->orderSequence; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* {@inheritdoc} |
224
|
|
|
*/ |
225
|
|
|
public function getOrderable() { |
226
|
|
|
return $this->orderable; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* {@inheritdoc} |
231
|
|
|
*/ |
232
|
|
|
public function getSearch() { |
233
|
|
|
return $this->search; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* {@inheritdoc} |
238
|
|
|
*/ |
239
|
|
|
public function getSearchable() { |
240
|
|
|
return $this->searchable; |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* {@inheritdoc} |
245
|
|
|
*/ |
246
|
|
|
public function getTitle() { |
247
|
|
|
return $this->title; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* {@inheritdoc} |
252
|
|
|
*/ |
253
|
|
|
public function getType() { |
254
|
|
|
return $this->type; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* {@inheritdoc} |
259
|
|
|
*/ |
260
|
|
|
public function getVisible() { |
261
|
|
|
return $this->visible; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* {@inheritdoc} |
266
|
|
|
*/ |
267
|
|
|
public function getWidth() { |
268
|
|
|
return $this->width; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* Set the cell type. |
273
|
|
|
* |
274
|
|
|
* @param string $cellType The cell type. |
275
|
|
|
* @return DataTablesColumnInterface Returns this column. |
276
|
|
|
*/ |
277
|
|
|
public function setCellType($cellType) { |
278
|
|
|
if (false === in_array($cellType, DataTablesEnumerator::enumCellTypes())) { |
279
|
|
|
$cellType = self::DATATABLES_CELL_TYPE_TD; |
280
|
|
|
} |
281
|
|
|
$this->cellType = $cellType; |
282
|
|
|
return $this; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* Set the class name. |
287
|
|
|
* |
288
|
|
|
* @param string $classname The class name. |
289
|
|
|
* @return DataTablesColumnInterface Returns this column. |
290
|
|
|
*/ |
291
|
|
|
public function setClassname($classname) { |
292
|
|
|
$this->classname = $classname; |
293
|
|
|
return $this; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* Set the content padding. |
298
|
|
|
* |
299
|
|
|
* @param string $contentPadding The content padding. |
300
|
|
|
* @return DataTablesColumnInterface Returns this column. |
301
|
|
|
*/ |
302
|
|
|
public function setContentPadding($contentPadding) { |
303
|
|
|
$this->contentPadding = $contentPadding; |
304
|
|
|
return $this; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* Set the data. |
309
|
|
|
* |
310
|
|
|
* @param integer|string $data The data. |
311
|
|
|
* @return DataTablesColumnInterface Returns this column. |
312
|
|
|
*/ |
313
|
|
|
public function setData($data) { |
314
|
|
|
$this->data = $data; |
315
|
|
|
return $this; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* Set the default content. |
320
|
|
|
* |
321
|
|
|
* @param string $defaultContent The default content. |
322
|
|
|
* @return DataTablesColumnInterface Returns this column. |
323
|
|
|
*/ |
324
|
|
|
public function setDefaultContent($defaultContent) { |
325
|
|
|
$this->defaultContent = $defaultContent; |
326
|
|
|
return $this; |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* Set the mapping. |
331
|
|
|
* |
332
|
|
|
* @param DataTablesMappingInterface $mapping The mapping. |
333
|
|
|
* @return DataTablesColumnInterface Returns this column. |
334
|
|
|
*/ |
335
|
|
|
protected function setMapping(DataTablesMappingInterface $mapping) { |
336
|
|
|
$this->mapping = $mapping; |
337
|
|
|
return $this; |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* Set the name. |
342
|
|
|
* |
343
|
|
|
* @param string $name The name. |
344
|
|
|
* @return DataTablesColumnInterface Returns this column. |
345
|
|
|
*/ |
346
|
|
|
public function setName($name) { |
347
|
|
|
$this->name = $name; |
348
|
|
|
return $this; |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* Set the order data. |
353
|
|
|
* |
354
|
|
|
* @param integer|array $orderData The order data. |
355
|
|
|
* @return DataTablesColumnInterface Returns this column. |
356
|
|
|
*/ |
357
|
|
|
public function setOrderData($orderData) { |
358
|
|
|
$this->orderData = $orderData; |
359
|
|
|
return $this; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
/** |
363
|
|
|
* Set the order data type. |
364
|
|
|
* |
365
|
|
|
* @param string $orderDataType The order data type. |
366
|
|
|
* @return DataTablesColumnInterface Returns this column. |
367
|
|
|
*/ |
368
|
|
|
public function setOrderDataType($orderDataType) { |
369
|
|
|
$this->orderDataType = $orderDataType; |
370
|
|
|
return $this; |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* Set the order sequence. |
375
|
|
|
* |
376
|
|
|
* @param string $orderSequence The order sequence. |
377
|
|
|
* @return DataTablesColumnInterface Returns this column. |
378
|
|
|
*/ |
379
|
|
|
public function setOrderSequence($orderSequence) { |
380
|
|
|
if (false === in_array($orderSequence, DataTablesEnumerator::enumOrderSequences())) { |
381
|
|
|
$orderSequence = null; |
382
|
|
|
} |
383
|
|
|
$this->orderSequence = $orderSequence; |
384
|
|
|
return $this; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* Set the orderable. |
389
|
|
|
* |
390
|
|
|
* @param bool $orderable The orderable. |
391
|
|
|
* @return DataTablesColumnInterface Returns this column. |
392
|
|
|
*/ |
393
|
|
|
public function setOrderable($orderable) { |
394
|
|
|
$this->orderable = $orderable; |
395
|
|
|
return $this; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* Set the search. |
400
|
|
|
* |
401
|
|
|
* @param DataTablesSearchInterface $search The search. |
402
|
|
|
* @return DataTablesColumnInterface Returns this column. |
403
|
|
|
*/ |
404
|
|
|
public function setSearch(DataTablesSearchInterface $search) { |
405
|
|
|
$this->search = $search; |
406
|
|
|
return $this; |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
/** |
410
|
|
|
* Set the searchable. |
411
|
|
|
* |
412
|
|
|
* @param bool $searchable The searchable. |
413
|
|
|
* @return DataTablesColumnInterface Returns this column. |
414
|
|
|
*/ |
415
|
|
|
public function setSearchable($searchable) { |
416
|
|
|
$this->searchable = $searchable; |
417
|
|
|
return $this; |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* Set the title. |
422
|
|
|
* |
423
|
|
|
* @param string $title The title. |
424
|
|
|
* @return DataTablesColumnInterface Returns this column. |
425
|
|
|
*/ |
426
|
|
|
public function setTitle($title) { |
427
|
|
|
$this->title = $title; |
428
|
|
|
return $this; |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
/** |
432
|
|
|
* Set the type. |
433
|
|
|
* |
434
|
|
|
* @param string $type The type. |
435
|
|
|
* @return DataTablesColumnInterface Returns this column. |
436
|
|
|
*/ |
437
|
|
|
public function setType($type) { |
438
|
|
|
if (false === in_array($type, DataTablesEnumerator::enumTypes())) { |
439
|
|
|
$type = null; |
440
|
|
|
} |
441
|
|
|
$this->type = $type; |
442
|
|
|
return $this; |
443
|
|
|
} |
444
|
|
|
|
445
|
|
|
/** |
446
|
|
|
* Set the visible. |
447
|
|
|
* |
448
|
|
|
* @param bool $visible The visible. |
449
|
|
|
* @return DataTablesColumnInterface Returns this column. |
450
|
|
|
*/ |
451
|
|
|
public function setVisible($visible) { |
452
|
|
|
$this->visible = $visible; |
453
|
|
|
return $this; |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* Set the width. |
458
|
|
|
* |
459
|
|
|
* @param string $width The width. |
460
|
|
|
* @return DataTablesColumnInterface Returns this column. |
461
|
|
|
*/ |
462
|
|
|
public function setWidth($width) { |
463
|
|
|
$this->width = $width; |
464
|
|
|
return $this; |
465
|
|
|
} |
466
|
|
|
} |
467
|
|
|
|