ILIAS  release_8 Revision v8.24
class.ilDclCreateViewDefinitionGUI.php
Go to the documentation of this file.
1<?php
2
24{
27 protected ilCtrl $ctrl;
28 protected int $tableview_id;
31
32 public function __construct(int $tableview_id)
33 {
34 global $DIC;
35 $this->ctrl = $DIC['ilCtrl'];
36 $this->tableview_id = $tableview_id;
37 $this->http = $DIC->http();
38 $this->refinery = $DIC->refinery();
39
41
42 // we always need a page object - create on demand
44 $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
45
46 $viewdef = new ilDclCreateViewDefinition();
47 $viewdef->setId($tableview_id);
48 $viewdef->setParentId(ilObject2::_lookupObjectId($ref_id));
49 $viewdef->setActive(false);
50 $viewdef->create();
51 }
52
54
55 $table = new ilDclCreateViewTableGUI($this);
56 $this->table_gui = $table;
57 $this->tpl->setContent($table->getHTML());
58 }
59
60 public function executeCommand(): string
61 {
62 global $DIC;
63 $ilLocator = $DIC['ilLocator'];
64 $lng = $DIC['lng'];
65
66 $next_class = $this->ctrl->getNextClass($this);
67
68 $viewdef = $this->getPageObject();
69 if ($viewdef) {
70 $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
71 $title = $lng->txt("dcl_view_viewdefinition");
72 }
73
74 switch ($next_class) {
75 case "ilpageobjectgui":
76 throw new ilCOPageException("Deprecated. ilDclDetailedViewDefinitionGUI gui forwarding to ilpageobject");
77 default:
78 if ($viewdef) {
79 $this->setPresentationTitle($title);
80 $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
81 }
82
83 return parent::executeCommand();
84 }
85 }
86
87 protected function activate(): void
88 {
89 $page = $this->getPageObject();
90 $page->setActive(true);
91 $page->update();
92 $this->ctrl->redirect($this, 'edit');
93 }
94
95 protected function deactivate(): void
96 {
97 $page = $this->getPageObject();
98 $page->setActive(false);
99 $page->update();
100 $this->ctrl->redirect($this, 'edit');
101 }
102
103 public function confirmDelete(): void
104 {
105 global $DIC;
106 $ilCtrl = $DIC['ilCtrl'];
107 $lng = $DIC['lng'];
108 $tpl = $DIC['tpl'];
109
110 $conf = new ilConfirmationGUI();
111 $conf->setFormAction($ilCtrl->getFormAction($this));
112 $conf->setHeaderText($lng->txt('dcl_confirm_delete_detailed_view_title'));
113
114 $conf->addItem('tableview', $this->tableview_id, $lng->txt('dcl_confirm_delete_detailed_view_text'));
115
116 $conf->setConfirm($lng->txt('delete'), 'deleteView');
117 $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
118
119 $tpl->setContent($conf->getHTML());
120 }
121
122 public function cancelDelete(): void
123 {
124 global $DIC;
125 $ilCtrl = $DIC['ilCtrl'];
126
127 $ilCtrl->redirect($this, "edit");
128 }
129
130 public function deleteView(): void
131 {
132 global $DIC;
133 $ilCtrl = $DIC['ilCtrl'];
134 $lng = $DIC['lng'];
135
136 if ($this->tableview_id && ilDclDetailedViewDefinition::exists($this->tableview_id)) {
137 $pageObject = new ilDclDetailedViewDefinition($this->tableview_id);
138 $pageObject->delete();
139 }
140
141 $this->tpl->setOnScreenMessage('success', $lng->txt("dcl_empty_detailed_view_success"), true);
142
143 // Bug fix for mantis 22537: Redirect to settings-tab instead of fields-tab. This solves the problem and is more intuitive.
144 $ilCtrl->redirectByClass("ilDclTableViewEditGUI", "editGeneralSettings");
145 }
146
152 public function postOutputProcessing(string $a_output): string
153 {
154 // You can use this to parse placeholders and the like before outputting
155
156 if ($this->getOutputMode() == ilPageObjectGUI::PREVIEW) {
157 //page preview is not being used inside DataCollections - if you are here, something's probably wrong
158
159 //
160 // // :TODO: find a suitable presentation for matched placeholders
161 // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
162 // foreach ($allp as $id => $item) {
163 // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
164 // $parsed_item = $parsed_item->getToolbarHTML();
165 //
166 // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
167 // }
168 } // editor
169 else {
170 if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
171 $allp = $this->getPageObject()->getAvailablePlaceholders();
172
173 // :TODO: find a suitable markup for matched placeholders
174 foreach ($allp as $item) {
175 $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
176 }
177 }
178 }
179
180 return $a_output;
181 }
182
186 public function saveTable(): void
187 {
189 $raw_values = $this->http->request()->getParsedBody();
190 foreach ($raw_values as $key => $value) {
191 if (strpos($key, "default_") === 0) {
192 $parts = explode("_", $key);
193 $id = $parts[1];
194 $data_type_id = intval($parts[2]);
195
196 // Delete all field values associated with this id
197 $existing_values = ilDclTableViewBaseDefaultValue::findAll($data_type_id, $id);
198
199 if (!is_null($existing_values)) {
200 foreach ($existing_values as $existing_value) {
201 $existing_value->delete();
202 }
203 }
204
205 // Create fields
206 if ($value !== '') {
207 // Check number field
208 if ($data_type_id === ilDclDatatype::INPUTFORMAT_NUMBER) {
209 if (!ctype_digit($value)) {
210 $this->tpl->setOnScreenMessage(
211 'failure',
212 $this->lng->txt('dcl_tableview_default_value_fail'),
213 true
214 );
215 $this->ctrl->saveParameter($this, 'tableview_id');
216 $this->ctrl->redirect($this, 'presentation');
217 }
218 }
219
220 $default_value = $f->create($data_type_id);
221 $default_value->setTviewSetId($id);
222 $default_value->setValue($value);
223 $default_value->create();
224 }
225 }
226 }
230 foreach ($this->tableview->getFieldSettings() as $setting) {
231 if (!$setting->getFieldObject()->isStandardField()) {
232
233 // Radio Inputs
234 foreach (array("RadioGroup") as $attribute) {
235 $selection_key = $attribute . '_' . $setting->getField();
236 $selection = $this->http->wrapper()->post()->retrieve(
237 $selection_key,
238 $this->refinery->kindlyTo()->string()
239 );
240 $selected_radio_attribute = explode("_", $selection)[0];
241
242 foreach (array("LockedCreate",
243 "RequiredCreate",
244 "VisibleCreate",
245 "NotVisibleCreate"
246 ) as $radio_attribute) {
247 $result = false;
248
249 if ($selected_radio_attribute === $radio_attribute) {
250 $result = true;
251 }
252
253 $setting->{'set' . $radio_attribute}($result);
254 }
255 }
256
257 // Text Inputs
258 foreach (array("DefaultValue") as $attribute) {
259 $key = $attribute . '_' . $setting->getField();
260 if ($this->http->wrapper()->post()->has($key)) {
261 $attribute_value = $this->http->wrapper()->post()->retrieve(
262 $key,
263 $this->refinery->kindlyTo()->string()
264 );
265 } else {
266 $attribute_value = "";
267 }
268
269 $setting->{'set' . $attribute}($attribute_value);
270 }
271
272 $setting->update();
273 }
274 }
275
276 // Set Workflow flag to true
277 $view = ilDclTableView::getCollection()->where(array("id" => filter_input(INPUT_GET, "tableview_id")))->first();
278 if (!is_null($view)) {
279 $view->setStepC(true);
280 $view->save();
281 }
282
283 $this->tpl->setOnScreenMessage('success', $this->lng->txt('dcl_msg_tableview_updated'), true);
284 $this->ctrl->saveParameter($this, 'tableview_id');
285 $this->ctrl->redirect($this, 'presentation');
286 }
287}
Builds data types.
Definition: Factory.php:21
Class Services.
Definition: Services.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
postOutputProcessing(string $a_output)
Finalizing output processing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static findAll(int $data_type_id, int $tview_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static findOrGetInstance($primary_key, array $add_constructor_args=array())
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _lookupObjectId(int $ref_id)
Class ilPageObjectGUI.
setPresentationTitle(string $a_title="")
ilGlobalTemplateInterface $tpl
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
global $DIC
Definition: feed.php:28
setContent(string $a_html)
Sets content for standard template.
$ref_id
Definition: ltiauth.php:67
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193