ILIAS  release_8 Revision v8.24
class.ilSystemStyleMainGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26use Psr\Http\Message\ServerRequestInterface;
27use ILIAS\Refinery\Factory as RefineryFactory;
29
37{
38 protected ilCtrl $ctrl;
39 protected ilLanguage $lng;
40 protected ilTabsGUI $tabs;
42 protected string $ref_id;
44 protected ilHelpGUI $help;
51 protected RefineryFactory $refinery;
52 protected ServerRequestInterface $request;
56 protected ilTree $tree;
57 protected ilObjUser $user;
59
60 public function __construct()
61 {
65 global $DIC;
66
67 $this->ctrl = $DIC->ctrl();
68 $this->lng = $DIC->language();
69 $this->tabs = $DIC->tabs();
70 $this->rbacsystem = $DIC->rbac()->system();
71 $this->tpl = $DIC->ui()->mainTemplate();
72 $this->help = $DIC->help();
73 $this->ui_factory = $DIC->ui()->factory();
74 $this->renderer = $DIC->ui()->renderer();
75 $this->locator = $DIC['ilLocator'];
76 $this->ilIniFile = $DIC->iliasIni();
77 $this->global_screen = $DIC->globalScreen();
78 $this->request_wrapper = $DIC->http()->wrapper();
79 $this->refinery = $DIC->refinery();
80 $this->request = $DIC->http()->request();
81 $this->toolbar = $DIC->toolbar();
82 $this->upload = $DIC->upload();
83 $this->tree = $DIC->repositoryTree();
84 $this->skin_factory = new ilSkinFactory($this->lng);
85 $this->user = $DIC->user();
86
87 $this->message_stack = new ilSystemStyleMessageStack($this->tpl);
88 $this->ref_id = $this->request_wrapper->query()->retrieve('ref_id', $this->refinery->kindlyTo()->string());
89 }
90
95 public function executeCommand(): void
96 {
97 $next_class = $this->ctrl->getNextClass($this);
98
99 $this->help->setScreenIdComponent('sty');
100 $this->help->setScreenId('system_styles');
101
103 $skin_factory = new ilSkinFactory($this->lng);
104
105 if ($this->request_wrapper->query()->has('skin_id') && $this->request_wrapper->query()->has('style_id')) {
106 $skin_id = $this->request_wrapper->query()->retrieve('skin_id', $this->refinery->kindlyTo()->string());
107 $style_id = $this->request_wrapper->query()->retrieve('style_id', $this->refinery->kindlyTo()->string());
108 } else {
109 $skin_id = $config->getDefaultSkinId();
110 $style_id = $config->getDefaultStyleId();
111 }
112
113 $this->ctrl->setParameterByClass('ilsystemstylesettingsgui', 'skin_id', $skin_id);
114 $this->ctrl->setParameterByClass('ilsystemstylesettingsgui', 'style_id', $style_id);
115 $this->ctrl->setParameterByClass('ilsystemstylelessgui', 'skin_id', $skin_id);
116 $this->ctrl->setParameterByClass('ilsystemstylelessgui', 'style_id', $style_id);
117 $this->ctrl->setParameterByClass('ilsystemstyleiconsgui', 'skin_id', $skin_id);
118 $this->ctrl->setParameterByClass('ilsystemstyleiconsgui', 'style_id', $style_id);
119 $this->ctrl->setParameterByClass('ilsystemstyledocumentationgui', 'skin_id', $skin_id);
120 $this->ctrl->setParameterByClass('ilsystemstyledocumentationgui', 'style_id', $style_id);
121
122 try {
123 switch ($next_class) {
124
125 case 'ilsystemstylesettingsgui':
126 $this->help->setSubScreenId('settings');
127 $this->checkPermission('sty_management');
128 $this->setUnderworldTabs($skin_id, 'settings');
129 $this->setUnderworldTitle($skin_id, $style_id);
130 $system_styles_settings = new ilSystemStyleSettingsGUI(
131 $this->ctrl,
132 $this->lng,
133 $this->tpl,
134 $this->tabs,
135 $this->ui_factory,
136 $this->renderer,
138 $this->request_wrapper,
139 $this->refinery,
140 $this->toolbar,
141 $this->user,
142 $this->request,
143 $this->tree,
144 $skin_id,
145 $style_id
146 );
147 $this->ctrl->forwardCommand($system_styles_settings);
148 break;
149 case 'ilsystemstylelessgui':
150 $this->help->setSubScreenId('less');
151 $this->checkPermission('sty_management');
152 $this->setUnderworldTabs($skin_id, 'less');
153 $this->setUnderworldTitle($skin_id, $style_id);
154 $system_styles_less = new ilSystemStyleLessGUI(
155 $this->ctrl,
156 $this->lng,
157 $this->tpl,
158 $this->ui_factory,
159 $this->renderer,
160 $this->request,
161 $this->toolbar,
162 $this->refinery,
163 $skin_factory,
164 $skin_id,
165 $style_id
166 );
167 $this->ctrl->forwardCommand($system_styles_less);
168 break;
169 case 'ilsystemstyleiconsgui':
170 $this->help->setSubScreenId('icons');
171 $this->checkPermission('sty_management');
172 $this->setUnderworldTabs($skin_id, 'icons');
173 $this->setUnderworldTitle($skin_id, $style_id);
174 $system_styles_icons = new ilSystemStyleIconsGUI(
175 $this->ctrl,
176 $this->lng,
177 $this->tpl,
178 $this->ui_factory,
179 $this->renderer,
180 $this->request_wrapper,
181 $this->toolbar,
182 $this->refinery,
183 $skin_factory,
184 $this->tabs,
185 $this->upload,
186 $skin_id,
187 $style_id
188 );
189 $this->ctrl->forwardCommand($system_styles_icons);
190 break;
191 case 'ilsystemstyledocumentationgui':
192 $this->help->setSubScreenId('documentation');
193 $read_only = !$this->checkPermission('sty_management', false);
194 $this->setUnderworldTabs($skin_id, 'documentation', $read_only);
195 $this->setUnderworldTitle($skin_id, $style_id, $read_only);
196 $node_id = '';
197 if ($this->request_wrapper->query()->has('node_id')) {
198 $node_id = $this->request_wrapper->query()->retrieve(
199 'node_id',
200 $this->refinery->kindlyTo()->string()
201 );
202 }
203 $goto_link = (new ilKSDocumentationGotoLink())->generateGotoLink($node_id, $skin_id, $style_id);
204 $this->global_screen->tool()->context()->current()->addAdditionalData(
206 true
207 );
208 $this->tpl->setPermanentLink('stys', (int) $this->ref_id, $goto_link);
209 $entries = new Entries();
210 $entries->addEntriesFromArray(include ilSystemStyleDocumentationGUI::DATA_PATH);
211 $documentation_gui = new ilSystemStyleDocumentationGUI(
212 $this->tpl,
213 $this->ctrl,
214 $this->ui_factory,
215 $this->renderer
216 );
217 $documentation_gui->show($entries, $node_id);
218 break;
219 case 'ilsystemstyleoverviewgui':
220 default:
221 $this->executeDefaultCommand($skin_factory, $skin_id, $style_id);
222 break;
223 }
224 } catch (ilObjectException $e) {
225 $this->message_stack->addMessage(new ilSystemStyleMessage(
226 $e->getMessage(),
228 ));
229 $this->message_stack->sendMessages();
230 $this->executeDefaultCommand($skin_factory, $skin_id, $style_id);
231 }
232 }
233
234 protected function executeDefaultCommand(ilSkinFactory $skin_factory, string $skin_id, string $style_id): void
235 {
236 $this->help->setSubScreenId('overview');
237 $this->checkPermission('visible,read');
238 $read_only = !$this->checkPermission('sty_write_system', false);
239 $management_enabled = $this->checkPermission('sty_management', false);
240 $system_styles_overview = new ilSystemStyleOverviewGUI(
241 $this->ctrl,
242 $this->lng,
243 $this->tpl,
244 $this->ui_factory,
245 $this->renderer,
246 $this->request_wrapper,
247 $this->toolbar,
248 $this->refinery,
249 $skin_factory,
250 $this->upload,
251 $this->tabs,
252 $this->help,
253 $skin_id,
254 $style_id,
255 $this->ref_id,
256 $read_only,
257 $management_enabled
258 );
259
260 $this->ctrl->forwardCommand($system_styles_overview);
261 }
262
268 public function checkPermission(string $a_perm, bool $a_throw_exc = true): bool
269 {
270 $has_perm = true;
271
273 if ($a_perm == 'sty_management') {
274 $has_perm = $this->ilIniFile->readVariable('tools', 'enable_system_styles_management') == '1';
275 $a_perm = 'sty_write_system';
276 if ($has_perm && !is_writable($config->getCustomizingSkinPath())) {
277 $this->message_stack->addMessage(new ilSystemStyleMessage(
278 $this->lng->txt('enable_system_styles_management_no_write_perm'),
280 ));
281 $this->message_stack->sendMessages();
282 $has_perm = false;
283 }
284 }
285
286 if ($has_perm) {
287 $has_perm = $this->rbacsystem->checkAccess($a_perm, (int) $this->ref_id);
288 }
289
290 if (!$has_perm) {
291 if ($a_throw_exc) {
292 throw new ilObjectException($this->lng->txt('sty_permission_denied'));
293 }
294 return false;
295 }
296 return true;
297 }
298
303 protected function setUnderworldTabs(string $sking_id, string $active = '', bool $read_only = false): void
304 {
305 $this->tabs->clearTargets();
306
307 if ($read_only) {
308 $this->locator->clearItems();
309 $this->tpl->setLocator();
310 return;
311 }
312
316 $this->help->setScreenIdComponent('sty');
317 $this->help->setScreenId('system_styles');
318 $this->tabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
320 if ($sking_id != $config->getDefaultSkinId()) {
321 $this->tabs->addTab(
322 'settings',
323 $this->lng->txt('settings'),
324 $this->ctrl->getLinkTargetByClass('ilsystemstylesettingsgui')
325 );
326 $this->tabs->addTab(
327 'less',
328 $this->lng->txt('less'),
329 $this->ctrl->getLinkTargetByClass('ilsystemstylelessgui')
330 );
331 $this->tabs->addTab(
332 'icons',
333 $this->lng->txt('icons'),
334 $this->ctrl->getLinkTargetByClass('ilsystemstyleiconsgui')
335 );
336 }
337
338 $this->tabs->addTab(
339 'documentation',
340 $this->lng->txt('documentation'),
341 $this->ctrl->getLinkTargetByClass('ilsystemstyledocumentationgui')
342 );
343
344 $this->tabs->activateTab($active);
345 }
346
351 protected function setUnderworldTitle(string $skin_id, string $style_id, bool $read_only = false): void
352 {
353 $skin = $this->skin_factory->skinStyleContainerFromId($skin_id, $this->message_stack)->getSkin();
354 $style = $skin->getStyle($style_id);
355
356 if ($read_only) {
357 $this->tpl->setTitle($this->lng->txt('documentation'));
358
359 if ($style->isSubstyle()) {
360 $this->tpl->setDescription(
361 $this->lng->txt('ks_documentation_of_substyle')
362 . " '"
363 . $style->getName() . "' " .
364 $this->lng->txt('of_parent') . " '" . $skin->getStyle($style->getSubstyleOf())->getName() . "' " .
365 $this->lng->txt('from_skin') . ' ' . $skin->getName()
366 );
367 } else {
368 $this->tpl->setDescription(
369 $this->lng->txt('ks_documentation_of_style') . " '" . $style->getName() . "' " .
370 $this->lng->txt('from_skin') . " '" . $skin->getName() . "'"
371 );
372 }
373 } else {
374 $this->tpl->setTitle($style->getName());
375 if ($style->isSubstyle()) {
376 $this->tpl->setDescription(
377 $this->lng->txt('settings_of_substyle') . " '" . $style->getName() . "' " .
378 $this->lng->txt('of_parent') . " '" . $skin->getStyle($style->getSubstyleOf())->getName() . "' " .
379 $this->lng->txt('from_skin') . ' ' . $skin->getName()
380 );
381 } else {
382 $this->tpl->setDescription(
383 $this->lng->txt('settings_of_style') . " '" . $style->getName() . "' " .
384 $this->lng->txt('from_skin') . " '" . $skin->getName() . "'"
385 );
386 }
387 }
388 }
389}
Builds data types.
Definition: Factory.php:21
Container storing a list of UI Component Entries, can act as Iterator, countable and is serializable.
Class ilCtrl provides processing control methods.
Help GUI class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
Factory to create Skin classes holds an manages the basic data of a skin as provide by the template o...
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Renders the Overview of the Examples in the Administration.
@ilCtrl_Calls ilSystemStyleIconsGUI:
Settings UI class for system styles.
executeDefaultCommand(ilSkinFactory $skin_factory, string $skin_id, string $style_id)
setUnderworldTabs(string $sking_id, string $active='', bool $read_only=false)
Sets the tab correctly if one system style is open (navigational underworld opened)
ilSystemStyleMessageStack $message_stack
checkPermission(string $a_perm, bool $a_throw_exc=true)
Checks permission for system styles.
ilGlobalTemplateInterface $tpl
executeCommand()
Main routing of the system styles.
ServerRequestInterface $request
setUnderworldTitle(string $skin_id, string $style_id, bool $read_only=false)
Sets title correctly if one system style is opened.
Used to stack messages to be shown to the user.
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...
global $DIC
Definition: feed.php:28
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc