ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilSubStyleAssignmentGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
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(
38  ilSystemStyleConfigGUI $parent_gui,
39  ilCtrl $ctrl,
40  ilLanguage $lng,
42  ilToolbarGUI $toolbar,
43  ilTree $tree,
44  WrapperFactory $request_wrapper,
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  $exp = new ilSearchRootSelector(
90  $this->ctrl->getLinkTarget($this->getParentGui(), 'addStyleCatAssignment')
91  );
92  $expand_id = $this->tree->readRootId();
93  if ($this->request_wrapper->query()->has('search_root_expand')) {
94  $expand_id = $this->request_wrapper->query()->retrieve(
95  'search_root_expand',
96  $this->refinery->kindlyTo()->string()
97  );
98  }
99  $exp->setExpand($expand_id);
100  $exp->setExpandTarget($this->ctrl->getLinkTarget($this->getParentGui(), 'addAssignment'));
101  $exp->setTargetClass(get_class($this->getParentGui()));
102  $exp->setCmd('saveAssignment');
103  $exp->setClickableTypes(['cat']);
104 
105  $exp->setOutput(0);
106  $this->tpl->setContent($exp->getOutput());
107  }
108 
112  public function saveAssignment(ilSkin $skin, ilSkinStyle $substyle): void
113  {
114  $style = $skin->getStyle($substyle->getSubstyleOf());
115  try {
116  $root_id = $this->request_wrapper->query()->retrieve(
117  'root_id',
118  $this->refinery->kindlyTo()->string()
119  );
121  $skin->getId(),
122  $style->getId(),
123  $substyle->getId(),
124  $root_id
125  );
126  $this->message_stack->addMessage(new ilSystemStyleMessage($this->lng->txt('msg_obj_modified')));
127  } catch (ilSystemStyleException $e) {
128  $message = $this->lng->txt('msg_assignment_failed') . $e->getMessage();
129  $this->message_stack->addMessage(new ilSystemStyleMessage($message, ilSystemStyleMessage::TYPE_ERROR));
130  }
131  $this->message_stack->sendMessages();
132  $this->ctrl->redirect($this->getParentGui(), 'assignStyle');
133  }
134 
138  public function deleteAssignments(ilSkin $skin, ilSkinStyle $substyle): void
139  {
140  $style = $skin->getStyle($substyle->getSubstyleOf());
141 
142  if ($this->request_wrapper->post()->has('id')) {
143  $ids = $this->request_wrapper->post()->retrieve('id', $this->refinery->identity());
144  foreach ($ids as $id) {
145  $id_arr = explode(':', $id);
147  $skin->getId(),
148  $style->getId(),
149  $substyle->getId(),
150  $id_arr[1]
151  );
152  }
153  $this->message_stack->addMessage(new ilSystemStyleMessage($this->lng->txt('msg_obj_modified')));
154  } else {
155  $this->message_stack->addMessage(new ilSystemStyleMessage(
156  $this->lng->txt('no_style_selected'),
158  ));
159  }
160  $this->message_stack->sendMessages();
161  $this->ctrl->redirect($this->getParentGui(), 'assignStyle');
162  }
163 
165  {
166  return $this->parent_gui;
167  }
168 
169  public function setParentGui(ilSystemStyleConfigGUI $parent_gui): void
170  {
171  $this->parent_gui = $parent_gui;
172  }
173 }
assignStyle(ilSkin $skin, ilSkinStyle $substyle)
Assign styles to categories.
static writeSystemStyleCategoryAssignment(string $a_skin_id, string $a_style_id, string $a_substyle, string $a_ref_id)
Sets a substyle category assignment.
setParentGui(ilSystemStyleConfigGUI $parent_gui)
getStyle(string $id)
Interface Observer Contains several chained tasks and infos about them.
saveAssignment(ilSkin $skin, ilSkinStyle $substyle)
Save style category assignment.
__construct(ilSystemStyleConfigGUI $parent_gui, ilCtrl $ctrl, ilLanguage $lng, ilGlobalTemplateInterface $tpl, ilToolbarGUI $toolbar, ilTree $tree, WrapperFactory $request_wrapper, Refinery $refinery, \ILIAS\UI\Factory $ui_factory)
ilSystemStyleMessageStack $message_stack
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.
TableGUI class for system style to category assignments.
addAssignment()
Add style category assignment.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Used to stack messages to be shown to the user.
$message
Definition: xapiexit.php:31
deleteAssignments(ilSkin $skin, ilSkinStyle $substyle)
Delete system style to category assignments.
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...