ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDclDetailedViewDefinitionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
16{
17
21 public $obj;
25 public $ctrl;
29 protected $tableview_id;
30
31
36 public function __construct($tableview_id, $a_definition_id = 0)
37 {
38 global $DIC;
39 $tpl = $DIC['tpl'];
40 $ilCtrl = $DIC['ilCtrl'];
44 $this->ctrl = $ilCtrl;
45 $this->tableview_id = $tableview_id;
46
47 // we always need a page object - create on demand
49 $viewdef = new ilDclDetailedViewDefinition();
50 $viewdef->setId($tableview_id);
51 $viewdef->setParentId(ilObject2::_lookupObjectId($_GET['ref_id']));
52 $viewdef->setActive(false);
53 $viewdef->create();
54 }
55
57
58 // Add JavaScript
59 $tpl->addJavascript('Modules/DataCollection/js/single_view_listener.js');
60
61 // content style (using system defaults)
62 $tpl->setCurrentBlock("SyntaxStyle");
63 $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
64 $tpl->parseCurrentBlock();
65
66 $tpl->setCurrentBlock("ContentStyle");
67 $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
68 $tpl->parseCurrentBlock();
69 }
70
71
75 public function executeCommand()
76 {
77 global $DIC;
78 $ilLocator = $DIC['ilLocator'];
79 $lng = $DIC['lng'];
80
81 $next_class = $this->ctrl->getNextClass($this);
82
83 $viewdef = $this->getPageObject();
84 if ($viewdef) {
85 $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
86 $title = $lng->txt("dcl_view_viewdefinition");
87 }
88
89 switch ($next_class) {
90 case "ilpageobjectgui":
91 throw new ilCOPageException("Deprecated. ilDclDetailedViewDefinitionGUI gui forwarding to ilpageobject");
92 default:
93 if ($viewdef) {
94 $this->setPresentationTitle($title);
95 $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
96 }
97
98 return parent::executeCommand();
99 }
100 }
101
102
106 public function showPage()
107 {
108 global $DIC;
109 $ilToolbar = $DIC['ilToolbar'];
113 if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
114 $delete_button = ilLinkButton::getInstance();
115 $delete_button->setCaption('dcl_empty_detailed_view');
116 $delete_button->setUrl($this->ctrl->getLinkTarget($this, 'confirmDelete'));
117 $ilToolbar->addButtonInstance($delete_button);
118
119 $activation_button = ilLinkButton::getInstance();
120 if ($this->getPageObject()->getActive()) {
121 $activation_button->setCaption('dcl_deactivate_view');
122 $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'deactivate'));
123 } else {
124 $activation_button->setCaption('dcl_activate_view');
125 $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'activate'));
126 }
127
128 $ilToolbar->addButtonInstance($activation_button);
129
130 $legend = $this->getPageObject()->getAvailablePlaceholders();
131 if (sizeof($legend)) {
132 $this->setPrependingHtml(
133 "<span class=\"small\">" . $this->lng->txt("dcl_legend_placeholders") . ": " . implode(" ", $legend)
134 . "</span>"
135 );
136 }
137 }
138
139 return parent::showPage();
140 }
141
142
143 public function editActivation()
144 {
145 parent::editActivation();
146 }
147
148
149 public function edit()
150 {
151 return parent::edit();
152 }
153
154
155
156 public function setEditPreview($a_editpreview)
157 {
158 parent::setEditPreview($a_editpreview);
159 }
160
161
165 protected function activate()
166 {
167 $page = $this->getPageObject();
168 $page->setActive(true);
169 $page->update();
170 $this->ctrl->redirect($this, 'edit');
171 }
172
173
177 protected function deactivate()
178 {
179 $page = $this->getPageObject();
180 $page->setActive(false);
181 $page->update();
182 $this->ctrl->redirect($this, 'edit');
183 }
184
185
189 public function confirmDelete()
190 {
191 global $DIC;
192 $ilCtrl = $DIC['ilCtrl'];
193 $lng = $DIC['lng'];
194 $tpl = $DIC['tpl'];
195
196 $conf = new ilConfirmationGUI();
197 $conf->setFormAction($ilCtrl->getFormAction($this));
198 $conf->setHeaderText($lng->txt('dcl_confirm_delete_detailed_view_title'));
199
200 $conf->addItem('tableview', (int) $this->tableview_id, $lng->txt('dcl_confirm_delete_detailed_view_text'));
201
202 $conf->setConfirm($lng->txt('delete'), 'deleteView');
203 $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
204
205 $tpl->setContent($conf->getHTML());
206 }
207
208
212 public function cancelDelete()
213 {
214 global $DIC;
215 $ilCtrl = $DIC['ilCtrl'];
216
217 $ilCtrl->redirect($this, "edit");
218 }
219
220
224 public function deleteView()
225 {
226 global $DIC;
227 $ilCtrl = $DIC['ilCtrl'];
228 $lng = $DIC['lng'];
229
230 if ($this->tableview_id && ilDclDetailedViewDefinition::exists($this->tableview_id)) {
231 $pageObject = new ilDclDetailedViewDefinition($this->tableview_id);
232 $pageObject->delete();
233 }
234
235 ilUtil::sendSuccess($lng->txt("dcl_empty_detailed_view_success"), true);
236
237 // Bug fix for mantis 22537: Redirect to settings-tab instead of fields-tab. This solves the problem and is more intuitive.
238 $ilCtrl->redirectByClass("ilDclTableViewEditGUI", "editGeneralSettings");
239 }
240
241
246 public function releasePageLock()
247 {
248 global $DIC;
249 $ilCtrl = $DIC['ilCtrl'];
250 $lng = $DIC['lng'];
251
252 $this->getPageObject()->releasePageLock();
253 ilUtil::sendSuccess($lng->txt("cont_page_lock_released"), true);
254 $ilCtrl->redirectByClass('ilDclTableViewGUI', "show");
255 }
256
257
265 public function postOutputProcessing($a_output)
266 {
267 // You can use this to parse placeholders and the like before outputting
268
269 if ($this->getOutputMode() == ilPageObjectGUI::PREVIEW) {
270 //page preview is not being used inside DataCollections - if you are here, something's probably wrong
271
272 //
273 // // :TODO: find a suitable presentation for matched placeholders
274 // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
275 // foreach ($allp as $id => $item) {
276 // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
277 // $parsed_item = $parsed_item->getToolbarHTML();
278 //
279 // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
280 // }
281 } // editor
282 else {
283 if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
284 $allp = $this->getPageObject()->getAvailablePlaceholders();
285
286 // :TODO: find a suitable markup for matched placeholders
287 foreach ($allp as $item) {
288 $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
289 }
290 }
291 }
292
293 return $a_output;
294 }
295}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Base exception class for copage service.
Confirmation screen class.
Class ilDclDetailedViewDefinitionGUI.
setEditPreview($a_editpreview)
Set Display first Edit tab, then Preview tab, instead of Page and Edit.
editActivation()
Edit activation (only, if scheduled page activation is activated in administration)
postOutputProcessing($a_output)
Finalizing output processing.
releasePageLock()
Release page lock overwrite to redirect properly.
Class ilDclDetailedViewDefinition.
static getInstance()
Factory.
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static _lookupObjectId($a_ref_id)
lookup object id
Class ilPageObjectGUI.
setPrependingHtml($a_prependinghtml)
Set Prepending HTML.
__construct( $a_parent_type, $a_id, $a_old_nr=0, $a_prevent_get_id=false, $a_lang="", $concrete_lang="")
Constructor.
setPresentationTitle($a_title="")
showPage()
display content of page
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