ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
36{
37 protected ilCtrl $ctrl;
38 protected ilLanguage $lng;
39 protected ilTabsGUI $tabs;
41 protected string $ref_id;
43 protected ilHelpGUI $help;
50 protected RefineryFactory $refinery;
51 protected ServerRequestInterface $request;
55 protected ilTree $tree;
56 protected ilObjUser $user;
58
59 public function __construct()
60 {
64 global $DIC;
65
66 $this->ctrl = $DIC->ctrl();
67 $this->lng = $DIC->language();
68 $this->tabs = $DIC->tabs();
69 $this->rbacsystem = $DIC->rbac()->system();
70 $this->tpl = $DIC->ui()->mainTemplate();
71 $this->help = $DIC->help();
72 $this->ui_factory = $DIC->ui()->factory();
73 $this->renderer = $DIC->ui()->renderer();
74 $this->locator = $DIC['ilLocator'];
75 $this->ilIniFile = $DIC->iliasIni();
76 $this->global_screen = $DIC->globalScreen();
77 $this->request_wrapper = $DIC->http()->wrapper();
78 $this->refinery = $DIC->refinery();
79 $this->request = $DIC->http()->request();
80 $this->toolbar = $DIC->toolbar();
81 $this->upload = $DIC->upload();
82 $this->tree = $DIC->repositoryTree();
83 $this->skin_factory = new ilSkinFactory($this->lng);
84 $this->user = $DIC->user();
85
86 $this->message_stack = new ilSystemStyleMessageStack($this->tpl);
87 $this->ref_id = $this->request_wrapper->query()->retrieve('ref_id', $this->refinery->kindlyTo()->string());
88 }
89
94 public function executeCommand(): void
95 {
96 $next_class = $this->ctrl->getNextClass($this);
97
98 $this->help->setScreenIdComponent('sty');
99 $this->help->setScreenId('system_styles');
100
101 $config = new ilSystemStyleConfig();
102 $skin_factory = new ilSkinFactory($this->lng);
103
104 if ($this->request_wrapper->query()->has('skin_id') && $this->request_wrapper->query()->has('style_id')) {
105 $skin_id = $this->request_wrapper->query()->retrieve('skin_id', $this->refinery->kindlyTo()->string());
106 $style_id = $this->request_wrapper->query()->retrieve('style_id', $this->refinery->kindlyTo()->string());
107 } else {
108 $skin_id = $config->getDefaultSkinId();
109 $style_id = $config->getDefaultStyleId();
110 }
111
112 $this->ctrl->setParameterByClass(ilSystemStyleConfigGUI::class, 'skin_id', $skin_id);
113 $this->ctrl->setParameterByClass(ilSystemStyleConfigGUI::class, 'style_id', $style_id);
114 $this->ctrl->setParameterByClass(ilSystemStyleDocumentationGUI::class, 'skin_id', $skin_id);
115 $this->ctrl->setParameterByClass(ilSystemStyleDocumentationGUI::class, 'style_id', $style_id);
116
117 try {
118 switch ($next_class) {
119 case strtolower(ilSystemStyleConfigGUI::class):
120 $this->help->setSubScreenId('settings');
121 $this->checkPermission('sty_management');
122 $this->setUnderworldTabs($skin_id, 'settings');
123 $this->setUnderworldTitle($skin_id, $style_id, 'settings');
124 $system_styles_settings = new ilSystemStyleConfigGUI(
125 $this->ctrl,
126 $this->lng,
127 $this->tpl,
128 $this->tabs,
129 $this->ui_factory,
130 $this->renderer,
131 $skin_factory,
132 $this->request_wrapper,
133 $this->refinery,
134 $this->toolbar,
135 $this->user,
136 $this->request,
137 $this->tree,
138 $skin_id,
139 $style_id
140 );
141 $this->ctrl->forwardCommand($system_styles_settings);
142 break;
143 case strtolower(ilSystemStyleDocumentationGUI::class):
144 $this->setTabs($skin_id, $style_id);
145 $this->tabs->activateSubTab('documentation');
146 $this->help->setSubScreenId('documentation');
147 $read_only = !$this->checkPermission('sty_management', false);
148 $node_id = '';
149 if ($this->request_wrapper->query()->has('node_id')) {
150 $node_id = $this->request_wrapper->query()->retrieve(
151 'node_id',
152 $this->refinery->kindlyTo()->string()
153 );
154 }
155 $goto_link = (new ilKSDocumentationGotoLink())->generateGotoLink($node_id, $skin_id, $style_id);
156 $this->global_screen->tool()->context()->current()->addAdditionalData(
158 true
159 );
160 $this->tpl->setPermanentLink('stys', (int) $this->ref_id, $goto_link);
161 $entries = new Entries();
162 $entries->addEntriesFromArray(require ilKitchenSinkDataCollectedObjective::PATH());
163 $documentation_gui = new ilSystemStyleDocumentationGUI(
164 $this->tpl,
165 $this->ctrl,
166 $this->ui_factory,
167 $this->renderer
168 );
169 $documentation_gui->show($entries, $node_id);
170 break;
171 case strtolower(ilSystemStyleOverviewGUI::class):
172 default:
173 $this->executeDefaultCommand($skin_factory, $skin_id, $style_id);
174 break;
175 }
176 } catch (ilObjectException $e) {
177 $this->message_stack->addMessage(new ilSystemStyleMessage(
178 $e->getMessage(),
180 ));
181 $this->message_stack->sendMessages();
182 $this->executeDefaultCommand($skin_factory, $skin_id, $style_id);
183 }
184 }
185
186 protected function executeDefaultCommand(ilSkinFactory $skin_factory, string $skin_id, string $style_id): void
187 {
188 $this->help->setSubScreenId('overview');
189 $this->setTabs($skin_id, $style_id);
190 $this->tabs->activateSubTab('overview');
191 $this->checkPermission('visible,read');
192 $read_only = !$this->checkPermission('sty_write_system', false);
193 $management_enabled = true;//$this->checkPermission('sty_management', false);
194 $system_styles_overview = new ilSystemStyleOverviewGUI(
195 $this->ctrl,
196 $this->lng,
197 $this->tpl,
198 $this->ui_factory,
199 $this->renderer,
200 $this->request_wrapper,
201 $this->toolbar,
202 $this->refinery,
203 $skin_factory,
204 $this->upload,
205 $this->tabs,
206 $this->help,
207 $skin_id,
208 $style_id,
209 $this->ref_id,
210 $read_only,
211 $management_enabled
212 );
213
214 $this->ctrl->forwardCommand($system_styles_overview);
215 }
216
221 public function checkPermission(string $a_perm, bool $a_throw_exc = true): bool
222 {
223 $has_perm = $this->rbacsystem->checkAccess($a_perm, (int) $this->ref_id);
224
225 if (!$has_perm) {
226 if ($a_throw_exc) {
227 throw new ilObjectException($this->lng->txt('sty_permission_denied'));
228 }
229 return false;
230 }
231 return true;
232 }
233
234 protected function setTabs(string $skin_id, string $style_id, string $active = '') {
235 $this->ctrl->setParameterByClass(ilSystemStyleDocumentationGUI::class, 'skin_id', $skin_id);
236 $this->ctrl->setParameterByClass(ilSystemStyleDocumentationGUI::class, 'style_id', $style_id);
237
238 $this->tabs->addSubTab(
239 'overview',
240 $this->lng->txt('overview'),
241 $this->ctrl->getLinkTargetByClass(self::class), 'documentation');
242 $this->tabs->addSubTab('documentation',
243 $this->lng->txt('documentation'),
244 $this->ctrl->getLinkTargetByClass(ilSystemStyleDocumentationGUI::class, 'entries')
245 );
246
247 }
252 protected function setUnderworldTabs(string $sking_id, string $active = '', bool $read_only = false): void
253 {
254 $this->tabs->clearTargets();
255
256 if ($read_only) {
257 $this->locator->clearItems();
258 $this->tpl->setLocator();
259 return;
260 }
261
262 $this->help->setScreenIdComponent('sty');
263 $this->help->setScreenId('system_styles');
264 $this->tabs->setBackTarget($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
265
266 $this->tabs->addTab(
267 'settings',
268 $this->lng->txt('settings'),
269 $this->ctrl->getLinkTargetByClass('ilsystemstyleconfiggui')
270 );
271
272 $this->tabs->activateTab($active);
273 }
274
279 protected function setUnderworldTitle(string $skin_id, string $style_id, string $active): void
280 {
281 $skin = $this->skin_factory->skinStyleContainerFromId($skin_id, $this->message_stack)->getSkin();
282 $style = $skin->getStyle($style_id);
283
284 $this->tpl->setTitle($style->getName());
285 if ($style->isSubstyle()) {
286 $this->tpl->setDescription(
287 $this->lng->txt('settings_of_substyle') . " '" . $style->getName() . "' " .
288 $this->lng->txt('of_parent') . " '" . $skin->getStyle($style->getSubstyleOf())->getName() . "' " .
289 $this->lng->txt('from_skin') . ' ' . $skin->getName()
290 );
291 } else {
292 $this->tpl->setDescription(
293 $this->lng->txt('settings_of_style') . " '" . $style->getName() . "' " .
294 $this->lng->txt('from_skin') . " '" . $skin->getName() . "'"
295 );
296 }
297 }
298}
renderer()
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
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.
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
Base exception class for object service.
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.
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
setUnderworldTitle(string $skin_id, string $style_id, string $active)
Sets title correctly if one system style is opened.
checkPermission(string $a_perm, bool $a_throw_exc=true)
Checks permission for system styles.
ilGlobalTemplateInterface $tpl
executeCommand()
Main routing of the system styles.
setTabs(string $skin_id, string $style_id, string $active='')
ServerRequestInterface $request
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...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26