ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDclCreateViewDefinitionGUI.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 ilDclCreateViewTableGUI($this);
50 $this->tpl->setContent($table->getHTML());
51 return '';
52
53 }
54
55 public function saveTable(): void
56 {
58 $raw_values = $this->http->request()->getParsedBody();
59 foreach ($raw_values as $key => $value) {
60 if (strpos($key, "default_") === 0) {
61 $parts = explode("_", $key);
62 $id = $parts[1];
63 $data_type_id = intval($parts[2]);
64
65 // Delete all field values associated with this id
66 $existing_values = ilDclTableViewBaseDefaultValue::findAll($data_type_id, (int) $id);
67
68 if (!is_null($existing_values)) {
69 foreach ($existing_values as $existing_value) {
70 $existing_value->delete();
71 }
72 }
73
74 // Create fields
75 if ($value !== '') {
76 // Check number field
77 $default_value = $f->create($data_type_id);
78 if ($data_type_id === ilDclDatatype::INPUTFORMAT_NUMBER) {
79 if (!ctype_digit($value)) {
80 $this->tpl->setOnScreenMessage(
81 'failure',
82 $this->lng->txt('dcl_tableview_default_value_fail'),
83 true
84 );
85 $this->ctrl->saveParameter($this, 'tableview_id');
86 $this->ctrl->redirect($this, 'presentation');
87 }
88 }
89
90 if ($default_value::class == ilDclTableViewNumberDefaultValue::class) {
91 $default_value->setValue((int) $value);
92 } else {
93 $default_value->setValue($value);
94 }
95 $default_value->setTviewSetId((int) $id);
96 $default_value->create();
97 }
98 }
99 }
103 foreach ($this->tableview->getFieldSettings() as $setting) {
104 if (!$setting->getFieldObject()->isStandardField()) {
105
106 // Radio Inputs
107 $attribute = "RadioGroup";
108 $selection_key = $attribute . '_' . $setting->getField();
109 $selection = $this->http->wrapper()->post()->retrieve(
110 $selection_key,
111 $this->refinery->kindlyTo()->string()
112 );
113 $selected_radio_attribute = explode("_", $selection)[0];
114
115 foreach (["LockedCreate",
116 "RequiredCreate",
117 "VisibleCreate",
118 "NotVisibleCreate"
119 ] as $radio_attribute) {
120 $result = false;
121
122 if ($selected_radio_attribute === $radio_attribute) {
123 $result = true;
124 }
125
126 $setting->{'set' . $radio_attribute}($result);
127 }
128
129 // Text Inputs
130 $attribute = "DefaultValue";
131 $key = $attribute . '_' . $setting->getField();
132 if ($this->http->wrapper()->post()->has($key)) {
133 $attribute_value = $this->http->wrapper()->post()->retrieve(
134 $key,
135 $this->refinery->kindlyTo()->string()
136 );
137 } else {
138 $attribute_value = "";
139 }
140
141 $setting->{'set' . $attribute}($attribute_value);
142
143 $setting->update();
144 }
145 }
146
147 $this->tpl->setOnScreenMessage('success', $this->lng->txt('dcl_msg_tableview_updated'), true);
148 $this->ctrl->saveParameter($this, 'tableview_id');
149 $this->ctrl->redirect($this, 'presentation');
150 }
151}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Builds data types.
Definition: Factory.php:36
Class Services.
Definition: Services.php:38
Class ilCtrl provides processing control methods.
@ilCtrl_IsCalledBy ilDclCreateViewDefinitionGUI: ilDclTableViewEditGUI
static findAll(int $data_type_id, int $tview_id)
static findOrGetInstance($primary_key, array $add_constructor_args=[])
language handling
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26