ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDclEditViewDefinitionGUI.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 ilDclEditViewDefinition();
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 ilDclEditViewTableGUI($this);
60 $this->table_gui = $table;
61 $this->tpl->setContent($table->getHTML());
62 }
63
64
68 public function executeCommand()
69 {
70 global $DIC;
71 $ilLocator = $DIC['ilLocator'];
72 $lng = $DIC['lng'];
73
74 $next_class = $this->ctrl->getNextClass($this);
75
76 $viewdef = $this->getPageObject();
77 if ($viewdef) {
78 $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
79 $title = $lng->txt("dcl_view_viewdefinition");
80 }
81
82 switch ($next_class) {
83 case "ilpageobjectgui":
84 throw new ilCOPageException("Deprecated. ilDclDetailedViewDefinitionGUI gui forwarding to ilpageobject");
85 default:
86 if ($viewdef) {
87 $this->setPresentationTitle($title);
88 $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
89 }
90
91 return parent::executeCommand();
92 }
93 }
94
95
99 protected function activate()
100 {
101 $page = $this->getPageObject();
102 $page->setActive(true);
103 $page->update();
104 $this->ctrl->redirect($this, 'edit');
105 }
106
107
111 protected function deactivate()
112 {
113 $page = $this->getPageObject();
114 $page->setActive(false);
115 $page->update();
116 $this->ctrl->redirect($this, 'edit');
117 }
118
119
123 public function confirmDelete()
124 {
125 global $DIC;
126 $ilCtrl = $DIC['ilCtrl'];
127 $lng = $DIC['lng'];
128 $tpl = $DIC['tpl'];
129
130 $conf = new ilConfirmationGUI();
131 $conf->setFormAction($ilCtrl->getFormAction($this));
132 $conf->setHeaderText($lng->txt('dcl_confirm_delete_detailed_view_title'));
133
134 $conf->addItem('tableview', (int) $this->tableview_id, $lng->txt('dcl_confirm_delete_detailed_view_text'));
135
136 $conf->setConfirm($lng->txt('delete'), 'deleteView');
137 $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
138
139 $tpl->setContent($conf->getHTML());
140 }
141
142
146 public function cancelDelete()
147 {
148 global $DIC;
149 $ilCtrl = $DIC['ilCtrl'];
150
151 $ilCtrl->redirect($this, "edit");
152 }
153
154
158 public function deleteView()
159 {
160 global $DIC;
161 $ilCtrl = $DIC['ilCtrl'];
162 $lng = $DIC['lng'];
163
164 if ($this->tableview_id && ilDclDetailedViewDefinition::exists($this->tableview_id)) {
165 $pageObject = new ilDclDetailedViewDefinition($this->tableview_id);
166 $pageObject->delete();
167 }
168
169 ilUtil::sendSuccess($lng->txt("dcl_empty_detailed_view_success"), true);
170
171 // Bug fix for mantis 22537: Redirect to settings-tab instead of fields-tab. This solves the problem and is more intuitive.
172 $ilCtrl->redirectByClass("ilDclTableViewEditGUI", "editGeneralSettings");
173 }
174
175
180 public function releasePageLock()
181 {
182 global $DIC;
183 $ilCtrl = $DIC['ilCtrl'];
184 $lng = $DIC['lng'];
185
186 $this->getPageObject()->releasePageLock();
187 ilUtil::sendSuccess($lng->txt("cont_page_lock_released"), true);
188 $ilCtrl->redirectByClass('ilDclTableViewGUI', "show");
189 }
190
191
199 public function postOutputProcessing($a_output)
200 {
201 // You can use this to parse placeholders and the like before outputting
202
203 if ($this->getOutputMode() == ilPageObjectGUI::PREVIEW) {
204 //page preview is not being used inside DataCollections - if you are here, something's probably wrong
205
206 //
207 // // :TODO: find a suitable presentation for matched placeholders
208 // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
209 // foreach ($allp as $id => $item) {
210 // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
211 // $parsed_item = $parsed_item->getToolbarHTML();
212 //
213 // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
214 // }
215 } // editor
216 else {
217 if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
218 $allp = $this->getPageObject()->getAvailablePlaceholders();
219
220 // :TODO: find a suitable markup for matched placeholders
221 foreach ($allp as $item) {
222 $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
223 }
224 }
225 }
226
227 return $a_output;
228 }
229
230
234 public function saveTable() {
235 // die(var_dump($_POST));
239 foreach ($this->tableview->getFieldSettings() as $setting) {
240
241 if (!$setting->getFieldObject()->isStandardField() || $setting->getFieldObject()->getId() === 'owner') {
242
243 // Radio Inputs
244 foreach (array("RadioGroup") as $attribute) {
245 $selection_key = $attribute . '_' . $setting->getField();
246 $selection = $_POST[$selection_key];
247 $selected_radio_attribute = explode("_", $selection)[0];
248
249 foreach (array("LockedEdit", "RequiredEdit", "VisibleEdit", "NotVisibleEdit") as $radio_attribute) {
250 $result = false;
251
252 if ($selected_radio_attribute === $radio_attribute) {
253 $result = true;
254 }
255
256 $setting->{'set' . $radio_attribute}($result);
257 }
258 }
259
260 // Text Inputs
261 foreach (array("DefaultValue") as $attribute) {
262 $key = $attribute . '_' . $setting->getField();
263 $setting->{'set' . $attribute}($_POST[$key]);
264 }
265
266 $setting->update();
267 }
268 }
269
270 // Set Workflow flag to true
271 $view = ilDclTableView::getCollection()->where(array("id" => filter_input(INPUT_GET, "tableview_id")))->first();
272 if (!is_null($view)) {
273 $view->setStepE(true);
274 $view->save();
275 }
276
277 ilUtil::sendSuccess($this->lng->txt('dcl_msg_tableview_updated'), true);
278 $this->ctrl->saveParameter($this, 'tableview_id');
279 $this->ctrl->redirect($this, 'presentation');
280 }
281}
$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 ilDclDetailedViewDefinition.
Class ilDclEditViewDefinitionGUI.
releasePageLock()
Release page lock overwrite to redirect properly.
postOutputProcessing($a_output)
Finalizing output processing.
Class ilDclEditViewDefinition.
Class ilDclEditViewTableGUI.
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.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc