ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilStructureObjectGUI.php
Go to the documentation of this file.
1<?php
2
21
27{
28 protected \ILIAS\LearningModule\InternalDomainService $domain;
29 protected \ILIAS\LearningModule\InternalGUIService $gui;
32 protected ilObjUser $user;
33 protected ilTabsGUI $tabs;
34 protected ilLogger $log;
36
37 public function __construct(
38 ilObjLearningModule $a_content_obj,
39 ilLMTree $a_tree
40 ) {
41 global $DIC;
42
43 $this->user = $DIC->user();
44 $this->ctrl = $DIC->ctrl();
45 $this->lng = $DIC->language();
46 $this->tabs = $DIC->tabs();
47 $this->log = $DIC["ilLog"];
48 $this->tpl = $DIC->ui()->mainTemplate();
49 parent::__construct($a_content_obj);
50 $this->tree = $a_tree;
51 $this->gui = $DIC->learningModule()->internal()->gui();
52 $this->domain = $DIC->learningModule()->internal()->domain();
53 }
54
55 public function setStructureObject(
56 ilStructureObject $a_st_object
57 ): void {
58 $this->obj = $a_st_object;
59 }
60
61 public function getType(): string
62 {
63 return "st";
64 }
65
66 public function executeCommand(): void
67 {
68 $next_class = $this->ctrl->getNextClass($this);
69 $cmd = $this->ctrl->getCmd();
70
71 switch ($next_class) {
72 case 'ilobjectmetadatagui':
73
74 $this->setTabs();
75
76 $md_gui = new ilObjectMetaDataGUI($this->content_object, $this->obj->getType(), $this->obj->getId());
77 $md_gui->addMDObserver($this->obj, 'MDUpdateListener', 'General');
78 $md_gui->addMDObserver($this->obj, 'MDUpdateListener', 'Educational'); // #9510
79 $this->ctrl->forwardCommand($md_gui);
80 break;
81
82 case "ilconditionhandlergui":
83 $ilTabs = $this->tabs;
84
85 $this->setTabs();
86 $this->initConditionHandlerInterface();
87 $this->ctrl->forwardCommand($this->condHI);
88 $ilTabs->setTabActive('preconditions');
89 break;
90
91 case strtolower(EditSubObjectsGUI::class):
92 $this->setTabs();
93 $this->tabs->activateTab("sub_pages");
94 if ($this->request->getSubType() === "pg") {
95 $this->addSubTabs("sub_pages");
96 $table_title = $this->lng->txt("cont_pages");
97 } else {
98 $this->addSubTabs("sub_chapters");
99 $table_title = $this->lng->txt("cont_subchapters");
100 }
101 $gui = $this->gui->editing()->editSubObjectsGUI(
102 $this->request->getSubType(),
103 $this->content_object,
104 $table_title
105 );
106 $this->ctrl->forwardCommand($gui);
107 break;
108
109 default:
110 if ($cmd == 'listConditions') {
111 $this->setTabs();
112 $this->initConditionHandlerInterface();
113 $this->condHI->executeCommand();
114 } elseif (($cmd == "create") && ($this->requested_new_type == "pg")) {
115 $this->setTabs();
116 $pg_gui = new ilLMPageObjectGUI($this->content_object);
117 $pg_gui->executeCommand();
118 } else {
119 $this->$cmd();
120 }
121 break;
122 }
123 }
124
125 public function create(): void
126 {
127 if ($this->requested_obj_id != 0) {
128 $this->setTabs();
129 }
130 parent::create();
131 }
132
133 public function edit(): void
134 {
135 $this->view();
136 }
137
138 public function view(): void
139 {
140 $this->ctrl->redirectByClass(EditSubObjectsGUI::class, "editPages");
141 }
142
143
144 public function initConditionHandlerInterface(): void
145 {
146 $this->condHI = new ilConditionHandlerGUI();
147 $this->condHI->setBackButtons(array());
148 $this->condHI->setAutomaticValidation(false);
149 $this->condHI->setTargetType("st");
150 $this->condHI->setTargetRefId($this->content_object->getRefId());
151 $this->condHI->setTargetId($this->obj->getId());
152 $this->condHI->setTargetTitle($this->obj->getTitle());
153 }
154
155
159 public function cancel(): void
160 {
161 if ($this->requested_obj_id != 0) {
162 if ($this->requested_new_type == "pg") {
163 $this->ctrl->redirect($this, "view");
164 } else {
165 $this->ctrl->redirect($this, "subchap");
166 }
167 }
168 }
169
170 public function setTabs(): void
171 {
172 $ilTabs = $this->tabs;
174
175 // subelements
176 $this->ctrl->setParameterByClass(static::class, "sub_type", "pg");
177 $ilTabs->addTab(
178 "sub_pages",
179 $lng->txt("cont_content"),
180 $this->ctrl->getLinkTargetByClass(EditSubObjectsGUI::class)
181 );
182
183 // preconditions
184 $ilTabs->addTab(
185 "preconditions",
186 $lng->txt("preconditions"),
187 $this->ctrl->getLinkTarget($this, 'listConditions')
188 );
189
190 // metadata
191 $mdgui = new ilObjectMetaDataGUI($this->content_object, $this->obj->getType(), $this->obj->getId());
192 $mdtab = $mdgui->getTab();
193 if ($mdtab) {
194 $ilTabs->addTab(
195 "meta_data",
196 $lng->txt("meta_data"),
197 $mdtab
198 );
199 }
200
201 $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_st.svg"));
202 $this->tpl->setTitle(
203 $this->lng->txt($this->obj->getType()) . ": " . $this->obj->getTitle()
204 );
205
206 // presentation view
207 $ilTabs->addNonTabbedLink(
208 "pres_mode",
209 $lng->txt("cont_presentation_view"),
210 ILIAS_HTTP_PATH . "/goto.php?target=st_" . $this->obj->getId()
211 );
212 }
213
214 protected function addSubTabs($active = "")
215 {
216 $ilTabs = $this->tabs;
218
219 // content -> pages
220 $this->ctrl->setParameterByClass(static::class, "sub_type", "pg");
221 $ilTabs->addSubTab(
222 "sub_pages",
223 $lng->txt("cont_pages"),
224 $this->ctrl->getLinkTargetByClass(EditSubObjectsGUI::class)
225 );
226
227 // chapters
228 $this->ctrl->setParameterByClass(static::class, "sub_type", "st");
229 $ilTabs->addSubTab(
230 "sub_chapters",
231 $lng->txt("cont_subchapters"),
232 $this->ctrl->getLinkTargetByClass(EditSubObjectsGUI::class)
233 );
234 $ilTabs->activateSubTab($active);
235 }
236
240 public static function _goto(
241 string $a_target,
242 int $a_target_ref_id = 0
243 ): void {
244 global $DIC;
245 $main_tpl = $DIC->ui()->mainTemplate();
246
247 $lng = $DIC->language();
248 $ilAccess = $DIC->access();
249 $ctrl = $DIC->ctrl();
250
251 // determine learning object
252 $lm_id = ilLMObject::_lookupContObjID($a_target);
253
254 // get all references
255 $ref_ids = ilObject::_getAllReferences($lm_id);
256
257 // always try passed ref id first
258 if (in_array($a_target_ref_id, $ref_ids)) {
259 $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
260 }
261
262 // check read permissions
263 foreach ($ref_ids as $ref_id) {
264 // Permission check
265 if ($ilAccess->checkAccess("read", "", $ref_id)) {
266 $ctrl->setParameterByClass("ilLMPresentationGUI", "obj_id", $a_target);
267 $ctrl->setParameterByClass("ilLMPresentationGUI", "ref_id", $ref_id);
268 $ctrl->redirectByClass("ilLMPresentationGUI", "");
269 }
270 }
271
272 if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
273 $main_tpl->setOnScreenMessage('failure', sprintf(
274 $lng->txt("msg_no_perm_read_item"),
276 ), true);
278 }
279
280 throw new ilPermissionException($lng->txt("msg_no_perm_read_lm"));
281 }
282
283
287
291 public function setPageLayout(): void
292 {
293 $tpl = $this->tpl;
294 $ilCtrl = $this->ctrl;
296
297 $ids = $this->request->getIds();
298 if (count($ids) == 0) {
299 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
300 $ilCtrl->redirect($this, "showHierarchy");
301 }
302
303 $this->initSetPageLayoutForm();
304
305 $tpl->setContent($this->form->getHTML());
306 }
307
311 public function initSetPageLayoutForm(): void
312 {
314 $ilCtrl = $this->ctrl;
315
316 $this->form = new ilPropertyFormGUI();
317
318 $ids = $this->request->getIds();
319 foreach ($ids as $id) {
320 $hi = new ilHiddenInputGUI("id[]");
321 $hi->setValue($id);
322 $this->form->addItem($hi);
323 }
325 $lng->txt("cont_layout"),
326 "layout",
327 $this->content_object->getLayout()
328 );
329
330 $this->form->addItem($layout);
331
332 $this->form->addCommandButton("savePageLayout", $lng->txt("save"));
333 $this->form->addCommandButton("showHierarchy", $lng->txt("cancel"));
334
335 $this->form->setTitle($lng->txt("cont_set_layout"));
336 $this->form->setFormAction($ilCtrl->getFormAction($this));
337 }
338
342 public function savePageLayout(): void
343 {
345 $ilCtrl = $this->ctrl;
346
347 $ids = $this->request->getIds();
348 $layout = $this->request->getLayout();
349 foreach ($ids as $id) {
351 $id,
352 $layout,
353 $this->content_object
354 );
355 }
356 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
357 $ilCtrl->redirect($this, "showHierarchy");
358 }
359
360 public function editMasterLanguage(): void
361 {
362 $ilCtrl = $this->ctrl;
363
364 $ilCtrl->setParameter($this, "transl", "-");
365 $ilCtrl->redirect($this, "showHierarchy");
366 }
367
368 public function switchToLanguage(): void
369 {
370 $ilCtrl = $this->ctrl;
371
372 $ilCtrl->setParameter($this, "transl", $this->requested_totransl);
373 $ilCtrl->redirect($this, "showHierarchy");
374 }
375}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
class ilConditionHandlerGUI
This class represents a hidden form property in a property form.
Base class for ilStructureObjects and ilPageObjects (see ILIAS DTD)
static writeLayout(int $a_obj_id, string $a_layout, ?ilObjLearningModule $a_lm=null)
Write layout setting.
static _lookupContObjID(int $a_id)
get learning module id for lm object
User Interface for Learning Module Page Objects Editing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Component logger with individual log levels by component id.
static getLayoutOption(string $a_txt, string $a_var, string $a_def_option="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
Class ilObjectMetaDataGUI.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
This class represents a property form user interface.
@ilCtrl_Calls ilStructureObjectGUI: ilConditionHandlerGUI, ilObjectMetaDataGUI @ilCtrl_Calls ilStruct...
initSetPageLayoutForm()
Init set page layout form.
static _goto(string $a_target, int $a_target_ref_id=0)
create()
structure / page object creation form
ILIAS LearningModule InternalDomainService $domain
cancel()
cancel creation of new page or chapter
__construct(ilObjLearningModule $a_content_obj, ilLMTree $a_tree)
ilConditionHandlerGUI $condHI
setStructureObject(ilStructureObject $a_st_object)
setPageLayout()
Set layout for multipl pages.
ILIAS LearningModule InternalGUIService $gui
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...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const ROOT_FOLDER_ID
Definition: constants.php:32
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd, string $submit_caption="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26