ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilRepositoryGUI.php
Go to the documentation of this file.
1<?php
2
21
47{
49 protected ilLogger $log;
50 protected ilObjUser $user;
52 protected ilHelpGUI $help;
58 public ilTree $tree;
60 public int $cur_ref_id;
61 public string $cmd;
62 public string $mode = "";
63 public ilCtrl $ctrl;
64 private \ILIAS\HTTP\Services $http;
66 protected bool $creation_mode;
68
69 public function __construct()
70 {
72 global $DIC;
73
74 $this->log = $DIC["ilLog"];
75 $this->user = $DIC->user();
76 $this->settings = $DIC->settings();
77 $this->help = $DIC["ilHelp"];
78 $this->error = $DIC["ilErr"];
79 $this->access = $DIC->access();
80 $lng = $DIC->language();
81 $tpl = $DIC->ui()->mainTemplate();
82 $tree = $DIC->repositoryTree();
83 $rbacsystem = $DIC->rbac()->system();
84 $objDefinition = $DIC["objDefinition"];
85 $ilCtrl = $DIC->ctrl();
86 $this->tool_context = $DIC->globalScreen()->tool()->context();
87 $this->http = $DIC->http();
88
89 $this->lng = $lng;
90 $this->tpl = $tpl;
91 $this->tree = $tree;
92 $this->rbacsystem = $rbacsystem;
93 $this->objDefinition = $objDefinition;
94
95 $this->ctrl = $ilCtrl;
96
97 $this->creation_mode = false;
98
99 $this->ctrl->saveParameter($this, ["ref_id"]);
100 $this->ctrl->setReturn($this, "");
101
102 $this->request = $DIC->repository()->internal()->gui()->standardRequest();
103
104 // determine current ref id and mode
105 $this->cur_ref_id = $this->request->getRefId();
106 if (!$tree->isInTree($this->cur_ref_id)) {
107 $this->redirectToRoot();
108 }
109 }
110
111 protected function redirectToRoot(): void
112 {
115 self::class,
116 "ref_id",
117 $this->tree->getRootId()
118 );
119
120 $ctrl->redirectByClass(self::class, "");
121 }
122
123 public function executeCommand(): void
124 {
127 $ilHelp = $this->help;
129 if (
130 ($this->user->isAnonymous() || !($this->user->getId() >= 1)) &&
131 !ilPublicSectionSettings::getInstance()->isEnabledForDomain(
132 $this->http->request()->getServerParams()['SERVER_NAME']
133 )
134 ) {
135 $this->ctrl->redirectToURL('./login.php?cmd=force_login');
136 }
137
138 $this->tool_context->claim()->repository();
139
140 // check creation mode
141 // determined by "new_type" parameter
142 $new_type = $this->request->getNewType();
143
144 if ($new_type !== "" && $new_type !== "sty") {
145 $this->creation_mode = true;
146 $ilHelp->setScreenIdComponent($new_type);
147 $ilHelp->setDefaultScreenId(ilHelpGUI::ID_PART_SCREEN, "create");
148 $this->ctrl->saveParameter($this, ["crtcb"]);
149 }
150
151 $cmd = $this->ctrl->getCmd();
152
153 // determine next class
154 if ($this->creation_mode) {
155 $obj_type = $new_type;
156 $class_name = $this->objDefinition->getClassName($obj_type);
157 if (strtolower($class_name) !== "user") {
158 $next_class = strtolower("ilObj" . $class_name . "GUI");
159 } else {
160 $next_class = $this->ctrl->getNextClass();
161 }
162 // Only set the fixed cmdClass if the next class is different to
163 // the GUI class of the new object.
164 // An example:
165 // Copy Category uses this call structure:
166 // RespositoryGUI -> CategoryGUI -> ilObjectCopyGUI
167 // Without this fix, the cmdClass ilObjectCopyGUI would never be reached
168
169 ilLoggerFactory::getLogger('obj')->debug($this->ctrl->getNextClass() . ' <-> ' . $class_name);
170
171 if ($this->ctrl->getNextClass() !== strtolower('ilObj' . $class_name . 'GUI')) {
172 $this->ctrl->setParameterByClass($next_class, "new_type", $new_type);
173 $this->ctrl->redirectByClass($next_class, $this->ctrl->getCmd());
174 }
175 } elseif ((($next_class = $this->ctrl->getNextClass($this)) == "")
176 || ($next_class === "ilrepositorygui" && $this->ctrl->getCmd() === "return")) {
177 // get GUI of current object
178 $obj_type = ilObject::_lookupType($this->cur_ref_id, true);
179 $class_name = $this->objDefinition->getClassName($obj_type);
180 $next_class = strtolower("ilObj" . $class_name . "GUI");
181
182 if ($this->ctrl->getCmd() === "return") {
183 $this->ctrl->redirectByClass($next_class, "");
184 }
185
186 if ($this->ctrl->getCmd() !== "showRepTree") {
187 $this->ctrl->setParameterByClass($next_class, "item_ref_id", $this->request->getItemRefId());
188 $this->ctrl->redirectByClass($next_class, $this->ctrl->getCmd());
189 }
190 }
191
192 // commands that are always handled by repository gui
193 // to do: move to container
194 if ($cmd === "showRepTree") {
195 $next_class = "";
196 }
197
198 switch ($next_class) {
199 // forward asynchronous file uploads to the upload handler.
200 // possible via dropzones in list guis or global template
201 // sections like title.
202 case strtolower(ilObjFileUploadHandlerGUI::class):
203 $this->ctrl->forwardCommand(new ilObjFileUploadHandlerGUI());
204 break;
205
206 default:
207 // forward all other classes to gui commands
208 if ($next_class !== null && $next_class !== "" && $next_class !== "ilrepositorygui") {
209 $class_path = $this->ctrl->lookupClassPath($next_class);
210 // get gui class instance
211 //require_once($class_path);
212 $class_name = $this->ctrl->getClassForClasspath($class_path);
213 if (!$this->creation_mode) {
214 if (is_subclass_of($class_name, "ilObject2GUI")) {
215 $this->gui_obj = new $class_name($this->cur_ref_id, ilObject2GUI::REPOSITORY_NODE_ID);
216 } else {
217 $this->gui_obj = new $class_name("", $this->cur_ref_id, true, false);
218 }
219 } elseif (is_subclass_of($class_name, "ilObject2GUI")) {
220 $this->gui_obj = new $class_name(0, ilObject2GUI::REPOSITORY_NODE_ID, $this->cur_ref_id);
221 } else {
222 $this->gui_obj = new $class_name("", 0, true, false);
223 }
224 $this->gui_obj->setCreationMode($this->creation_mode);
225 $this->ctrl->setReturn($this, "return");
226
227 $this->show();
228 } else { //
229 $cmd = (string) $this->ctrl->getCmd("");
230
231 // check read access for category
232 if ($cmd !== "showRepTree" && $this->cur_ref_id > 0 && !$rbacsystem->checkAccess("read", $this->cur_ref_id)) {
233 $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->MESSAGE);
234 $this->tpl->printToStdout();
235 } else {
236 $this->cmd = $cmd;
237 $this->$cmd();
238 }
239 }
240 break;
241 }
242 }
243
244 public function show(): void
245 {
246 // normal command processing
247 $this->ctrl->forwardCommand($this->gui_obj);
248 $this->tpl->setVariable("OBJECTS", $this->gui_obj->getHTML());
249 $this->tpl->printToStdout();
250 }
251
252 public function showRepTree(): void
253 {
254 $exp = new ilRepositoryExplorerGUI($this, "showRepTree");
255 // root node should be skipped, see #26787
256 $exp->setSkipRootNode(true);
257 $exp->handleCommand();
258 }
259}
error(string $a_errmsg)
Class ilCtrl provides processing control methods.
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
Error Handling & global info handling.
Help GUI class.
const ID_PART_SCREEN
language handling
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...
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
User class.
parses the objects.xml it handles the xml-description of all ilias objects
Class ilObjectGUI Basic methods of all Output classes.
static _lookupType(int $id, bool $reference=false)
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 ...
Repository explorer GUI class.
Class ilRepositoryGUI.
ILIAS HTTP Services $http
StandardGUIRequest $request
ContextServices $tool_context
ilAccessHandler $access
ilGlobalTemplateInterface $tpl
ilObjectDefinition $objDefinition
ilErrorHandling $error
ILIAS Setting Class.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
isInTree(?int $a_node_id)
get all information of a node.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ilErr
Definition: raiseError.php:33
global $DIC
Definition: shib_login.php:26