ILIAS  release_8 Revision v8.24
class.ilDclTableViewFieldSetting.php
Go to the documentation of this file.
1<?php
2
20{
31 protected ?int $id;
39 protected int $tableview_id;
47 protected string $field = "";
54 protected bool $visible = false;
61 protected bool $in_filter = false;
68 protected $filter_value = "";
75 protected bool $filter_changeable = false;
82 protected bool $required_create = false;
89 protected bool $locked_create = false;
96 protected ?string $default_value = null;
104 protected bool $visible_create = false;
112 protected bool $visible_edit = false;
119 protected bool $required_edit = false;
126 protected bool $locked_edit = false;
127
132 public static function returnDbTableName(): string
133 {
134 return "il_dcl_tview_set";
135 }
136
137 public function getTableviewId(): int
138 {
139 return $this->tableview_id;
140 }
141
142 public function setTableviewId(int $tableview_id): void
143 {
144 $this->tableview_id = $tableview_id;
145 }
146
147 public function getField(): string
148 {
149 return $this->field;
150 }
151
155 public function setField(string $field): void
156 {
157 $this->field = $field;
158 }
159
160 public function isVisibleInList(): bool
161 {
162 return $this->visible;
163 }
164
165 public function setVisible(bool $visible): void
166 {
167 $this->visible = $visible;
168 }
169
170 public function isInFilter(): bool
171 {
172 return $this->in_filter;
173 }
174
175 public function setInFilter(bool $in_filter): void
176 {
177 $this->in_filter = $in_filter;
178 }
179
180 public function getFilterValue()
181 {
182 return $this->filter_value;
183 }
184
185 public function setFilterValue($filter_value): void
186 {
187 $this->filter_value = $filter_value;
188 }
189
190 public function isFilterChangeable(): bool
191 {
193 }
194
195 public function setFilterChangeable(bool $filter_changeable): void
196 {
197 $this->filter_changeable = $filter_changeable;
198 }
199
200 public function getId(): int
201 {
202 return $this->id;
203 }
204
205 public function setId(int $id): void
206 {
207 $this->id = $id;
208 }
209
210 public function isRequiredCreate(): bool
211 {
213 }
214
215 public function setRequiredCreate(bool $required_create): void
216 {
217 $this->required_create = $required_create;
218 }
219
220 public function isLockedCreate(): bool
221 {
223 }
224
225 public function setLockedCreate(bool $locked_create): void
226 {
227 $this->locked_create = $locked_create;
228 }
229
230 public function isRequiredEdit(): bool
231 {
233 }
234
235 public function setRequiredEdit(bool $required_edit): void
236 {
237 $this->required_edit = $required_edit;
238 }
239
240 public function isLockedEdit(): bool
241 {
242 return $this->locked_edit;
243 }
244
245 public function setLockedEdit(bool $locked_edit): void
246 {
247 $this->locked_edit = $locked_edit;
248 }
249
250 public function getDefaultValue(): ?string
251 {
253 }
254
255 public function setDefaultValue(?string $default_value): void
256 {
257 $this->default_value = $default_value;
258 }
259
260 public function isVisibleCreate(): bool
261 {
263 }
264
265 public function setVisibleCreate(bool $visible_create): void
266 {
267 $this->visible_create = $visible_create;
268 }
269
270 public function setNotVisibleCreate(bool $not_visible_create): void
271 {
272 $this->visible_create = !$not_visible_create;
273 }
274
275 public function isNotVisibleCreate(): bool
276 {
277 return !$this->visible_create;
278 }
279
280 public function isVisibleEdit(): bool
281 {
282 return $this->visible_edit;
283 }
284
285 public function setVisibleEdit(bool $visible_edit): void
286 {
287 $this->visible_edit = $visible_edit;
288 }
289
290 public function setNotVisibleEdit(bool $not_visible): void
291 {
292 $this->visible_edit = !$not_visible;
293 }
294
295 public function isNotVisibleEdit(): bool
296 {
297 return !$this->visible_edit;
298 }
299
300 public function isVisibleInForm(bool $creation_mode): bool
301 {
302 return $creation_mode ? $this->isVisibleCreate() : $this->isVisibleEdit();
303 }
304
305 public function isLocked(bool $creation_mode): bool
306 {
307 return $creation_mode ? $this->isLockedCreate() : $this->isLockedEdit();
308 }
309
310 public function isRequired(bool $creation_mode): bool
311 {
312 return $creation_mode ? $this->isRequiredCreate() : $this->isRequiredEdit();
313 }
314
319 public function sleep($field_name)
320 {
321 if ($field_name == 'filter_value' && is_array($this->filter_value)) {
322 return json_encode($this->filter_value);
323 }
324
325 return null;
326 }
327
328 public function wakeUp($field_name, $field_value): ?array
329 {
330 if ($field_name == 'filter_value') {
331 $return = array();
332 $json = json_decode($field_value, true);
333 if (is_array($json)) {
334 foreach ($json as $key => $value) {
335 $return['filter_' . $this->getField() . '_' . $key] = $value;
336 }
337 } else {
338 $return = array('filter_' . $this->getField() => $field_value);
339 }
340
341 return $return;
342 }
343
344 return null;
345 }
346
348 {
350 $this->setInFilter($orig->isInFilter());
351 $this->setVisibleCreate($orig->isVisibleCreate());
352 $this->setVisibleEdit($orig->isVisibleEdit());
353 $this->setLockedCreate($orig->isLockedCreate());
354 $this->setLockedEdit($orig->isLockedEdit());
355 $this->setRequiredCreate($orig->isRequiredCreate());
356 $this->setRequiredEdit($orig->isRequiredEdit());
357 $this->setFilterValue($orig->getFilterValue());
358 $this->setVisible($orig->isVisibleInList());
359 $this->create();
360 return $this->getId();
361 }
362
366 public function getFieldObject()
367 {
368 if (is_numeric($this->field)) { //normal field
369 return ilDclCache::getFieldCache($this->field);
370 } else { //standard field
371 global $DIC;
372 $lng = $DIC['lng'];
373 $stdfield = new ilDclStandardField();
374 $stdfield->setId($this->field);
375 $stdfield->setDatatypeId(ilDclStandardField::_getDatatypeForId($this->field));
376 $stdfield->setTitle($lng->txt('dcl_' . $this->field));
377
378 return $stdfield;
379 }
380 }
381
385 public static function getTableViewFieldSetting(string $id, int $tableview_id): ActiveRecord
386 {
387 return parent::where(array('field' => $id,
388 'tableview_id' => $tableview_id
389 ))->first();
390 }
391
397 public static function getInstance(int $tableview_id, int $field_id): ActiveRecord
398 {
399 if (!($setting = self::where(array('field' => $field_id, 'tableview_id' => $tableview_id))->first())) {
400 $setting = new self();
401 $setting->setField($field_id);
402 $setting->setTableviewId($tableview_id);
403 }
404 return $setting;
405 }
406}
Class ActiveRecord.
static getFieldCache(int $field_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getDatatypeForId(string $id)
gives you the datatype id of a specified standard field.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
cloneStructure(ilDclTableViewFieldSetting $orig)
static getTableViewFieldSetting(string $id, int $tableview_id)
static getInstance(int $tableview_id, int $field_id)
global $DIC
Definition: feed.php:28
string $key
Consumer key/client ID value.
Definition: System.php:193
$lng