ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSystemStyleConfigGUI Class Reference
+ Collaboration diagram for ilSystemStyleConfigGUI:

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

 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.ilSystemStyleConfigGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleConfigGUI::__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.ilSystemStyleConfigGUI.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 }
renderer()
ilGlobalTemplateInterface $tpl
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(), renderer(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ edit()

ilSystemStyleConfigGUI::edit ( )
protected

Definition at line 123 of file class.ilSystemStyleConfigGUI.php.

123 : void
124 {
125 $form = $this->editSystemStyleForm();
126 $this->tpl->setContent($this->renderer->render($form));
127 }

References editSystemStyleForm(), and renderer().

Referenced by executeCommand().

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

◆ editSystemStyleForm()

ilSystemStyleConfigGUI::editSystemStyleForm ( )
protected
Exceptions
ilSystemStyleException

Definition at line 254 of file class.ilSystemStyleConfigGUI.php.

254 : Form
255 {
256 $f = $this->ui_factory->input();
257 $skin = $this->style_container->getSkin();
258 $style = $skin->getStyle($this->style_id);
259
260 if (!$style->isSubstyle()) {
261 $skin_fields = [];
262 $skin_fields[] = $f->field()->text($this->lng->txt('skin_id'), $this->lng->txt('skin_id_description'))
263 ->withRequired(true)
264 ->withValue($skin->getId())
265 ->withAdditionalTransformation($this->refinery->custom()->transformation(
266 function ($v) use ($skin) {
267 $skin->setId($v);
268 }
269 ));
270
271 $skin_fields[] = $f->field()->text($this->lng->txt('skin_name'), $this->lng->txt('skin_name_description'))
272 ->withRequired(true)
273 ->withValue($skin->getName())
274 ->withAdditionalTransformation($this->refinery->custom()->transformation(
275 function ($v) use ($skin) {
276 $skin->setName($v);
277 }
278 ));
279
280 if ($skin->isVersionChangeable()) {
281 $skin_fields[] = $f->field()->text(
282 $this->lng->txt('skin_version'),
283 $this->lng->txt('skin_version_description')
284 )
285 ->withDisabled(true)
286 ->withValue($skin->getVersion())
287 ->withAdditionalTransformation($this->refinery->custom()->transformation(
288 function ($v) use ($skin) {
289 $skin->getVersionStep($v);
290 }
291 ));
292 }
293 $sections[] = $f->field()->section($skin_fields, $this->lng->txt('skin'));
294 }
295
296 $style_id = $f->field()->text($this->lng->txt('style_id'), $this->lng->txt('style_id_description'))
297 ->withRequired(true)
298 ->withValue($style->getId())
299 ->withAdditionalTransformation($this->refinery->custom()->transformation(
300 function ($v) use ($style) {
301 $style->setId($v);
302 $style->setCssFile($v);
303 }
304 ));
305 $style_name = $f->field()->text($this->lng->txt('style_name'), $this->lng->txt('style_name_description'))
306 ->withRequired(true)
307 ->withValue($style->getName())
308 ->withAdditionalTransformation($this->refinery->custom()->transformation(
309 function ($v) use ($style) {
310 $style->setName($v);
311 }
312 ));
313 $image_dir = $f->field()->text($this->lng->txt('image_dir'), $this->lng->txt('image_dir_description'))
314 ->withValue($style->getImageDirectory())
315 ->withAdditionalTransformation($this->refinery->custom()->transformation(
316 function ($v) use ($style) {
317 $style->setImageDirectory($v);
318 }
319 ));
320 $font_dir = $f->field()->text($this->lng->txt('font_dir'), $this->lng->txt('font_dir_description'))
321 ->withValue($style->getFontDirectory())
322 ->withAdditionalTransformation($this->refinery->custom()->transformation(
323 function ($v) use ($style) {
324 $style->setFontDirectory($v);
325 }
326 ));
327 $sound_dir = $f->field()->text($this->lng->txt('sound_dir'), $this->lng->txt('sound_dir_description'))
328 ->withValue($style->getSoundDirectory())
329 ->withAdditionalTransformation($this->refinery->custom()->transformation(
330 function ($v) use ($style) {
331 $style->setSoundDirectory($v);
332 }
333 ));
334 $section_name = $this->lng->txt('style');
335 if ($style->isSubstyle()) {
336 $this->lng->txt('sub_style');
337 }
338 $sections[] = $f->field()->section([$style_id, $style_name, $image_dir, $font_dir, $sound_dir], $section_name);
339
340 if (!$style->isSubstyle()) {
341 $active = ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId());
342 $activation_values = null;
343 if ($active) {
344 $is_personal_style = $this->user->getPref('skin') == $skin->getId()
345 && $this->user->getPref('style') == $style->getId();
346 $is_default_style = ilSystemStyleSettings::getCurrentDefaultSkin() == $skin->getId()
347 && ilSystemStyleSettings::getCurrentDefaultStyle() == $style->getId();
348 $activation_values = ['default' => $is_default_style, 'personal' => $is_personal_style];
349 }
350
351 $default = $f->field()->checkbox(
352 $this->lng->txt('default'),
353 $this->lng->txt('system_style_default_description')
354 );
355
356 $personal = $f->field()->checkbox(
357 $this->lng->txt('personal'),
358 $this->lng->txt('system_style_personal_description')
359 );
360
361 $activation = $f->field()->optionalGroup(
362 ['default' => $default, 'personal' => $personal],
363 $this->lng->txt('system_style_activation'),
364 $this->lng->txt('system_style_activation_description')
365 )->withValue($activation_values);
366 $sections['activation_section'] = $f->field()->section(
367 ['activation' => $activation],
368 $this->lng->txt('system_style_activation')
369 )
370 ->withAdditionalTransformation($this->refinery->custom()->transformation(
371 function ($v) {
372 return $v['activation'];
373 }
374 ));
375 }
376
377 return $f->container()->form()->standard($this->ctrl->getFormActionByClass(
378 'ilsystemstyleconfiggui',
379 'save'
380 ), $sections);
381 }
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(), 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()

ilSystemStyleConfigGUI::executeCommand ( )

Definition at line 83 of file class.ilSystemStyleConfigGUI.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 $assign_gui = new ilSubStyleAssignmentGUI(
89 $this,
90 $this->ctrl,
91 $this->lng,
92 $this->tpl,
93 $this->toolbar,
94 $this->tree,
95 $this->request_wrapper,
96 $this->refinery,
97 $this->ui_factory
98 );
99
100 switch ($cmd) {
101 case 'deleteAssignments':
102 $assign_gui->deleteAssignments($this->style_container->getSkin(), $style);
103 break;
104 case 'saveAssignment':
105 $assign_gui->saveAssignment($this->style_container->getSkin(), $style);
106 break;
107 case 'addAssignment':
108 $assign_gui->addAssignment();
109 break;
110 case 'assignStyle':
111 $assign_gui->assignStyle($this->style_container->getSkin(), $style);
112 break;
113 case 'save':
114 $this->save();
115 break;
116 case 'edit':
117 default:
118 $this->edit();
119 break;
120 }
121 }

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

+ Here is the call graph for this function:

◆ handleStyleActivation()

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

Definition at line 186 of file class.ilSystemStyleConfigGUI.php.

191 : void {
192 $active = false;
193 $personal = false;
194 $default = false;
195
196 if (is_array($activation_values)) {
197 $active = true;
198 $personal = (bool) $activation_values['personal'];
199 $default = (bool) $activation_values['default'];
200 }
201 if ($active) {
203 if ($personal) {
205 }
206 if ($default) {
208 }
209 } else {
211 }
212
213 $system_style_conf = new ilSystemStyleConfig();
214
215 //If style has been unset as personal style
216 if (!$personal && $this->user->getPref('skin') == $skin_id) {
217 //Reset to default if possible, else change to delos
218 if (!$default) {
222 );
223 } else {
225 $system_style_conf->getDefaultSkinId(),
226 $system_style_conf->getDefaultStyleId()
227 );
228 }
231 $this->lng->txt('personal_style_set_to') . ' ' .
234 )
235 );
236 }
237 if (!$default && ilSystemStyleSettings::getCurrentDefaultSkin() == $skin_id) {
239 $system_style_conf->getDefaultSkinId(),
240 $system_style_conf->getDefaultStyleId()
241 );
244 $this->lng->txt('default_style_set_to') . ' ' . $system_style_conf->getDefaultSkinId() . ': ' . $system_style_conf->getDefaultStyleId(),
246 )
247 );
248 }
249 }
ilSystemStyleMessageStack $message_stack
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.
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()

ilSystemStyleConfigGUI::save ( )
protected

Definition at line 129 of file class.ilSystemStyleConfigGUI.php.

129 : void
130 {
131 $new_skin = $this->style_container->getSkin();
132 $new_style = $new_skin->getStyle($this->style_id);
133 $old_skin = clone $new_skin;
134 $old_style = clone $new_style;
135
136 $form = $this->editSystemStyleForm();
137 $form = $form->withRequest($this->request);
138 $result = $form->getData();
139
140 if ($result) {
141 try {
142 $new_skin->updateParentStyleOfSubstyles($old_style->getId(), $new_style->getId());
143 $this->style_container->updateSkin($old_skin);
144 $this->style_container->updateStyle($new_style->getId(), $old_style);
145
146 if ($old_style->isSubstyle()) {
147 $new_style->setSubstyleOf($old_style->getSubstyleOf());
149 $old_style->getId(),
150 $new_style->getId()
151 );
152 } else {
154 $old_skin->getId(),
155 $old_style->getId(),
156 $new_skin->getId(),
157 $new_style->getId()
158 );
159
161 $result['activation_section'],
162 $new_skin->getId(),
163 $new_style->getId(),
164 $this->message_stack
165 );
166 }
167
168 $this->ctrl->setParameterByClass('ilsystemstyleconfiggui', 'skin_id', $new_skin->getId());
169 $this->ctrl->setParameterByClass('ilsystemstyleconfiggui', 'style_id', $new_style->getId());
170 $this->message_stack->prependMessage(new ilSystemStyleMessage($this->lng->txt('msg_sys_style_update')));
171 $this->message_stack->sendMessages();
172 $this->ctrl->redirectByClass('ilsystemstyleconfiggui');
173 } catch (ilSystemStyleException $e) {
174 $this->message_stack->prependMessage(new ilSystemStyleMessage(
175 $e->getMessage(),
177 ));
178 }
179 }
180
181 $this->tpl->setContent($this->renderer->render(
182 array_merge($this->message_stack->getUIComponentsMessages($this->ui_factory), [$form])
183 ));
184 }
handleStyleActivation(?array $activation_values, string $skin_id, string $style_id, ilSystemStyleMessageStack $message_stack)
Class for advanced editing exception handling in ILIAS.
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(), renderer(), 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:

Field Documentation

◆ $ctrl

ilCtrl ilSystemStyleConfigGUI::$ctrl
protected

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

Referenced by __construct().

◆ $lng

ilLanguage ilSystemStyleConfigGUI::$lng
protected

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

Referenced by __construct().

◆ $message_stack

ilSystemStyleMessageStack ilSystemStyleConfigGUI::$message_stack
protected

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

◆ $refinery

Refinery ilSystemStyleConfigGUI::$refinery
protected

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

Referenced by __construct().

◆ $renderer

Renderer ilSystemStyleConfigGUI::$renderer
protected

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

Referenced by __construct().

◆ $request

ServerRequestInterface ilSystemStyleConfigGUI::$request
protected

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

Referenced by __construct().

◆ $request_wrapper

WrapperFactory ilSystemStyleConfigGUI::$request_wrapper
protected

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

Referenced by __construct().

◆ $skin_factory

ilSkinFactory ilSystemStyleConfigGUI::$skin_factory
protected

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

Referenced by __construct().

◆ $style_container

ilSkinStyleContainer ilSystemStyleConfigGUI::$style_container
protected

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

◆ $style_id

string ilSystemStyleConfigGUI::$style_id
protected

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

Referenced by __construct().

◆ $tabs

ilTabsGUI ilSystemStyleConfigGUI::$tabs
protected

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

Referenced by __construct().

◆ $toolbar

ilToolbarGUI ilSystemStyleConfigGUI::$toolbar
protected

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

Referenced by __construct().

◆ $tpl

ilGlobalTemplateInterface ilSystemStyleConfigGUI::$tpl
protected

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

Referenced by __construct().

◆ $tree

ilTree ilSystemStyleConfigGUI::$tree
protected

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

Referenced by __construct().

◆ $ui_factory

Factory ilSystemStyleConfigGUI::$ui_factory
protected

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

Referenced by __construct().

◆ $user

ilObjUser ilSystemStyleConfigGUI::$user
protected

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

Referenced by __construct().


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