ILIAS  release_8 Revision v8.24
class.ilDclEditViewDefinitionGUI.php
Go to the documentation of this file.
1<?php
2
24{
29 protected int $tableview_id;
30
31 public function __construct(int $tableview_id)
32 {
33 global $DIC;
34 $this->tableview_id = $tableview_id;
36 $this->http = $DIC->http();
37 $this->refinery = $DIC->refinery();
38
39 // we always need a page object - create on demand
41 $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
42
43 $viewdef = new ilDclEditViewDefinition();
44 $viewdef->setId($tableview_id);
45 $viewdef->setParentId(ilObject2::_lookupObjectId($ref_id));
46 $viewdef->setActive(false);
47 $viewdef->create();
48 }
49
51
52 $table = new ilDclEditViewTableGUI($this);
53 $this->table_gui = $table;
54 $this->tpl->setContent($table->getHTML());
55 }
56
57 public function executeCommand(): string
58 {
59 global $DIC;
60 $ilLocator = $DIC['ilLocator'];
61 $lng = $DIC['lng'];
62
63 $next_class = $this->ctrl->getNextClass($this);
64
65 $viewdef = $this->getPageObject();
66 if ($viewdef) {
67 $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
68 $title = $lng->txt("dcl_view_viewdefinition");
69 }
70
71 switch ($next_class) {
72 case "ilpageobjectgui":
73 throw new ilCOPageException("Deprecated. ilDclDetailedViewDefinitionGUI gui forwarding to ilpageobject");
74 default:
75 if ($viewdef) {
76 $this->setPresentationTitle($title);
77 $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
78 }
79
80 return parent::executeCommand();
81 }
82 }
83
84 protected function activate(): void
85 {
86 $page = $this->getPageObject();
87 $page->setActive(true);
88 $page->update();
89 $this->ctrl->redirect($this, 'edit');
90 }
91
92 protected function deactivate(): void
93 {
94 $page = $this->getPageObject();
95 $page->setActive(false);
96 $page->update();
97 $this->ctrl->redirect($this, 'edit');
98 }
99
100 public function confirmDelete(): void
101 {
102 global $DIC;
103 $ilCtrl = $DIC['ilCtrl'];
104 $lng = $DIC['lng'];
105 $tpl = $DIC['tpl'];
106
107 $conf = new ilConfirmationGUI();
108 $conf->setFormAction($ilCtrl->getFormAction($this));
109 $conf->setHeaderText($lng->txt('dcl_confirm_delete_detailed_view_title'));
110
111 $conf->addItem('tableview', $this->tableview_id, $lng->txt('dcl_confirm_delete_detailed_view_text'));
112
113 $conf->setConfirm($lng->txt('delete'), 'deleteView');
114 $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
115
116 $tpl->setContent($conf->getHTML());
117 }
118
119 public function cancelDelete(): void
120 {
121 global $DIC;
122 $ilCtrl = $DIC['ilCtrl'];
123
124 $ilCtrl->redirect($this, "edit");
125 }
126
127 public function deleteView(): void
128 {
129 global $DIC;
130 $ilCtrl = $DIC['ilCtrl'];
131 $lng = $DIC['lng'];
132
133 if ($this->tableview_id && ilDclDetailedViewDefinition::exists($this->tableview_id)) {
134 $pageObject = new ilDclDetailedViewDefinition($this->tableview_id);
135 $pageObject->delete();
136 }
137
138 $this->tpl->setOnScreenMessage('success', $lng->txt("dcl_empty_detailed_view_success"), true);
139
140 // Bug fix for mantis 22537: Redirect to settings-tab instead of fields-tab. This solves the problem and is more intuitive.
141 $ilCtrl->redirectByClass("ilDclTableViewEditGUI", "editGeneralSettings");
142 }
143
149 public function postOutputProcessing(string $a_output): string
150 {
151 // You can use this to parse placeholders and the like before outputting
152
153 if ($this->getOutputMode() == ilPageObjectGUI::PREVIEW) {
154 //page preview is not being used inside DataCollections - if you are here, something's probably wrong
155
156 //
157 // // :TODO: find a suitable presentation for matched placeholders
158 // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
159 // foreach ($allp as $id => $item) {
160 // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
161 // $parsed_item = $parsed_item->getToolbarHTML();
162 //
163 // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
164 // }
165 } // editor
166 else {
167 if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
168 $allp = $this->getPageObject()->getAvailablePlaceholders();
169
170 // :TODO: find a suitable markup for matched placeholders
171 foreach ($allp as $item) {
172 $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
173 }
174 }
175 }
176
177 return $a_output;
178 }
179
183 public function saveTable(): void
184 {
188 foreach ($this->tableview->getFieldSettings() as $setting) {
189 if (!$setting->getFieldObject()->isStandardField() || $setting->getFieldObject()->getId() === 'owner') {
190
191 // Radio Inputs
192 foreach (array("RadioGroup") as $attribute) {
193 $selection_key = $attribute . '_' . $setting->getField();
194 $selection = $this->http->wrapper()->post()->retrieve(
195 $selection_key,
196 $this->refinery->kindlyTo()->string()
197 );
198 $selected_radio_attribute = explode("_", $selection)[0];
199
200 foreach (array("LockedEdit", "RequiredEdit", "VisibleEdit", "NotVisibleEdit") as $radio_attribute) {
201 $result = false;
202
203 if ($selected_radio_attribute === $radio_attribute) {
204 $result = true;
205 }
206
207 $setting->{'set' . $radio_attribute}($result);
208 }
209 }
210
211 // Text Inputs
212 foreach (array("DefaultValue") as $attribute) {
213 $key = $attribute . '_' . $setting->getField();
214 if ($this->http->wrapper()->post()->has($key)) {
215 $attribute_value = $this->http->wrapper()->post()->retrieve(
216 $key,
217 $this->refinery->kindlyTo()->string()
218 );
219 } else {
220 $attribute_value = "";
221 }
222
223 $setting->{'set' . $attribute}($attribute_value);
224 }
225
226 $setting->update();
227 }
228 }
229
230 // Set Workflow flag to true
231 $view = ilDclTableView::getCollection()->where(array("id" => filter_input(INPUT_GET, "tableview_id")))->first();
232 if (!is_null($view)) {
233 $view->setStepE(true);
234 $view->save();
235 }
236
237 $this->tpl->setOnScreenMessage('success', $this->lng->txt('dcl_msg_tableview_updated'), true);
238 $this->ctrl->saveParameter($this, 'tableview_id');
239 $this->ctrl->redirect($this, 'presentation');
240 }
241}
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...
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...
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...
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
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