ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDclCreateViewDefinitionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
13{
14
18 public $obj;
22 public $ctrl;
26 public $tableview;
30 protected $table_gui;
31
32
37 public function __construct($tableview_id, $a_definition_id = 0)
38 {
39 global $DIC;
40 $tpl = $DIC['tpl'];
41 $ilCtrl = $DIC['ilCtrl'];
45 $this->ctrl = $ilCtrl;
46 $this->tableview = ilDclTableView::findOrGetInstance($tableview_id);
47
48 // we always need a page object - create on demand
49 if (!ilPageObject::_exists('dclf', $tableview_id)) {
50 $viewdef = new ilDclCreateViewDefinition();
51 $viewdef->setId($tableview_id);
52 $viewdef->setParentId(ilObject2::_lookupObjectId($_GET['ref_id']));
53 $viewdef->setActive(false);
54 $viewdef->create();
55 }
56
57 parent::__construct("dclf", $tableview_id);
58
59 $table = new ilDclCreateViewTableGUI($this);
60 $this->table_gui = $table;
61 $this->tpl->setContent($table->getHTML());
62
63 }
64
65
69 public function executeCommand()
70 {
71 global $DIC;
72 $ilLocator = $DIC['ilLocator'];
73 $lng = $DIC['lng'];
74
75 $next_class = $this->ctrl->getNextClass($this);
76
77 $viewdef = $this->getPageObject();
78 if ($viewdef) {
79 $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
80 $title = $lng->txt("dcl_view_viewdefinition");
81 }
82
83 switch ($next_class) {
84 case "ilpageobjectgui":
85 throw new ilCOPageException("Deprecated. ilDclDetailedViewDefinitionGUI gui forwarding to ilpageobject");
86 default:
87 if ($viewdef) {
88 $this->setPresentationTitle($title);
89 $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
90 }
91
92 return parent::executeCommand();
93 }
94 }
95
96
100 protected function activate()
101 {
102 $page = $this->getPageObject();
103 $page->setActive(true);
104 $page->update();
105 $this->ctrl->redirect($this, 'edit');
106 }
107
108
112 protected function deactivate()
113 {
114 $page = $this->getPageObject();
115 $page->setActive(false);
116 $page->update();
117 $this->ctrl->redirect($this, 'edit');
118 }
119
120
124 public function confirmDelete()
125 {
126 global $DIC;
127 $ilCtrl = $DIC['ilCtrl'];
128 $lng = $DIC['lng'];
129 $tpl = $DIC['tpl'];
130
131 $conf = new ilConfirmationGUI();
132 $conf->setFormAction($ilCtrl->getFormAction($this));
133 $conf->setHeaderText($lng->txt('dcl_confirm_delete_detailed_view_title'));
134
135 $conf->addItem('tableview', (int) $this->tableview_id, $lng->txt('dcl_confirm_delete_detailed_view_text'));
136
137 $conf->setConfirm($lng->txt('delete'), 'deleteView');
138 $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
139
140 $tpl->setContent($conf->getHTML());
141 }
142
143
147 public function cancelDelete()
148 {
149 global $DIC;
150 $ilCtrl = $DIC['ilCtrl'];
151
152 $ilCtrl->redirect($this, "edit");
153 }
154
155
159 public function deleteView()
160 {
161 global $DIC;
162 $ilCtrl = $DIC['ilCtrl'];
163 $lng = $DIC['lng'];
164
165 if ($this->tableview_id && ilDclDetailedViewDefinition::exists($this->tableview_id)) {
166 $pageObject = new ilDclDetailedViewDefinition($this->tableview_id);
167 $pageObject->delete();
168 }
169
170 ilUtil::sendSuccess($lng->txt("dcl_empty_detailed_view_success"), true);
171
172 // Bug fix for mantis 22537: Redirect to settings-tab instead of fields-tab. This solves the problem and is more intuitive.
173 $ilCtrl->redirectByClass("ilDclTableViewEditGUI", "editGeneralSettings");
174 }
175
176
181 public function releasePageLock()
182 {
183 global $DIC;
184 $ilCtrl = $DIC['ilCtrl'];
185 $lng = $DIC['lng'];
186
187 $this->getPageObject()->releasePageLock();
188 ilUtil::sendSuccess($lng->txt("cont_page_lock_released"), true);
189 $ilCtrl->redirectByClass('ilDclTableViewGUI', "show");
190 }
191
192
200 public function postOutputProcessing($a_output)
201 {
202 // You can use this to parse placeholders and the like before outputting
203
204 if ($this->getOutputMode() == ilPageObjectGUI::PREVIEW) {
205 //page preview is not being used inside DataCollections - if you are here, something's probably wrong
206
207 //
208 // // :TODO: find a suitable presentation for matched placeholders
209 // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
210 // foreach ($allp as $id => $item) {
211 // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
212 // $parsed_item = $parsed_item->getToolbarHTML();
213 //
214 // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
215 // }
216 } // editor
217 else {
218 if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
219 $allp = $this->getPageObject()->getAvailablePlaceholders();
220
221 // :TODO: find a suitable markup for matched placeholders
222 foreach ($allp as $item) {
223 $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
224 }
225 }
226 }
227
228 return $a_output;
229 }
230
231
235 public function saveTable() {
237 foreach ($_POST as $key => $value) {
238 if (strpos($key, "default_") === 0) {
239 $parts = explode("_", $key);
240 $id = $parts[1];
241 $data_type_id = intval($parts[2]);
242
243 // Delete all field values associated with this id
244 $existing_values = ilDclTableViewBaseDefaultValue::findAll($data_type_id, $id);
245
246 if (!is_null($existing_values)) {
247 foreach ($existing_values as $existing_value) {
248 $existing_value->delete();
249 }
250 }
251
252 // Create fields
253 if ($value !== '') {
254 // Check number field
255 if ($data_type_id === ilDclDatatype::INPUTFORMAT_NUMBER) {
256 if (!ctype_digit($value)) {
257 ilUtil::sendFailure($this->lng->txt('dcl_tableview_default_value_fail'), true);
258 $this->ctrl->saveParameter($this, 'tableview_id');
259 $this->ctrl->redirect($this, 'presentation');
260 }
261 }
262
263 $default_value = $f->create($data_type_id);
264 $default_value->setTviewSetId($id);
265 $default_value->setValue($value);
266 $default_value->create();
267 }
268 }
269 }
273 foreach ($this->tableview->getFieldSettings() as $setting) {
274
275 if (!$setting->getFieldObject()->isStandardField()) {
276
277 // Radio Inputs
278 foreach (array("RadioGroup") as $attribute) {
279 $selection_key = $attribute . '_' . $setting->getField();
280 $selection = $_POST[$selection_key];
281 $selected_radio_attribute = explode("_", $selection)[0];
282
283 foreach (array("LockedCreate", "RequiredCreate", "VisibleCreate", "NotVisibleCreate") as $radio_attribute) {
284 $result = false;
285
286 if ($selected_radio_attribute === $radio_attribute) {
287 $result = true;
288 }
289
290 $setting->{'set' . $radio_attribute}($result);
291 }
292 }
293
294 // Text Inputs
295 foreach (array("DefaultValue") as $attribute) {
296 $key = $attribute . '_' . $setting->getField();
297 $setting->{'set' . $attribute}($_POST[$key]);
298 }
299
300 $setting->update();
301 }
302 }
303
304 // Set Workflow flag to true
305 $view = ilDclTableView::getCollection()->where(array("id" => filter_input(INPUT_GET, "tableview_id")))->first();
306 if (!is_null($view)) {
307 $view->setStepC(true);
308 $view->save();
309 }
310
311 ilUtil::sendSuccess($this->lng->txt('dcl_msg_tableview_updated'), true);
312 $this->ctrl->saveParameter($this, 'tableview_id');
313 $this->ctrl->redirect($this, 'presentation');
314 }
315}
$result
$_GET["client_id"]
$_POST["username"]
static findOrGetInstance($primary_key, array $add_constructor_args=array())
An exception for terminatinating execution or to throw for unit testing.
Base exception class for copage service.
Confirmation screen class.
Class ilDclCreateViewDefinitionGUI.
postOutputProcessing($a_output)
Finalizing output processing.
releasePageLock()
Release page lock overwrite to redirect properly.
Class ilDclCreateViewDefinition.
Class ilDclCreateViewTableGUI.
Class ilDclDetailedViewDefinition.
static _lookupObjectId($a_ref_id)
lookup object id
Class ilPageObjectGUI.
__construct( $a_parent_type, $a_id, $a_old_nr=0, $a_prevent_get_id=false, $a_lang="", $concrete_lang="")
Constructor.
setPresentationTitle($a_title="")
getPageObject()
Get Page Object.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc