ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ilSystemStyleSettingsGUI Class Reference
+ Collaboration diagram for ilSystemStyleSettingsGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, ilLanguage $lng, ilGlobalTemplateInterface $tpl, ilTabsGUI $tabs, Factory $ui_factory, Renderer $renderer, ilSkinFactory $skin_factory, WrapperFactory $request_wrapper, Refinery $refinery, ilToolbarGUI $toolbar, ilObjUser $user, ServerRequestInterface $request, ilTree $tree, string $skin_id, string $style_id)
 
 executeCommand ()
 

Protected Member Functions

 setSubStyleSubTabs (string $active='')
 
 edit ()
 
 save ()
 
 handleStyleActivation (?array $activation_values, string $skin_id, string $style_id, ilSystemStyleMessageStack $message_stack)
 
 editSystemStyleForm ()
 

Protected Attributes

ilCtrl $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilTabsGUI $tabs
 
Factory $ui_factory
 
Renderer $renderer
 
ilSkinFactory $skin_factory
 
WrapperFactory $request_wrapper
 
Refinery $refinery
 
ilToolbarGUI $toolbar
 
ilObjUser $user
 
ilTree $tree
 
ServerRequestInterface $request
 
string $style_id
 
ilSkinStyleContainer $style_container
 
ilSystemStyleMessageStack $message_stack
 

Detailed Description

Definition at line 28 of file class.ilSystemStyleSettingsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleSettingsGUI::__construct ( ilCtrl  $ctrl,
ilLanguage  $lng,
ilGlobalTemplateInterface  $tpl,
ilTabsGUI  $tabs,
Factory  $ui_factory,
Renderer  $renderer,
ilSkinFactory  $skin_factory,
WrapperFactory  $request_wrapper,
Refinery  $refinery,
ilToolbarGUI  $toolbar,
ilObjUser  $user,
ServerRequestInterface  $request,
ilTree  $tree,
string  $skin_id,
string  $style_id 
)

Definition at line 47 of file class.ilSystemStyleSettingsGUI.php.

63 {
64 $this->ctrl = $ctrl;
65 $this->lng = $lng;
66 $this->tpl = $tpl;
67 $this->tabs = $tabs;
68 $this->ui_factory = $ui_factory;
69 $this->skin_factory = $skin_factory;
70 $this->request_wrapper = $request_wrapper;
71 $this->refinery = $refinery;
72 $this->toolbar = $toolbar;
73 $this->tree = $tree;
74 $this->style_id = $style_id;
75 $this->renderer = $renderer;
76 $this->user = $user;
77 $this->request = $request;
78 $this->message_stack = new ilSystemStyleMessageStack($this->tpl);
79
80 $this->style_container = $this->skin_factory->skinStyleContainerFromId($skin_id, $this->message_stack);
81 }
Used to stack messages to be shown to the user.

References $ctrl, $lng, $refinery, $renderer, $request, $request_wrapper, $skin_factory, $style_id, $tabs, $toolbar, $tpl, $tree, $ui_factory, $user, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ edit()

ilSystemStyleSettingsGUI::edit ( )
protected

Definition at line 147 of file class.ilSystemStyleSettingsGUI.php.

147 : void
148 {
149 $form = $this->editSystemStyleForm();
150 $this->tpl->setContent($this->renderer->render($form));
151 }

References editSystemStyleForm().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editSystemStyleForm()

ilSystemStyleSettingsGUI::editSystemStyleForm ( )
protected
Exceptions
ilSystemStyleException

Definition at line 278 of file class.ilSystemStyleSettingsGUI.php.

278 : Form
279 {
280 $f = $this->ui_factory->input();
281 $skin = $this->style_container->getSkin();
282 $style = $skin->getStyle($this->style_id);
283
284 if (!$style->isSubstyle()) {
285 $skin_fields = [];
286 $skin_fields[] = $f->field()->text($this->lng->txt('skin_id'), $this->lng->txt('skin_id_description'))
287 ->withRequired(true)
288 ->withValue($skin->getId())
289 ->withAdditionalTransformation($this->refinery->custom()->transformation(
290 function ($v) use ($skin) {
291 $skin->setId($v);
292 }
293 ));
294
295 $skin_fields[] = $f->field()->text($this->lng->txt('skin_name'), $this->lng->txt('skin_name_description'))
296 ->withRequired(true)
297 ->withValue($skin->getName())
298 ->withAdditionalTransformation($this->refinery->custom()->transformation(
299 function ($v) use ($skin) {
300 $skin->setName($v);
301 }
302 ));
303
304 if ($skin->isVersionChangeable()) {
305 $skin_fields[] = $f->field()->text(
306 $this->lng->txt('skin_version'),
307 $this->lng->txt('skin_version_description')
308 )
309 ->withDisabled(true)
310 ->withValue($skin->getVersion())
311 ->withAdditionalTransformation($this->refinery->custom()->transformation(
312 function ($v) use ($skin) {
313 $skin->getVersionStep($v);
314 }
315 ));
316 }
317 $sections[] = $f->field()->section($skin_fields, $this->lng->txt('skin'));
318 }
319
320 $style_id = $f->field()->text($this->lng->txt('style_id'), $this->lng->txt('style_id_description'))
321 ->withRequired(true)
322 ->withValue($style->getId())
323 ->withAdditionalTransformation($this->refinery->custom()->transformation(
324 function ($v) use ($style) {
325 $style->setId($v);
326 $style->setCssFile($v);
327 }
328 ));
329 $style_name = $f->field()->text($this->lng->txt('style_name'), $this->lng->txt('style_name_description'))
330 ->withRequired(true)
331 ->withValue($style->getName())
332 ->withAdditionalTransformation($this->refinery->custom()->transformation(
333 function ($v) use ($style) {
334 $style->setName($v);
335 }
336 ));
337 $image_dir = $f->field()->text($this->lng->txt('image_dir'), $this->lng->txt('image_dir_description'))
338 ->withValue($style->getImageDirectory())
339 ->withAdditionalTransformation($this->refinery->custom()->transformation(
340 function ($v) use ($style) {
341 $style->setImageDirectory($v);
342 }
343 ));
344 $font_dir = $f->field()->text($this->lng->txt('font_dir'), $this->lng->txt('font_dir_description'))
345 ->withValue($style->getFontDirectory())
346 ->withAdditionalTransformation($this->refinery->custom()->transformation(
347 function ($v) use ($style) {
348 $style->setFontDirectory($v);
349 }
350 ));
351 $sound_dir = $f->field()->text($this->lng->txt('image_dir'), $this->lng->txt('sound_dir_description'))
352 ->withValue($style->getSoundDirectory())
353 ->withAdditionalTransformation($this->refinery->custom()->transformation(
354 function ($v) use ($style) {
355 $style->setSoundDirectory($v);
356 }
357 ));
358 $section_name = $this->lng->txt('style');
359 if ($style->isSubstyle()) {
360 $this->lng->txt('sub_style');
361 }
362 $sections[] = $f->field()->section([$style_id, $style_name, $image_dir, $font_dir, $sound_dir], $section_name);
363
364 if (!$style->isSubstyle()) {
365 $active = ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId());
366 $activation_values = null;
367 if ($active) {
368 $is_personal_style = $this->user->getPref('skin') == $skin->getId()
369 && $this->user->getPref('style') == $style->getId();
370 $is_default_style = ilSystemStyleSettings::getCurrentDefaultSkin() == $skin->getId()
371 && ilSystemStyleSettings::getCurrentDefaultStyle() == $style->getId();
372 $activation_values = ['default' => $is_default_style, 'personal' => $is_personal_style];
373 }
374
375 $default = $f->field()->checkbox(
376 $this->lng->txt('default'),
377 $this->lng->txt('system_style_default_description')
378 );
379
380 $personal = $f->field()->checkbox(
381 $this->lng->txt('personal'),
382 $this->lng->txt('system_style_personal_description')
383 );
384
385 $activation = $f->field()->optionalGroup(
386 ['default' => $default, 'personal' => $personal],
387 $this->lng->txt('system_style_activation'),
388 $this->lng->txt('system_style_activation_description')
389 )->withValue($activation_values);
390 $sections['activation_section'] = $f->field()->section(
391 ['activation' => $activation],
392 $this->lng->txt('system_style_activation')
393 )
394 ->withAdditionalTransformation($this->refinery->custom()->transformation(
395 function ($v) {
396 return $v['activation'];
397 }
398 ));
399 }
400
401 return $f->container()->form()->standard($this->ctrl->getFormActionByClass(
402 'ilsystemstylesettingsgui',
403 'save'
404 ), $sections);
405 }
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
static getCurrentDefaultStyle()
Gets default style of the system.
static _lookupActivatedStyle(string $a_skin, string $a_style)
lookup if a style is activated
static getCurrentDefaultSkin()
Gets default Skin of the System.

References Vendor\Package\$f, ilSystemStyleSettings\_lookupActivatedStyle(), ILIAS\Repository\ctrl(), function, ilSystemStyleSettings\getCurrentDefaultSkin(), ilSystemStyleSettings\getCurrentDefaultStyle(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

Referenced by edit(), and save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilSystemStyleSettingsGUI::executeCommand ( )

Definition at line 83 of file class.ilSystemStyleSettingsGUI.php.

83 : void
84 {
85 $cmd = $this->ctrl->getCmd() ? $this->ctrl->getCmd() : 'edit';
86 $style = $this->style_container->getSkin()->getStyle($this->style_id);
87
88 if ($style->isSubstyle()) {
89 if ($cmd == 'edit' || $cmd == 'view') {
90 $this->setSubStyleSubTabs('edit');
91 } else {
92 $this->setSubStyleSubTabs('assignStyle');
93 }
94 }
95
96 $assign_gui = new ilSubStyleAssignmentGUI(
97 $this,
98 $this->ctrl,
99 $this->lng,
100 $this->tpl,
101 $this->toolbar,
102 $this->tree,
103 $this->request_wrapper,
104 $this->refinery,
105 $this->ui_factory
106 );
107
108 switch ($cmd) {
109 case 'deleteAssignments':
110 $assign_gui->deleteAssignments($this->style_container->getSkin(), $style);
111 break;
112 case 'saveAssignment':
113 $assign_gui->saveAssignment($this->style_container->getSkin(), $style);
114 break;
115 case 'addAssignment':
116 $assign_gui->addAssignment();
117 break;
118 case 'assignStyle':
119 $assign_gui->assignStyle($this->style_container->getSkin(), $style);
120 break;
121 case 'save':
122 $this->save();
123 break;
124 case 'edit':
125 default:
126 $this->edit();
127 break;
128 }
129 }

References ILIAS\Repository\ctrl(), edit(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), save(), setSubStyleSubTabs(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

◆ handleStyleActivation()

ilSystemStyleSettingsGUI::handleStyleActivation ( ?array  $activation_values,
string  $skin_id,
string  $style_id,
ilSystemStyleMessageStack  $message_stack 
)
protected

Definition at line 210 of file class.ilSystemStyleSettingsGUI.php.

215 : void {
216 $active = false;
217 $personal = false;
218 $default = false;
219
220 if (is_array($activation_values)) {
221 $active = true;
222 $personal = (bool) $activation_values['personal'];
223 $default = (bool) $activation_values['default'];
224 }
225 if ($active) {
227 if ($personal) {
229 }
230 if ($default) {
232 }
233 } else {
235 }
236
237 $system_style_conf = new ilSystemStyleConfig();
238
239 //If style has been unset as personal style
240 if (!$personal && $this->user->getPref('skin') == $skin_id) {
241 //Reset to default if possible, else change to delos
242 if (!$default) {
246 );
247 } else {
249 $system_style_conf->getDefaultSkinId(),
250 $system_style_conf->getDefaultStyleId()
251 );
252 }
255 $this->lng->txt('personal_style_set_to') . ' ' .
258 )
259 );
260 }
261 if (!$default && ilSystemStyleSettings::getCurrentDefaultSkin() == $skin_id) {
263 $system_style_conf->getDefaultSkinId(),
264 $system_style_conf->getDefaultStyleId()
265 );
268 $this->lng->txt('default_style_set_to') . ' ' . $system_style_conf->getDefaultSkinId() . ': ' . $system_style_conf->getDefaultStyleId(),
270 )
271 );
272 }
273 }
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
ilSystemStyleMessageStack $message_stack
static _activateStyle(string $a_skin, string $a_style)
activate system style
static getCurrentUserPrefSkin()
Gets a users preferred skin by using the user object.
static _deactivateStyle(string $a_skin, string $a_style)
deactivate system style
static setCurrentUserPrefStyle(string $skin_id, string $style_id)
Sets a users preferred system skin/style by using the user object.
static setCurrentDefaultStyle(string $skin_id, string $style_id)
Sets the default style of the system.
static getCurrentUserPrefStyle()
Gets a users preferred style by using the user object.

Referenced by save().

+ Here is the caller graph for this function:

◆ save()

ilSystemStyleSettingsGUI::save ( )
protected

Definition at line 153 of file class.ilSystemStyleSettingsGUI.php.

153 : void
154 {
155 $new_skin = $this->style_container->getSkin();
156 $new_style = $new_skin->getStyle($this->style_id);
157 $old_skin = clone $new_skin;
158 $old_style = clone $new_style;
159
160 $form = $this->editSystemStyleForm();
161 $form = $form->withRequest($this->request);
162 $result = $form->getData();
163
164 if ($result) {
165 try {
166 $new_skin->updateParentStyleOfSubstyles($old_style->getId(), $new_style->getId());
167 $this->style_container->updateSkin($old_skin);
168 $this->style_container->updateStyle($new_style->getId(), $old_style);
169
170 if ($old_style->isSubstyle()) {
171 $new_style->setSubstyleOf($old_style->getSubstyleOf());
173 $old_style->getId(),
174 $new_style->getId()
175 );
176 } else {
178 $old_skin->getId(),
179 $old_style->getId(),
180 $new_skin->getId(),
181 $new_style->getId()
182 );
183
185 $result['activation_section'],
186 $new_skin->getId(),
187 $new_style->getId(),
188 $this->message_stack
189 );
190 }
191
192 $this->ctrl->setParameterByClass('ilSystemStyleSettingsGUI', 'skin_id', $new_skin->getId());
193 $this->ctrl->setParameterByClass('ilSystemStyleSettingsGUI', 'style_id', $new_style->getId());
194 $this->message_stack->prependMessage(new ilSystemStyleMessage($this->lng->txt('msg_sys_style_update')));
195 $this->message_stack->sendMessages();
196 $this->ctrl->redirectByClass('ilSystemStyleSettingsGUI');
197 } catch (ilSystemStyleException $e) {
198 $this->message_stack->prependMessage(new ilSystemStyleMessage(
199 $e->getMessage(),
201 ));
202 }
203 }
204
205 $this->tpl->setContent($this->renderer->render(
206 array_merge($this->message_stack->getUIComponentsMessages($this->ui_factory), [$form])
207 ));
208 }
Class for advanced editing exception handling in ILIAS.
handleStyleActivation(?array $activation_values, string $skin_id, string $style_id, ilSystemStyleMessageStack $message_stack)
static updateSubStyleIdfSubStyleCategoryAssignments(string $old_substyle_id, string $new_substyle_id)
Updates an assignment, e.g.
static updateSkinIdAndStyleIDOfSubStyleCategoryAssignments(string $old_skin_id, string $old_style_id, string $new_skin_id, string $new_style_id)
Updates an assignment, e.g.

References Vendor\Package\$e, ILIAS\Repository\ctrl(), editSystemStyleForm(), handleStyleActivation(), ILIAS\Repository\lng(), ilSystemStyleMessage\TYPE_ERROR, ilSystemStyleSettings\updateSkinIdAndStyleIDOfSubStyleCategoryAssignments(), and ilSystemStyleSettings\updateSubStyleIdfSubStyleCategoryAssignments().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSubStyleSubTabs()

ilSystemStyleSettingsGUI::setSubStyleSubTabs ( string  $active = '')
protected

Definition at line 131 of file class.ilSystemStyleSettingsGUI.php.

131 : void
132 {
133 $this->tabs->addSubTab(
134 'edit',
135 $this->lng->txt('settings'),
136 $this->ctrl->getLinkTargetByClass('ilsystemstylesettingsgui')
137 );
138 $this->tabs->addSubTab(
139 'assignStyle',
140 $this->lng->txt('assignment'),
141 $this->ctrl->getLinkTargetByClass('ilsystemstylesettingsgui', 'assignStyle')
142 );
143
144 $this->tabs->activateSubTab($active);
145 }

References ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilSystemStyleSettingsGUI::$ctrl
protected

Definition at line 30 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $lng

ilLanguage ilSystemStyleSettingsGUI::$lng
protected

Definition at line 31 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $message_stack

ilSystemStyleMessageStack ilSystemStyleSettingsGUI::$message_stack
protected

Definition at line 45 of file class.ilSystemStyleSettingsGUI.php.

◆ $refinery

Refinery ilSystemStyleSettingsGUI::$refinery
protected

Definition at line 38 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $renderer

Renderer ilSystemStyleSettingsGUI::$renderer
protected

Definition at line 35 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $request

ServerRequestInterface ilSystemStyleSettingsGUI::$request
protected

Definition at line 42 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $request_wrapper

WrapperFactory ilSystemStyleSettingsGUI::$request_wrapper
protected

Definition at line 37 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $skin_factory

ilSkinFactory ilSystemStyleSettingsGUI::$skin_factory
protected

Definition at line 36 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $style_container

ilSkinStyleContainer ilSystemStyleSettingsGUI::$style_container
protected

Definition at line 44 of file class.ilSystemStyleSettingsGUI.php.

◆ $style_id

string ilSystemStyleSettingsGUI::$style_id
protected

Definition at line 43 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $tabs

ilTabsGUI ilSystemStyleSettingsGUI::$tabs
protected

Definition at line 33 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $toolbar

ilToolbarGUI ilSystemStyleSettingsGUI::$toolbar
protected

Definition at line 39 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $tpl

ilGlobalTemplateInterface ilSystemStyleSettingsGUI::$tpl
protected

Definition at line 32 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $tree

ilTree ilSystemStyleSettingsGUI::$tree
protected

Definition at line 41 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $ui_factory

Factory ilSystemStyleSettingsGUI::$ui_factory
protected

Definition at line 34 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().

◆ $user

ilObjUser ilSystemStyleSettingsGUI::$user
protected

Definition at line 40 of file class.ilSystemStyleSettingsGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: