ILIAS  release_8 Revision v8.24
class.ilDclDetailedViewDefinitionGUI.php
Go to the documentation of this file.
1<?php
2
24{
25 protected int $tableview_id;
28
29 public function __construct(int $tableview_id)
30 {
31 global $DIC;
32
33 $this->tableview_id = $tableview_id;
34 $this->http = $DIC->http();
35 $this->refinery = $DIC->refinery();
36
37 // we always need a page object - create on demand
39 $ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $this->refinery->kindlyTo()->int());
40
41 $viewdef = new ilDclDetailedViewDefinition();
42 $viewdef->setId($tableview_id);
43 $viewdef->setParentId(ilObject2::_lookupObjectId($ref_id));
44 $viewdef->setActive(false);
45 $viewdef->create(false);
46 }
47
49
50 // content style (using system defaults)
51 $this->tpl->setCurrentBlock("SyntaxStyle");
52 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
53 $this->tpl->parseCurrentBlock();
54
55 $this->tpl->setCurrentBlock("ContentStyle");
56 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
57 $this->tpl->parseCurrentBlock();
58 }
59
63 public function executeCommand(): string
64 {
65 global $DIC;
66 $ilLocator = $DIC['ilLocator'];
67
68 $next_class = $this->ctrl->getNextClass($this);
69
70 $viewdef = $this->getPageObject();
71 if ($viewdef) {
72 $this->ctrl->setParameter($this, "dclv", $viewdef->getId());
73 $title = $this->lng->txt("dcl_view_viewdefinition");
74 }
75
76 switch ($next_class) {
77 case "ilpageobjectgui":
78 throw new ilCOPageException("Deprecated. ilDclDetailedViewDefinitionGUI gui forwarding to ilpageobject");
79 default:
80 if ($viewdef) {
81 $this->setPresentationTitle($title);
82 $ilLocator->addItem($title, $this->ctrl->getLinkTarget($this, "preview"));
83 }
84
85 return parent::executeCommand();
86 }
87 }
88
89 public function showPage(): string
90 {
91 if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
92 $delete_button = ilLinkButton::getInstance();
93 $delete_button->setCaption('dcl_empty_detailed_view');
94 $delete_button->setUrl($this->ctrl->getLinkTarget($this, 'confirmDelete'));
95 $this->toolbar->addButtonInstance($delete_button);
96
97 $activation_button = ilLinkButton::getInstance();
98 if ($this->getPageObject()->getActive()) {
99 $activation_button->setCaption('dcl_deactivate_view');
100 $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'deactivate'));
101 } else {
102 $activation_button->setCaption('dcl_activate_view');
103 $activation_button->setUrl($this->ctrl->getLinkTarget($this, 'activate'));
104 }
105
106 $this->toolbar->addButtonInstance($activation_button);
107
108 $legend = $this->getPageObject()->getAvailablePlaceholders();
109 if (sizeof($legend)) {
110 $this->setPrependingHtml(
111 "<span class=\"small\">" . $this->lng->txt("dcl_legend_placeholders") . ": " . implode(" ", $legend)
112 . "</span>"
113 );
114 }
115 }
116
117 return parent::showPage();
118 }
119
120 protected function activate(): void
121 {
122 $page = $this->getPageObject();
123 $page->setActive(true);
124 $page->update();
125 $this->ctrl->redirect($this, 'edit');
126 }
127
128 protected function deactivate(): void
129 {
130 $page = $this->getPageObject();
131 $page->setActive(false);
132 $page->update();
133 $this->ctrl->redirect($this, 'edit');
134 }
135
136 public function confirmDelete(): void
137 {
138 $conf = new ilConfirmationGUI();
139 $conf->setFormAction($this->ctrl->getFormAction($this));
140 $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_detailed_view_title'));
141
142 $conf->addItem('tableview', $this->tableview_id, $this->lng->txt('dcl_confirm_delete_detailed_view_text'));
143
144 $conf->setConfirm($this->lng->txt('delete'), 'deleteView');
145 $conf->setCancel($this->lng->txt('cancel'), 'cancelDelete');
146
147 $this->tpl->setContent($conf->getHTML());
148 }
149
150 public function cancelDelete(): void
151 {
152 $this->ctrl->redirect($this, "edit");
153 }
154
155 public function deleteView(): void
156 {
157 if ($this->tableview_id && ilDclDetailedViewDefinition::exists($this->tableview_id)) {
158 $pageObject = new ilDclDetailedViewDefinition($this->tableview_id);
159 $pageObject->delete();
160 }
161
162 $this->tpl->setOnScreenMessage('success', $this->lng->txt("dcl_empty_detailed_view_success"), true);
163 $this->ctrl->redirectByClass(self::class, "edit");
164 }
165
169 public function postOutputProcessing(string $a_output): string
170 {
171 // You can use this to parse placeholders and the like before outputting
172
173 if ($this->getOutputMode() == ilPageObjectGUI::PREVIEW) {
174 //page preview is not being used inside DataCollections - if you are here, something's probably wrong
175
176 //
177 // // :TODO: find a suitable presentation for matched placeholders
178 // $allp = ilDataCollectionRecordViewViewdefinition::getAvailablePlaceholders($this->table_id, true);
179 // foreach ($allp as $id => $item) {
180 // $parsed_item = new ilTextInputGUI("", "fields[" . $item->getId() . "]");
181 // $parsed_item = $parsed_item->getToolbarHTML();
182 //
183 // $a_output = str_replace($id, $item->getTitle() . ": " . $parsed_item, $a_output);
184 // }
185 } // editor
186 else {
187 if ($this->getOutputMode() == ilPageObjectGUI::EDIT) {
188 $allp = $this->getPageObject()->getAvailablePlaceholders();
189
190 // :TODO: find a suitable markup for matched placeholders
191 foreach ($allp as $item) {
192 $a_output = str_replace($item, "<span style=\"color:green\">" . $item . "</span>", $a_output);
193 }
194 }
195 }
196
197 return $a_output;
198 }
199}
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...
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...
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
static _lookupObjectId(int $ref_id)
Class ilPageObjectGUI.
setPresentationTitle(string $a_title="")
setPrependingHtml(string $a_prependinghtml)
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
$ref_id
Definition: ltiauth.php:67
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc