ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 // content style (using system defaults)
59 $tpl->setCurrentBlock("SyntaxStyle");
60 $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
61 $tpl->parseCurrentBlock();
62
63 $tpl->setCurrentBlock("ContentStyle");
64 $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
65 $tpl->parseCurrentBlock();
66 }
67
68
72 public function executeCommand()
73 {
74 global $DIC;
75 $ilLocator = $DIC['ilLocator'];
76 $lng = $DIC['lng'];
77
78 $next_class = $this->ctrl->getNextClass($this);
79
80 $viewdef = $this->getPageObject();
81 if ($viewdef) {
82 $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
83 $title = $lng->txt("dcl_view_viewdefinition");
84 }
85
86 switch ($next_class) {
87 case "ilpageobjectgui":
88 throw new ilCOPageException("Deprecated. ilDclDetailedViewDefinitionGUI gui forwarding to ilpageobject");
89 default:
90 if ($viewdef) {
91 $this->setPresentationTitle($title);
92 $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
93 }
94
95 return parent::executeCommand();
96 }
97 }
98
99
103 public function showPage()
104 {
105 global $DIC;
106 $ilToolbar = $DIC['ilToolbar'];
110 if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
111 $delete_button = ilLinkButton::getInstance();
112 $delete_button->setCaption('dcl_empty_detailed_view');
113 $delete_button->setUrl($this->ctrl->getLinkTarget($this, 'confirmDelete'));
114 $ilToolbar->addButtonInstance($delete_button);
115
116 $activation_button = ilLinkButton::getInstance();
117 if ($this->getPageObject()->getActive()) {
118 $activation_button->setCaption('dcl_deactivate_view');
119 $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'deactivate'));
120 } else {
121 $activation_button->setCaption('dcl_activate_view');
122 $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'activate'));
123 }
124
125 $ilToolbar->addButtonInstance($activation_button);
126
127 $legend = $this->getPageObject()->getAvailablePlaceholders();
128 if (sizeof($legend)) {
129 $this->setPrependingHtml(
130 "<span class=\"small\">" . $this->lng->txt("dcl_legend_placeholders") . ": " . implode(" ", $legend)
131 . "</span>"
132 );
133 }
134 }
135
136 return parent::showPage();
137 }
138
139
143 protected function activate()
144 {
145 $page = $this->getPageObject();
146 $page->setActive(true);
147 $page->update();
148 $this->ctrl->redirect($this, 'edit');
149 }
150
151
155 protected function deactivate()
156 {
157 $page = $this->getPageObject();
158 $page->setActive(false);
159 $page->update();
160 $this->ctrl->redirect($this, 'edit');
161 }
162
163
167 public function confirmDelete()
168 {
169 global $DIC;
170 $ilCtrl = $DIC['ilCtrl'];
171 $lng = $DIC['lng'];
172 $tpl = $DIC['tpl'];
173
174 $conf = new ilConfirmationGUI();
175 $conf->setFormAction($ilCtrl->getFormAction($this));
176 $conf->setHeaderText($lng->txt('dcl_confirm_delete_detailed_view_title'));
177
178 $conf->addItem('tableview', (int) $this->tableview_id, $lng->txt('dcl_confirm_delete_detailed_view_text'));
179
180 $conf->setConfirm($lng->txt('delete'), 'deleteView');
181 $conf->setCancel($lng->txt('cancel'), 'cancelDelete');
182
183 $tpl->setContent($conf->getHTML());
184 }
185
186
190 public function cancelDelete()
191 {
192 global $DIC;
193 $ilCtrl = $DIC['ilCtrl'];
194
195 $ilCtrl->redirect($this, "edit");
196 }
197
198
202 public function deleteView()
203 {
204 global $DIC;
205 $ilCtrl = $DIC['ilCtrl'];
206 $lng = $DIC['lng'];
207
208 if ($this->tableview_id && ilDclDetailedViewDefinition::exists($this->tableview_id)) {
209 $pageObject = new ilDclDetailedViewDefinition($this->tableview_id);
210 $pageObject->delete();
211 }
212
213 ilUtil::sendSuccess($lng->txt("dcl_empty_detailed_view_success"), true);
214
215 // Bug fix for mantis 22537: Redirect to settings-tab instead of fields-tab. This solves the problem and is more intuitive.
216 $ilCtrl->redirectByClass("ilDclTableViewEditGUI", "editGeneralSettings");
217 }
218
219
224 public function releasePageLock()
225 {
226 global $DIC;
227 $ilCtrl = $DIC['ilCtrl'];
228 $lng = $DIC['lng'];
229
230 $this->getPageObject()->releasePageLock();
231 ilUtil::sendSuccess($lng->txt("cont_page_lock_released"), true);
232 $ilCtrl->redirectByClass('ilDclTableViewGUI', "show");
233 }
234
235
243 public function postOutputProcessing($a_output)
244 {
245 // You can use this to parse placeholders and the like before outputting
246
247 if ($this->getOutputMode() == ilPageObjectGUI::PREVIEW) {
248 //page preview is not being used inside DataCollections - if you are here, something's probably wrong
249
250 //
251 // // :TODO: find a suitable presentation for matched placeholders
252 // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
253 // foreach ($allp as $id => $item) {
254 // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
255 // $parsed_item = $parsed_item->getToolbarHTML();
256 //
257 // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
258 // }
259 } // editor
260 else {
261 if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
262 $allp = $this->getPageObject()->getAvailablePlaceholders();
263
264 // :TODO: find a suitable markup for matched placeholders
265 foreach ($allp as $item) {
266 $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
267 }
268 }
269 }
270
271 return $a_output;
272 }
273}
$_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.
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.
setPresentationTitle($a_title="")
showPage()
display content of page
getPageObject()
Get Page Object.
__construct( $a_parent_type, $a_id, $a_old_nr=0, $a_prevent_get_id=false, $a_lang="")
Constructor.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46