ILIAS  trunk Revision v12.0_alpha-1338-g8f7e531aa3c
class.ilLMEditorGUI.php
Go to the documentation of this file.
1<?php
2
20
27{
28 protected \ILIAS\GlobalScreen\ScreenContext\ContextServices $tool_context;
29 protected ilCtrl $ctrl;
32 protected ilHelpGUI $help;
34 protected ilLanguage $lng;
36 protected int $ref_id;
38 protected ilLMTree $tree;
39 protected int $obj_id;
40 protected int $requested_active_node = 0;
41 protected bool $to_page = false;
43 protected \ILIAS\Style\Content\GUIService $content_style_gui;
44
45 public function __construct()
46 {
47 global $DIC;
48
49 $this->rbacsystem = $DIC->rbac()->system();
50 $this->help = $DIC->help();
51 $tpl = $DIC->ui()->mainTemplate();
52 $lng = $DIC->language();
53 $objDefinition = $DIC["objDefinition"];
54 $ilCtrl = $DIC->ctrl();
55 $rbacsystem = $DIC->rbac()->system();
56 $ilNavigationHistory = $DIC["ilNavigationHistory"];
57
58 $lng->loadLanguageModule("content");
60
61 $this->request = $DIC
62 ->learningModule()
63 ->internal()
64 ->gui()
65 ->editing()
66 ->request();
67
68 $this->ref_id = $this->request->getRefId();
69 $this->obj_id = $this->request->getObjId();
70
71 $this->ctrl = $ilCtrl;
72
73 $cmd_class = $this->ctrl->getCmdClass($this);
74 $lp_settings_access = (in_array($cmd_class, [
75 strtolower(ilLPListOfSettingsGUI::class),
76 strtolower(ilLPListOfObjectsGUI::class),
77 ], true))
78 && $rbacsystem->checkAccess("edit_learning_progress", $this->ref_id);
79
80 // check write permission
81 if (!$rbacsystem->checkAccess("write", $this->ref_id) &&
82 !$lp_settings_access) {
83 throw new ilPermissionException($lng->txt("permission_denied"));
84 }
85
86
87 $this->tool_context = $DIC->globalScreen()->tool()->context();
88
89 $this->ctrl->saveParameter($this, array("ref_id", "transl"));
90
91 // initiate variables
92 $this->tpl = $tpl;
93 $this->lng = $lng;
94 $this->objDefinition = $objDefinition;
95
98 $this->lm_obj = $lm_obj;
99 $this->tree = new ilLMTree($this->lm_obj->getId());
100
101 $ilNavigationHistory->addItem(
102 $this->ref_id,
103 "ilias.php?baseClass=ilLMEditorGUI&ref_id=" . $this->ref_id,
104 "lm"
105 );
106
107 $this->requested_active_node = $this->request->getActiveNode();
108 $this->to_page = $this->request->getToPage();
109
110 $this->checkRequestParameters();
111 $cs = $DIC->contentStyle();
112 $this->content_style_gui = $cs->gui();
113 }
114
120 protected function checkRequestParameters(): void
121 {
122 $forwards_to_role = $this->ctrl->checkCurrentPathForClass("ilobjrolegui");
123
124 if (!$forwards_to_role && $this->obj_id > 0 && ilLMObject::_lookupContObjID($this->obj_id) != $this->lm_obj->getId()) {
125 throw new ilException("Object ID does not match learning module.");
126 }
127 if ($this->requested_active_node > 0 && ilLMObject::_lookupContObjID($this->requested_active_node) != $this->lm_obj->getId()) {
128 throw new ilException("Active node does not match learning module.");
129 }
130 }
131
132
137 public function executeCommand(): void
138 {
139 global $DIC;
140
141 $this->tool_context->claim()->repository();
142
143 $cmd = "";
144
146 $loc = $DIC["ilLocator"];
147 $loc->addRepositoryItems($this->ref_id);
148
149 if ($this->to_page) {
150 $this->ctrl->setParameterByClass("illmpageobjectgui", "obj_id", $this->obj_id);
151 $this->ctrl->redirectByClass(array("ilobjlearningmodulegui", "illmpageobjectgui"), "edit");
152 }
153
154 $this->showTree();
155
156 $next_class = $this->ctrl->getNextClass($this);
157
158 // show footer
159 $show_footer = ($cmd !== "explorer");
160
161 switch ($next_class) {
162 case "ilobjlearningmodulegui":
163 $this->main_header();
164 $lm_gui = new ilObjLearningModuleGUI("", $this->ref_id, true, false);
165
166 $ret = $this->ctrl->forwardCommand($lm_gui);
167 if (strcmp($cmd, "explorer") != 0) {
168 $this->displayLocator();
169 }
170 // (horrible) workaround for preventing template engine
171 // from hiding paragraph text that is enclosed
172 // in curly brackets (e.g. "{a}", see ilPageObjectGUI::showPage())
173 // @todo 6.0
174 /*
175 $output = $this->tpl->getSpecial("DEFAULT", true, true, $show_footer,true);
176 $output = str_replace("&#123;", "{", $output);
177 $output = str_replace("&#125;", "}", $output);
178 header('Content-type: text/html; charset=UTF-8');
179 echo $output;*/
180 $this->tpl->printToStdout();
181 break;
182
183 default:
184 $this->ctrl->redirectByClass(array("ilobjlearningmodulegui"), "");
185 break;
186 }
187 }
188
192 public function showTree(): void
193 {
195
196 $this->tool_context->current()->addAdditionalData(ilLMEditGSToolProvider::SHOW_TREE, true);
197
198 $exp = new ilLMEditorExplorerGUI($this, "showTree", $this->lm_obj);
199 $exp->handleCommand();
200 }
201
205 public function main_header(): void
206 {
207 $this->tpl->loadStandardTemplate();
208
209 // content style
210 $this->content_style_gui->addCss(
211 $this->tpl,
212 $this->lm_obj->getRefId()
213 );
214
215 // syntax style
216 $this->tpl->setCurrentBlock("SyntaxStyle");
217 $this->tpl->setVariable(
218 "LOCATION_SYNTAX_STYLESHEET",
220 );
221 $this->tpl->parseCurrentBlock();
222 }
223
224
228 public function displayLocator(): void
229 {
230 $this->tpl->setLocator();
231 }
232}
Class ilCtrl provides processing control methods.
Base class for ILIAS Exception handling.
Help GUI class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
GUI class for learning module editor.
ILIAS Style Content GUIService $content_style_gui
ilObjLearningModule $lm_obj
ILIAS GlobalScreen ScreenContext ContextServices $tool_context
ilRbacSystem $rbacsystem
checkRequestParameters()
Check request parameters.
ilGlobalTemplateInterface $tpl
EditingGUIRequest $request
ilNavigationHistory $nav_history
main_header()
output main header (title and locator)
displayLocator()
Display locator.
ilObjectDefinition $objDefinition
static _lookupContObjID(int $a_id)
get learning module id for lm object
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Last visited history for repository items.
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...
parses the objects.xml it handles the xml-description of all ilias objects
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26