ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDclTableViewFieldSetting.php
Go to the documentation of this file.
1<?php
2
12{
13
25 protected $id;
34 protected $tableview_id;
44 protected $field;
52 protected $visible;
60 protected $in_filter;
68 protected $filter_value;
92 protected $locked_create;
100 protected $default_value;
118 protected $visible_edit;
126 protected $required_edit;
134 protected $locked_edit;
135
136
141 public static function returnDbTableName()
142 {
143 return "il_dcl_tview_set";
144 }
145
146
150 public function getTableviewId()
151 {
152 return $this->tableview_id;
153 }
154
155
160 {
161 $this->tableview_id = $tableview_id;
162 }
163
164
168 public function getField()
169 {
170 return $this->field;
171 }
172
173
177 public function setField($field)
178 {
179 $this->field = $field;
180 }
181
182
186 public function isVisibleInList()
187 {
188 return $this->visible;
189 }
190
191
195 public function setVisible($visible)
196 {
197 $this->visible = $visible;
198 }
199
200
204 public function isInFilter()
205 {
206 return $this->in_filter;
207 }
208
209
213 public function setInFilter($in_filter)
214 {
215 $this->in_filter = $in_filter;
216 }
217
218
222 public function getFilterValue()
223 {
224 return $this->filter_value;
225 }
226
227
232 {
233 $this->filter_value = $filter_value;
234 }
235
236
240 public function isFilterChangeable()
241 {
243 }
244
245
250 {
251 $this->filter_changeable = $filter_changeable;
252 }
253
254
258 public function getId()
259 {
260 return $this->id;
261 }
262
263
267 public function setId($id)
268 {
269 $this->id = $id;
270 }
271
272
276 public function isRequiredCreate()
277 {
279 }
280
281
286 {
287 $this->required_create = $required_create;
288 }
289
290
294 public function isLockedCreate()
295 {
297 }
298
299
304 {
305 $this->locked_create = $locked_create;
306 }
307
308
312 public function isRequiredEdit()
313 {
315 }
316
317
322 {
323 $this->required_edit = $required_edit;
324 }
325
326
330 public function isLockedEdit()
331 {
332 return $this->locked_edit;
333 }
334
335
340 {
341 $this->locked_edit = $locked_edit;
342 }
343
344
348 public function getDefaultValue()
349 {
351 }
352
353
358 {
359 $this->default_value = $default_value;
360 }
361
362
366 public function isVisibleCreate()
367 {
369 }
370
371
376 {
377 $this->visible_create = $visible_create;
378 }
379
380
384 public function setNotVisibleCreate(bool $not_visible_create) : void
385 {
386 $this->visible_create = !$not_visible_create;
387 }
388
389
393 public function isNotVisibleCreate() : bool
394 {
395 return !$this->visible_create;
396 }
397
398
402 public function isVisibleEdit()
403 {
404 return $this->visible_edit;
405 }
406
407
412 {
413 $this->visible_edit = $visible_edit;
414 }
415
419 public function setNotVisibleEdit(bool $not_visible) : void
420 {
421 $this->visible_edit = !$not_visible;
422 }
423
427 public function isNotVisibleEdit() : bool
428 {
429 return !$this->visible_edit;
430 }
431
436 public function isVisibleInForm(bool $creation_mode) : bool
437 {
438 return $creation_mode ? $this->isVisibleCreate() : $this->isVisibleEdit();
439 }
440
445 public function isLocked(bool $creation_mode) : bool
446 {
447 return $creation_mode ? $this->isLockedCreate() : $this->isLockedEdit();
448 }
449
454 public function isRequired(bool $creation_mode) : bool
455 {
456 return $creation_mode ? $this->isRequiredCreate() : $this->isRequiredEdit();
457 }
458
464 public function sleep($field_name)
465 {
466 if ($field_name == 'filter_value' && is_array($this->filter_value)) {
467 return json_encode($this->filter_value);
468 }
469
470 return null;
471 }
472
473
480 public function wakeUp($field_name, $field_value)
481 {
482 if ($field_name == 'filter_value') {
483 $return = array();
484 $json = json_decode($field_value, true);
485 if (is_array($json)) {
486 foreach ($json as $key => $value) {
487 $return['filter_' . $this->getField() . '_' . $key] = $value;
488 }
489 } else {
490 $return = array('filter_' . $this->getField() => $field_value);
491 }
492
493 return $return;
494 }
495
496 return null;
497 }
498
499
501 {
503 $this->setInFilter($orig->isInFilter());
504 $this->setVisible($orig->isVisibleInList());
505 $this->setVisibleCreate($orig->isVisibleCreate());
506 $this->setVisibleEdit($orig->isVisibleEdit());
507 $this->setLockedCreate($orig->isLockedCreate());
508 $this->setLockedEdit($orig->isLockedEdit());
509 $this->setRequiredCreate($orig->isRequiredCreate());
510 $this->setRequiredEdit($orig->isRequiredEdit());
511 $this->setFilterValue($orig->getFilterValue());
512 $this->create();
513 return $this->getId();
514 }
515
516
520 public function getFieldObject()
521 {
522 if (is_numeric($this->field)) { //normal field
523 return ilDclCache::getFieldCache($this->field);
524 } else { //standard field
525 global $DIC;
526 $lng = $DIC['lng'];
527 $stdfield = new ilDclStandardField();
528 $stdfield->setId($this->field);
529 $stdfield->setDatatypeId(ilDclStandardField::_getDatatypeForId($this->field));
530 $stdfield->setTitle($lng->txt('dcl_' . $this->field));
531
532 return $stdfield;
533 }
534 }
535
536
543 public static function getInstance($tableview_id, $field_id)
544 {
545 if ($setting = self::where(array('field' => $field_id, 'tableview_id' => $tableview_id))->first()) {
546 return $setting;
547 } else {
548 $setting = new self();
549 $setting->setField($field_id);
550 $setting->setTableviewId($tableview_id);
551
552 return $setting;
553 }
554 }
555}
Class ActiveRecord.
An exception for terminatinating execution or to throw for unit testing.
static getFieldCache($field_id=0)
Class ilDclBaseFieldModel.
static _getDatatypeForId($id)
gives you the datatype id of a specified standard field.
Class ilDclTableViewFieldSetting.
cloneStructure(ilDclTableViewFieldSetting $orig)
static getInstance($tableview_id, $field_id)
global $DIC
Definition: goto.php:24
$lng