ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDclEditViewDefinitionGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
27 protected ilCtrl $ctrl;
28 protected ilLanguage $lng;
32
33 public function __construct(int $tableview_id)
34 {
35 global $DIC;
36 $this->ctrl = $DIC->ctrl();
37 $this->lng = $DIC->language();
38 $this->http = $DIC->http();
39 $this->refinery = $DIC->refinery();
40 $this->tpl = $DIC->ui()->mainTemplate();
41 $this->tableview = ilDclTableView::findOrGetInstance($tableview_id);
42 }
43
44 public function executeCommand(): string
45 {
46 if ($this->ctrl->getCmd() === 'saveTable') {
47 $this->saveTable();
48 }
49 $table = new ilDclEditViewTableGUI($this);
50 $this->tpl->setContent($table->getHTML());
51 return '';
52 }
53
54 public function saveTable(): void
55 {
56 foreach ($this->tableview->getFieldSettings() as $setting) {
57 if (!$setting->getFieldObject()->isStandardField() || $setting->getFieldObject()->getId() === 'owner') {
58
59 // Radio Inputs
60 $attribute = "RadioGroup";
61 $selection_key = $attribute . '_' . $setting->getField();
62 $selection = $this->http->wrapper()->post()->retrieve(
63 $selection_key,
64 $this->refinery->kindlyTo()->string()
65 );
66 $selected_radio_attribute = explode("_", $selection)[0];
67
68 foreach (["LockedEdit", "RequiredEdit", "VisibleEdit", "NotVisibleEdit"] as $radio_attribute) {
69 $result = false;
70
71 if ($selected_radio_attribute === $radio_attribute) {
72 $result = true;
73 }
74
75 $setting->{'set' . $radio_attribute}($result);
76 }
77
78 // Text Inputs
79 $attribute = "DefaultValue";
80 $key = $attribute . '_' . $setting->getField();
81 if ($this->http->wrapper()->post()->has($key)) {
82 $attribute_value = $this->http->wrapper()->post()->retrieve(
83 $key,
84 $this->refinery->kindlyTo()->string()
85 );
86 } else {
87 $attribute_value = "";
88 }
89
90 $setting->{'set' . $attribute}($attribute_value);
91
92 $setting->update();
93 }
94 }
95
96 $this->tpl->setOnScreenMessage('success', $this->lng->txt('dcl_msg_tableview_updated'), true);
97 $this->ctrl->saveParameter($this, 'tableview_id');
98 $this->ctrl->redirect($this, 'presentation');
99 }
100}
Builds data types.
Definition: Factory.php:36
Class Services.
Definition: Services.php:38
Class ilCtrl provides processing control methods.
@ilCtrl_IsCalledBy ilDclEditViewDefinitionGUI: ilDclTableViewEditGUI
static findOrGetInstance($primary_key, array $add_constructor_args=[])
language handling
Class ilPageObjectGUI.
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26