19 declare(strict_types=1);
68 bool $management_enabled
94 $cmd = $this->
ctrl->getCmd();
101 case 'addSystemStyle':
103 case 'saveNewSystemStyle':
104 case 'saveNewSubStyle':
109 case 'confirmDelete':
118 case 'moveUserStyles':
119 case 'saveStyleSettings':
130 $this->message_stack->sendMessages();
133 protected function view(): void
136 $this->tpl->setContent($table->getHTML());
148 $this->
toolbar->addComponent($this->ui_factory->button()->standard(
149 $this->
lng->txt(
'add_system_style'),
150 $this->
ctrl->getLinkTarget($this,
'addSystemStyle')
154 $add_sub = $this->ui_factory->button()->standard(
155 $this->
lng->txt(
'add_substyle'),
156 $this->
ctrl->getLinkTarget($this,
'addSubStyle')
158 if (count(ilStyleDefinition::getAllSkins()) == 1) {
159 $add_sub = $add_sub->withUnavailableAction();
161 $this->
toolbar->addComponent($add_sub);
162 $this->
toolbar->addSeparator();
167 $this->
lng->txt(
'sty_move_user_styles') .
': ' . $this->
lng->txt(
'sty_from'),
173 if (!$skin_style[
'substyle_of']) {
174 $options[
$id] = $skin_style[
'title'];
177 $si->
setOptions($options + [
'other' => $this->
lng->txt(
'other')]);
179 $this->
toolbar->addInputItem($si,
true);
182 $si->setOptions($options);
183 $this->
toolbar->addInputItem($si,
true);
184 $this->
toolbar->addComponent($this->ui_factory->button()->standard($this->
lng->txt(
'sty_move_style'),
''));
186 $this->
toolbar->setFormAction($this->
ctrl->getLinkTarget($this,
'moveUserStyles'));
190 $this->tpl->setContent($table->getHTML());
195 $to = $this->request_wrapper->post()->retrieve(
'to_style', $this->
refinery->string()->splitString(
':'));
197 $from_style = $this->request_wrapper->post()->retrieve(
'from_style', $this->
refinery->kindlyTo()->string());
199 if ($from_style ==
'other') {
205 foreach ($all_user_styles as $style) {
207 $style_arr = explode(
':', $style);
212 $from = explode(
':', $from_style);
222 $active_styles = $this->request_wrapper->post()->retrieve(
'st_act', $this->
refinery->identity());
226 foreach ($all_styles as $style) {
227 if (!isset($active_styles[$style[
'id']])) {
235 if ($this->request_wrapper->post()->has(
'default_skin_style')) {
236 $sknst = $this->request_wrapper->post()->retrieve(
237 'default_skin_style',
238 $this->
refinery->string()->splitString(
':')
243 $this->
lng->txt(
'msg_obj_modified'),
247 $this->message_stack->sendMessages();
248 $this->
ctrl->redirect($this,
'edit');
255 if (count($active_styles) < 1) {
258 $this->
lng->txt(
'at_least_one_style'),
263 $default_style = $this->request_wrapper->post()->retrieve(
264 'default_skin_style',
265 $this->
refinery->kindlyTo()->string()
268 if (!isset($active_styles[$default_style])) {
271 $this->
lng->txt(
'cant_deactivate_default_style'),
280 foreach ($all_styles as $style) {
281 if (!isset($active_styles[$style[
'id']])) {
285 $style[
'style_name'] .
': ' . $this->
lng->txt(
'cant_deactivate_if_users_assigned'),
303 if ($form->checkInput()) {
304 $skin_id = $this->request_wrapper->post()->retrieve(
'skin_id', $this->
refinery->kindlyTo()->string());
305 $style_id = $this->request_wrapper->post()->retrieve(
'style_id', $this->
refinery->kindlyTo()->string());
307 $skin_name = $this->request_wrapper->post()->retrieve(
'skin_name', $this->
refinery->kindlyTo()->string());
308 $style_name = $this->request_wrapper->post()->retrieve(
'style_name', $this->
refinery->kindlyTo()->string());
312 $this->
lng->txt(
'skin_id_exists'),
317 $skin =
new ilSkin($skin_id, $skin_name);
319 $skin->addStyle($style);
322 $this->
ctrl->setParameterByClass(
'ilSystemStyleSettingsGUI',
'skin_id', $skin->getId());
323 $this->
ctrl->setParameterByClass(
'ilSystemStyleSettingsGUI',
'style_id', $style->getId());
325 $this->message_stack->sendMessages();
326 $this->
ctrl->redirectByClass(
'ilSystemStyleSettingsGUI');
337 $form->setValuesByPost();
338 $this->tpl->setContent($form->getHTML());
343 $this->
tabs->clearTargets();
347 $this->
help->setScreenIdComponent(
'sty');
348 $this->
help->setScreenId(
'system_styles');
349 $this->
help->setSubScreenId(
'create');
357 $this->tpl->setContent($this->getCreationFormsHTML($forms));
363 $form->setFormAction($this->
ctrl->getFormAction($this));
364 $form->setTitle($this->
lng->txt(
'sty_create_new_system_style'));
367 $ti->setInfo($this->
lng->txt(
'skin_id_description'));
368 $ti->setMaxLength(128);
370 $ti->setRequired(
true);
374 $ti->setInfo($this->
lng->txt(
'skin_name_description'));
375 $ti->setMaxLength(128);
377 $ti->setRequired(
true);
381 $ti->setInfo($this->
lng->txt(
'style_id_description'));
382 $ti->setMaxLength(128);
384 $ti->setRequired(
true);
388 $ti->setInfo($this->
lng->txt(
'style_name_description'));
389 $ti->setMaxLength(128);
391 $ti->setRequired(
true);
394 $form->addCommandButton(
'saveNewSystemStyle', $this->
lng->txt(
'save'));
395 $form->addCommandButton(
'cancel', $this->
lng->txt(
'cancel'));
403 $form->setFormAction($this->
ctrl->getFormAction($this,
'importStyle'));
404 $form->setTitle($this->
lng->txt(
'sty_import_system_style'));
409 $file_input->setSuffixes([
'zip']);
410 $form->addItem($file_input);
412 $form->addCommandButton(
'importStyle', $this->
lng->txt(
'import'));
413 $form->addCommandButton(
'cancel', $this->
lng->txt(
'cancel'));
421 $form->setFormAction($this->
ctrl->getFormAction($this));
422 $form->setTitle($this->
lng->txt(
'sty_copy_other_system_style'));
426 $ti->setRequired(
true);
429 foreach ($styles as
$id => $style) {
431 if ($style[
'skin_id'] != $system_style_conf->getDefaultSkinId()) {
432 $options[
$id] = $style[
'title'];
435 $ti->setOptions($options);
439 $form->addCommandButton(
'copyStyle', $this->
lng->txt(
'copy'));
440 $form->addCommandButton(
'cancel', $this->
lng->txt(
'cancel'));
445 protected function getCreationFormsHTML(array $a_forms):
string 447 include_once(
'./Services/Accordion/classes/class.ilAccordionGUI.php');
452 foreach ($a_forms as $form_type => $cf) {
456 $htpl =
new ilTemplate(
'tpl.creation_acc_head.html',
true,
true,
'Services/Object');
460 if (method_exists($this,
'getCreationFormTitle')) {
461 $form_title = $this->getCreationFormTitle($form_type);
464 $form_title = $cf->getTitle();
468 $htpl->setVariable(
'TITLE', $this->
lng->txt(
'option') .
' ' . $cnt .
': ' .
471 $cf->setTitleIcon(
'');
472 $cf->setTableWidth(
'100%');
474 $acc->addItem($htpl->get(), $cf->getHTML());
479 return "<div class='ilCreationFormSection'>" . $acc->getHTML() .
'</div>';
484 $imploded_skin_style_id = $this->request_wrapper->post()->retrieve(
486 $this->
refinery->string()->splitString(
':')
488 $skin_id = $imploded_skin_style_id[0];
489 $style_id = $imploded_skin_style_id[1];
492 $container = $this->skin_factory->skinStyleContainerFromId($skin_id, $this->message_stack);
493 $new_container = $this->skin_factory->copyFromSkinStyleContainer(
496 $this->message_stack,
497 $this->
lng->txt(
'sty_acopy')
500 $this->
lng->txt(
'style_copied'),
503 $this->
ctrl->setParameterByClass(
'ilSystemStyleSettingsGUI',
'skin_id', $new_container->getSkin()->getId());
504 $this->
ctrl->setParameterByClass(
505 'ilSystemStyleSettingsGUI',
507 $new_container->getSkin()->getStyle($style_id)->getId()
510 $this->
lng->txt(
'directory_created') .
' ' . $new_container->getSkinDirectory(),
519 $this->message_stack->sendMessages();
520 $this->
ctrl->redirectByClass(
'ilSystemStyleSettingsGUI');
525 $skin_id = $this->style_container->getSkin()->getId();
528 if ($this->
checkDeletable($skin_id, $style_id, $this->message_stack)) {
530 $container = $this->skin_factory->skinStyleContainerFromId($skin_id, $this->message_stack);
531 $delete_form_table->addStyle(
534 $container->getImagesSkinPath($style_id) .
'/icon_stys.svg' 536 $this->tpl->setContent($delete_form_table->getDeleteStyleFormHTML());
539 $this->
lng->txt(
'style_not_deleted'),
550 $all_deletable =
true;
552 $skin_ids = $this->request_wrapper->post()->retrieve(
'id', $this->
refinery->identity());
553 foreach ($skin_ids as $skin_style_id) {
554 $imploded_skin_style_id = explode(
':', $skin_style_id);
555 $skin_id = $imploded_skin_style_id[0];
556 $style_id = $imploded_skin_style_id[1];
557 if (!$this->
checkDeletable($skin_id, $style_id, $this->message_stack)) {
558 $all_deletable =
false;
561 if ($all_deletable) {
562 foreach ($skin_ids as $skin_style_id) {
563 $imploded_skin_style_id = explode(
':', $skin_style_id);
564 $skin_id = $imploded_skin_style_id[0];
565 $style_id = $imploded_skin_style_id[1];
566 $container = $this->skin_factory->skinStyleContainerFromId($skin_id, $this->message_stack);
567 $delete_form_table->addStyle(
570 $container->getImagesSkinPath($style_id) .
'/icon_stys.svg' 573 $this->tpl->setContent($delete_form_table->getDeleteStyleFormHTML());
576 $this->
lng->txt(
'styles_not_deleted'),
591 $style_id .
': ' . $this->
lng->txt(
'cant_delete_if_users_assigned'),
598 $style_id .
': ' . $this->
lng->txt(
'cant_delete_activated_style'),
605 $style_id .
': ' . $this->
lng->txt(
'cant_delete_default_style'),
611 if ($this->skin_factory->skinStyleContainerFromId($skin_id, $this->message_stack)->getSkin()->getSubstylesOfStyle($style_id)) {
613 $style_id .
': ' . $this->
lng->txt(
'cant_delete_style_with_substyles'),
624 while ($this->request_wrapper->post()->has(
'style_' .
$i)) {
626 $skin_style_id = $this->request_wrapper->post()->retrieve(
628 $this->
refinery->string()->splitString(
':')
630 $container = $this->skin_factory->skinStyleContainerFromId($skin_style_id[0], $this->message_stack);
631 $syle =
$container->getSkin()->getStyle($skin_style_id[1]);
644 $this->message_stack->sendMessages();
645 $this->
ctrl->redirect($this);
648 protected function importStyle():
void 652 if ($form->checkInput() && $this->
upload->hasUploads()) {
654 $result = array_values($this->
upload->getResults())[0];
656 $this->
upload->moveOneFileTo(
663 $imported_container = $this->skin_factory->skinStyleContainerFromZip(
664 $this->config->getCustomizingSkinPath() . $result->getName(),
668 $this->
ctrl->setParameterByClass(
669 'ilSystemStyleSettingsGUI',
671 $imported_container->getSkin()->getId()
673 $this->
ctrl->setParameterByClass(
674 'ilSystemStyleSettingsGUI',
676 $imported_container->getSkin()->getDefaultStyle()->getId()
679 $this->
lng->txt(
'style_imported') .
' ' . $imported_container->getSkinDirectory(),
682 $this->message_stack->sendMessages();
683 $this->
ctrl->redirectByClass(
'ilSystemStyleSettingsGUI');
686 $form->setValuesByPost();
687 $this->tpl->setContent($form->getHTML());
697 $this->
lng->txt(
'zip_export_failed') .
' ' . $e->getMessage(),
708 $this->
tabs->clearTargets();
712 $this->
help->setScreenIdComponent(
'sty');
713 $this->
help->setScreenId(
'system_styles');
714 $this->
help->setSubScreenId(
'create_sub');
718 $this->tpl->setContent($form->getHTML());
724 $form->setFormAction($this->
ctrl->getFormAction($this));
725 $form->setTitle($this->
lng->txt(
'sty_create_new_system_sub_style'));
728 $ti->setInfo($this->
lng->txt(
'sub_style_id_description'));
729 $ti->setMaxLength(128);
731 $ti->setRequired(
true);
735 $ti->setInfo($this->
lng->txt(
'sub_style_name_description'));
736 $ti->setMaxLength(128);
738 $ti->setRequired(
true);
743 $ti->setRequired(
true);
744 $ti->setInfo($this->
lng->txt(
'sub_style_parent_style_description'));
747 foreach ($styles as
$id => $style) {
749 if ($style[
'skin_id'] != $system_style_conf->getDefaultSkinId() && !$style[
'substyle_of']) {
750 $options[
$id] = $style[
'title'];
753 $ti->setOptions($options);
756 $form->addCommandButton(
'saveNewSubStyle', $this->
lng->txt(
'save'));
757 $form->addCommandButton(
'cancel', $this->
lng->txt(
'cancel'));
766 if ($form->checkInput()) {
768 $skin_style_ids = $this->request_wrapper->post()->retrieve(
770 $this->
refinery->string()->splitString(
':')
773 $parent_skin_id = $skin_style_ids[0];
774 $parent_style_id = $skin_style_ids[1];
776 $container = $this->skin_factory->skinStyleContainerFromId($parent_skin_id, $this->message_stack);
778 $sub_style_id = $this->request_wrapper->post()->retrieve(
780 $this->
refinery->kindlyTo()->string()
783 if (array_key_exists(
785 $container->getSkin()->getSubstylesOfStyle($parent_style_id)
793 $sub_style_name = $this->request_wrapper->post()->retrieve(
795 $this->
refinery->kindlyTo()->string()
798 $style =
new ilSkinStyle($sub_style_id, $sub_style_name);
799 $style->setSubstyleOf($parent_style_id);
802 $this->
ctrl->setParameterByClass(
'ilSystemStyleSettingsGUI',
'skin_id', $parent_skin_id);
803 $this->
ctrl->setParameterByClass(
'ilSystemStyleSettingsGUI',
'style_id', $sub_style_id);
805 $this->message_stack->sendMessages();
806 $this->
ctrl->redirectByClass(
'ilSystemStyleSettingsGUI');
816 $form->setValuesByPost();
817 $this->tpl->setContent($form->getHTML());
An entity that renders components to a string output.
ilGlobalTemplateInterface $tpl
WrapperFactory $request_wrapper
const SUBSTYLE_ASSIGNMENT_EXISTS
static _lookupActivatedStyle(string $a_skin, string $a_style)
lookup if a style is activated
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static styleExists(string $style_id)
ilFileSystemHelper $file_system
static getCurrentDefaultSkin()
Gets default Skin of the System.
Factory to create Skin classes holds an manages the basic data of a skin as provide by the template o...
Class ChatMainBarProvider .
static _moveUsersToStyle(string $a_from_skin, string $a_from_style, string $a_to_skin, string $a_to_style)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
File System Helper, to reduce deps.
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
static _deactivateStyle(string $a_skin, string $a_style)
deactivate system style
setReadOnly(bool $read_only)
static _getNumberOfUsersForStyle(string $a_skin, string $a_style)
static _activateStyle(string $a_skin, string $a_style)
activate system style
This class is responsible for all file system related actions related actions of a skin such as copyi...
static getAllSkinStyles()
Get all skins/styles as array (convenient for tables) Attention: tempalte_name/template_id in this ar...
skinStyleContainerFromId(string $skin_id, ilSystemStyleMessageStack $message_stack)
Get container class is responsible for all file system related actions related actions of a skin such...
static setCurrentDefaultStyle(string $skin_id, string $style_id)
Sets the default style of the system.
checkStyleSettings(ilSystemStyleMessageStack $message_stack, array $active_styles)
ilSkinFactory $skin_factory
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
__construct(ilCtrl $ctrl, ilLanguage $lng, ilGlobalTemplateInterface $tpl, Factory $ui_factory, Renderer $renderer, WrapperFactory $request_wrapper, ilToolbarGUI $toolbar, Refinery $refinery, ilSkinFactory $skin_factory, FileUpload $upload, ilTabsGUI $tabs, ilHelpGUI $help, string $skin_id, string $style_id, string $ref_id, bool $read_only, bool $management_enabled)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static skinExists(string $skin_id, ?ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists.
ilSystemStyleMessageStack $message_stack
Used to stack messages to be shown to the user.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
ilSystemStyleConfig $config
TableGUI class for system styles.
ilSkinStyleContainer $style_container
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setManagementEnabled(bool $management_enabled)
static _getAllUserAssignedStyles()
checkDeletable(string $skin_id, string $style_id, ilSystemStyleMessageStack $message_stack)
ilSkin holds an manages the basic data of a skin as provide by the template of the skin...