ILIAS  release_8 Revision v8.24
class.ilSubStyleAssignmentGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use ILIAS\Refinery\Factory as Refinery;
23
25{
26 protected ilCtrl $ctrl;
27 protected ilLanguage $lng;
31 protected ilTree $tree;
33 protected Refinery $refinery;
34 protected \ILIAS\UI\Factory $ui_factory;
36
37 public function __construct(
45 Refinery $refinery,
46 \ILIAS\UI\Factory $ui_factory
47 ) {
48 $this->ctrl = $ctrl;
49 $this->lng = $lng;
50 $this->toolbar = $toolbar;
51 $this->tpl = $tpl;
52 $this->parent_gui = $parent_gui;
53 $this->tree = $tree;
54 $this->request_wrapper = $request_wrapper;
55 $this->refinery = $refinery;
56 $this->ui_factory = $ui_factory;
57 $this->message_stack = new ilSystemStyleMessageStack($this->tpl);
58 }
59
64 public function assignStyle(ilSkin $skin, ilSkinStyle $substyle): void
65 {
66 $style = $skin->getStyle($substyle->getSubstyleOf());
67
68 $this->toolbar->addComponent($this->ui_factory->button()->standard(
69 $this->lng->txt('sty_add_assignment'),
70 $this->ctrl->getLinkTarget($this->parent_gui, 'addAssignment')
71 ));
72
74 $this->getParentGui(),
75 'assignStyleToCat',
76 $skin->getId(),
77 $style->getId(),
78 $substyle->getId()
79 );
80
81 $this->tpl->setContent($tab->getHTML());
82 }
83
87 public function addAssignment(): void
88 {
89 include_once 'Services/Search/classes/class.ilSearchRootSelector.php';
90 $exp = new ilSearchRootSelector(
91 $this->ctrl->getLinkTarget($this->getParentGui(), 'addStyleCatAssignment')
92 );
93 $expand_id = $this->tree->readRootId();
94 if ($this->request_wrapper->query()->has('search_root_expand')) {
95 $expand_id = $this->request_wrapper->query()->retrieve(
96 'search_root_expand',
97 $this->refinery->kindlyTo()->string()
98 );
99 }
100 $exp->setExpand($expand_id);
101 $exp->setExpandTarget($this->ctrl->getLinkTarget($this->getParentGui(), 'addAssignment'));
102 $exp->setTargetClass(get_class($this->getParentGui()));
103 $exp->setCmd('saveAssignment');
104 $exp->setClickableTypes(['cat']);
105
106 $exp->setOutput(0);
107 $this->tpl->setContent($exp->getOutput());
108 }
109
113 public function saveAssignment(ilSkin $skin, ilSkinStyle $substyle): void
114 {
115 $style = $skin->getStyle($substyle->getSubstyleOf());
116 try {
117 $root_id = $this->request_wrapper->query()->retrieve(
118 'root_id',
119 $this->refinery->kindlyTo()->string()
120 );
122 $skin->getId(),
123 $style->getId(),
124 $substyle->getId(),
125 $root_id
126 );
127 $this->message_stack->addMessage(new ilSystemStyleMessage($this->lng->txt('msg_obj_modified')));
128 } catch (ilSystemStyleException $e) {
129 $message = $this->lng->txt('msg_assignment_failed') . $e->getMessage();
130 $this->message_stack->addMessage(new ilSystemStyleMessage($message, ilSystemStyleMessage::TYPE_ERROR));
131 }
132 $this->message_stack->sendMessages();
133 $this->ctrl->redirect($this->getParentGui(), 'assignStyle');
134 }
135
139 public function deleteAssignments(ilSkin $skin, ilSkinStyle $substyle): void
140 {
141 $style = $skin->getStyle($substyle->getSubstyleOf());
142
143 if ($this->request_wrapper->post()->has('id')) {
144 $ids = $this->request_wrapper->post()->retrieve('id', $this->refinery->identity());
145 foreach ($ids as $id) {
146 $id_arr = explode(':', $id);
148 $skin->getId(),
149 $style->getId(),
150 $substyle->getId(),
151 $id_arr[1]
152 );
153 }
154 $this->message_stack->addMessage(new ilSystemStyleMessage($this->lng->txt('msg_obj_modified')));
155 } else {
156 $this->message_stack->addMessage(new ilSystemStyleMessage(
157 $this->lng->txt('no_style_selected'),
159 ));
160 }
161 $this->message_stack->sendMessages();
162 $this->ctrl->redirect($this->getParentGui(), 'assignStyle');
163 }
164
166 {
167 return $this->parent_gui;
168 }
169
171 {
172 $this->parent_gui = $parent_gui;
173 }
174}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Builds data types.
Definition: Factory.php:21
Class ilCtrl provides processing control methods.
language handling
getSubstyleOf()
Returns the parent style of this style if set.
ilSkin holds an manages the basic data of a skin as provide by the template of the skin.
getStyle(string $id)
ilSystemStyleMessageStack $message_stack
setParentGui(ilSystemStyleSettingsGUI $parent_gui)
saveAssignment(ilSkin $skin, ilSkinStyle $substyle)
Save style category assignment.
addAssignment()
Add style category assignment.
deleteAssignments(ilSkin $skin, ilSkinStyle $substyle)
Delete system style to category assignments.
__construct(ilSystemStyleSettingsGUI $parent_gui, ilCtrl $ctrl, ilLanguage $lng, ilGlobalTemplateInterface $tpl, ilToolbarGUI $toolbar, ilTree $tree, WrapperFactory $request_wrapper, Refinery $refinery, \ILIAS\UI\Factory $ui_factory)
assignStyle(ilSkin $skin, ilSkinStyle $substyle)
Assign styles to categories.
ilSystemStyleSettingsGUI $parent_gui
TableGUI class for system style to category assignments.
Class for advanced editing exception handling in ILIAS.
Used to stack messages to be shown to the user.
static writeSystemStyleCategoryAssignment(string $a_skin_id, string $a_style_id, string $a_substyle, string $a_ref_id)
Sets a substyle category assignment.
static deleteSystemStyleCategoryAssignment(string $a_skin_id, string $a_style_id, string $a_substyle, string $a_ref_id)
Deletes all sub style category assignment of a system style.
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...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$message
Definition: xapiexit.php:32