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