ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSystemStyleIconsGUI Class Reference

ilSystemStyleIconsGUI: More...

+ Collaboration diagram for ilSystemStyleIconsGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, ilLanguage $lng, ilGlobalTemplateInterface $tpl, Factory $ui_factory, Renderer $renderer, WrapperFactory $request_wrapper, ilToolbarGUI $toolbar, Refinery $refinery, ilSkinFactory $skin_factory, ilTabsGUI $tabs, FileUpload $upload, string $skin_id, string $style_id)
 
 executeCommand ()
 

Protected Member Functions

 fail ()
 
 setSubStyleSubTabs (string $active='')
 
 edit ()
 
 preview ()
 
 getByColorValues (ilPropertyFormGUI $form)
 
 reset ()
 
 update ()
 
 editIcon ()
 
 addSelectIconToolbar (?string $icon_name='')
 
 renderIconPreview (ilSystemStyleIcon $icon)
 
 getStyleContainer ()
 
 setStyleContainer (ilSkinStyleContainer $style_container)
 
 getIconFolder ()
 
 setIconFolder (ilSystemStyleIconFolder $icon_folder)
 

Protected Attributes

ilCtrl $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilSkinStyleContainer $style_container
 
ilSkinFactory $skin_factory
 
ilSystemStyleMessageStack $message_stack
 
Factory $ui_factory
 
Renderer $renderer
 
WrapperFactory $request_wrapper
 
ilToolbarGUI $toolbar
 
Refinery $refinery
 
ilTabsGUI $tabs
 
ilSystemStyleIconFolder $icon_folder
 
FileUpload $upload
 
string $style_id
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleIconsGUI::__construct ( ilCtrl  $ctrl,
ilLanguage  $lng,
ilGlobalTemplateInterface  $tpl,
Factory  $ui_factory,
Renderer  $renderer,
WrapperFactory  $request_wrapper,
ilToolbarGUI  $toolbar,
Refinery  $refinery,
ilSkinFactory  $skin_factory,
ilTabsGUI  $tabs,
FileUpload  $upload,
string  $skin_id,
string  $style_id 
)

Definition at line 49 of file class.ilSystemStyleIconsGUI.php.

References $ctrl, $lng, $refinery, $renderer, $request_wrapper, $skin_factory, $style_id, $tabs, $toolbar, $tpl, $ui_factory, $upload, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), setStyleContainer(), ilSkinFactory\skinStyleContainerFromId(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\upload().

63  {
64  $this->ctrl = $ctrl;
65  $this->lng = $lng;
66  $this->tpl = $tpl;
67  $this->ui_factory = $ui_factory;
68  $this->renderer = $renderer;
69  $this->request_wrapper = $request_wrapper;
70  $this->toolbar = $toolbar;
71  $this->refinery = $refinery;
72  $this->tabs = $tabs;
73  $this->upload = $upload;
74  $this->style_id = $style_id;
75  $this->message_stack = new ilSystemStyleMessageStack($this->tpl);
76  $this->skin_factory = $skin_factory;
77  $this->style_container = $this->skin_factory->skinStyleContainerFromId($skin_id, $this->message_stack);
78 
79  $this->setStyleContainer($this->skin_factory->skinStyleContainerFromId($skin_id, $this->message_stack));
80  }
setStyleContainer(ilSkinStyleContainer $style_container)
skinStyleContainerFromId(string $skin_id, ilSystemStyleMessageStack $message_stack)
Get container class is responsible for all file system related actions related actions of a skin such...
ilGlobalTemplateInterface $tpl
Used to stack messages to be shown to the user.
+ Here is the call graph for this function:

Member Function Documentation

◆ addSelectIconToolbar()

ilSystemStyleIconsGUI::addSelectIconToolbar ( ?string  $icon_name = '')
protected

Definition at line 332 of file class.ilSystemStyleIconsGUI.php.

References $id, $message, $type, ilSystemStyleMessageStack\addMessage(), ilSystemStyleIcon\changeColors(), ILIAS\Repository\ctrl(), ilSystemStyleIcon\getColorSet(), getIconFolder(), ilSystemStyleMessageStack\getJoinedMessages(), ilSystemStyleIcon\getName(), ilSystemStyleIcon\getPath(), getStyleContainer(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ilSystemStyleMessageStack\sendMessages(), ilSelectInputGUI\setOptions(), ilFormPropertyGUI\setRequired(), ILIAS\Repository\toolbar(), ilSystemStyleMessage\TYPE_ERROR, ilSystemStyleMessage\TYPE_SUCCESS, and ILIAS\Repository\upload().

Referenced by editIcon().

332  : void
333  {
334  $si = new ilSelectInputGUI($this->lng->txt('select_icon'), 'selected_icon');
335 
336  $options = [];
337  $this->getIconFolder()->sortIconsByPath();
338  $substr_len = strlen($this->getIconFolder()->getPath()) + 1;
339  foreach ($this->getIconFolder()->getIcons() as $icon) {
340  if ($icon->getType() == 'svg') {
341  $options[$icon->getPath()] = substr($icon->getPath(), $substr_len);
342  }
343  }
344 
345  $si->setOptions($options);
346 
347  $si->setValue($icon_name);
348 
349  $this->toolbar->addInputItem($si, true);
350 
351  $this->toolbar->addComponent($this->ui_factory->button()->standard(
352  $this->lng->txt('select'),
353  ''
354  ));
355  $this->toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'editIcon'));
356  }
setOptions(array $a_options)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ edit()

ilSystemStyleIconsGUI::edit ( )
protected

Definition at line 151 of file class.ilSystemStyleIconsGUI.php.

References getByColorValues().

Referenced by executeCommand().

151  : void
152  {
153  $form = $this->initByColorForm();
154  $this->getByColorValues($form);
155  $this->tpl->setContent($form->getHTML());
156  }
getByColorValues(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editIcon()

ilSystemStyleIconsGUI::editIcon ( )
protected

Definition at line 308 of file class.ilSystemStyleIconsGUI.php.

References addSelectIconToolbar(), getIconFolder(), ILIAS\Repository\refinery(), and renderIconPreview().

Referenced by executeCommand().

308  : void
309  {
310  $icon_name = '';
311  if ($this->request_wrapper->post()->has('selected_icon')) {
312  $icon_name = $this->request_wrapper->post()->retrieve(
313  'selected_icon',
314  $this->refinery->kindlyTo()->string()
315  );
316  } elseif ($this->request_wrapper->query()->has('selected_icon')) {
317  $icon_name = $this->request_wrapper->query()->retrieve(
318  'selected_icon',
319  $this->refinery->kindlyTo()->string()
320  );
321  }
322 
323  $this->addSelectIconToolbar($icon_name);
324 
325  if ($icon_name) {
326  $icon = $this->getIconFolder()->getIconByPath($icon_name);
327  $form = $this->initByIconForm($icon);
328  $this->tpl->setContent($form->getHTML() . $this->renderIconPreview($icon));
329  }
330  }
addSelectIconToolbar(?string $icon_name='')
renderIconPreview(ilSystemStyleIcon $icon)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilSystemStyleIconsGUI::executeCommand ( )

Definition at line 82 of file class.ilSystemStyleIconsGUI.php.

References Vendor\Package\$e, ILIAS\Repository\ctrl(), edit(), editIcon(), fail(), getStyleContainer(), setIconFolder(), setSubStyleSubTabs(), and ilSystemStyleMessage\TYPE_ERROR.

82  : void
83  {
84  $cmd = $this->ctrl->getCmd();
85  $this->setSubStyleSubTabs($cmd);
86 
87  if ($this->ctrl->getCmd() != 'reset') {
88  try {
89  $this->setIconFolder(new ilSystemStyleIconFolder($this->getStyleContainer()->getImagesSkinPath($this->style_id)));
90  } catch (ilSystemStyleExceptionBase $e) {
91  $this->message_stack->addMessage(new ilSystemStyleMessage(
92  $e->getMessage(),
94  ));
95  $cmd = 'fail';
96  }
97  }
98 
99  switch ($cmd) {
100  case 'fail':
101  $this->fail();
102  break;
103  case 'cancelIcon':
104  $this->editIcon();
105  break;
106  case 'save':
107  case 'edit':
108  case 'editIcon':
109  case 'update':
110  case 'reset':
111  case 'preview':
112  case 'updateIcon':
113  $this->$cmd();
114  break;
115  default:
116  $this->edit();
117  break;
118  }
119  $this->message_stack->sendMessages();
120  }
setIconFolder(ilSystemStyleIconFolder $icon_folder)
Abstracts a folder containing a set of icons.
Class for advanced editing exception handling in ILIAS.
+ Here is the call graph for this function:

◆ fail()

ilSystemStyleIconsGUI::fail ( )
protected

Definition at line 122 of file class.ilSystemStyleIconsGUI.php.

Referenced by executeCommand().

122  : void
123  {
124  $form = $this->initByColorForm();
125  $this->tpl->setContent($form->getHTML());
126  }
+ Here is the caller graph for this function:

◆ getByColorValues()

ilSystemStyleIconsGUI::getByColorValues ( ilPropertyFormGUI  $form)
protected

Definition at line 237 of file class.ilSystemStyleIconsGUI.php.

References $id, getIconFolder(), and ilPropertyFormGUI\setValuesByArray().

Referenced by edit().

237  : void
238  {
239  $values = [];
240 
241  $colors = $this->getIconFolder()->getColorSet()->getColors();
242  foreach ($colors as $color) {
243  $id = $color->getId();
244  if (array_key_exists($color->getId(), $colors)) {
245  $values[$id] = $colors[$color->getId()]->getColor();
246  } else {
247  $values[$id] = $color->getColor();
248  }
249  }
250 
251  $form->setValuesByArray($values);
252  }
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIconFolder()

ilSystemStyleIconsGUI::getIconFolder ( )
protected

Definition at line 518 of file class.ilSystemStyleIconsGUI.php.

References $icon_folder.

Referenced by addSelectIconToolbar(), editIcon(), getByColorValues(), preview(), renderIconPreview(), and update().

519  {
520  return $this->icon_folder;
521  }
ilSystemStyleIconFolder $icon_folder
Abstracts a folder containing a set of icons.
+ Here is the caller graph for this function:

◆ getStyleContainer()

ilSystemStyleIconsGUI::getStyleContainer ( )
protected

Definition at line 508 of file class.ilSystemStyleIconsGUI.php.

References $style_container.

Referenced by addSelectIconToolbar(), executeCommand(), reset(), and update().

509  {
510  return $this->style_container;
511  }
This class is responsible for all file system related actions related actions of a skin such as copyi...
ilSkinStyleContainer $style_container
+ Here is the caller graph for this function:

◆ preview()

ilSystemStyleIconsGUI::preview ( )
protected

Definition at line 158 of file class.ilSystemStyleIconsGUI.php.

References Vendor\Package\$e, $id, $type, ilSystemStyleIconColor\BLUE, ILIAS\Repository\ctrl(), getIconFolder(), ilSystemStyleIconColor\GREEN, ilSystemStyleIconColor\GREY, ILIAS\Repository\lng(), ilSystemStyleIconColor\RED, ilFormPropertyGUI\setRequired(), and ilSystemStyleMessage\TYPE_ERROR.

158  : void
159  {
160  $this->tpl->setContent($this->renderer->render($this->getIconsPreviews()));
161  }
+ Here is the call graph for this function:

◆ renderIconPreview()

ilSystemStyleIconsGUI::renderIconPreview ( ilSystemStyleIcon  $icon)
protected

Definition at line 465 of file class.ilSystemStyleIconsGUI.php.

References getIconFolder(), ilSystemStyleIcon\getName(), ilSystemStyleIcon\getPath(), and ILIAS\Repository\lng().

Referenced by editIcon().

465  : string
466  {
467  $icon_image = $this->ui_factory->image()->standard($icon->getPath(), $icon->getName());
468 
469  $card = $this->ui_factory->card()->standard(
470  $icon->getName(),
471  $icon_image
472  );
473 
474  $report = $this->ui_factory->panel()->standard($this->lng->txt('preview'), $this->ui_factory->deck([$card]));
475 
476  return $this->renderer->render($report);
477  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

ilSystemStyleIconsGUI::reset ( )
protected

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

References ILIAS\Repository\ctrl(), getStyleContainer(), ILIAS\Repository\lng(), setIconFolder(), and ilSystemStyleMessage\TYPE_SUCCESS.

254  : void
255  {
256  $style = $this->getStyleContainer()->getSkin()->getStyle($this->style_id);
257  $this->getStyleContainer()->resetImages($style);
258  $this->setIconFolder(new ilSystemStyleIconFolder($this->getStyleContainer()->getImagesSkinPath($style->getId())));
259  $message_stack = new ilSystemStyleMessageStack($this->tpl);
260  $message_stack->addMessage(new ilSystemStyleMessage(
261  $this->lng->txt('color_reset'),
263  ));
264  $message_stack->sendMessages();
265 
266  $this->ctrl->redirect($this, 'edit');
267  }
ilSystemStyleMessageStack $message_stack
setIconFolder(ilSystemStyleIconFolder $icon_folder)
Abstracts a folder containing a set of icons.
Used to stack messages to be shown to the user.
+ Here is the call graph for this function:

◆ setIconFolder()

ilSystemStyleIconsGUI::setIconFolder ( ilSystemStyleIconFolder  $icon_folder)
protected

Definition at line 523 of file class.ilSystemStyleIconsGUI.php.

References $icon_folder.

Referenced by executeCommand(), reset(), and update().

523  : void
524  {
525  $this->icon_folder = $icon_folder;
526  }
ilSystemStyleIconFolder $icon_folder
+ Here is the caller graph for this function:

◆ setStyleContainer()

ilSystemStyleIconsGUI::setStyleContainer ( ilSkinStyleContainer  $style_container)
protected

Definition at line 513 of file class.ilSystemStyleIconsGUI.php.

References $style_container.

Referenced by __construct().

513  : void
514  {
515  $this->style_container = $style_container;
516  }
ilSkinStyleContainer $style_container
+ Here is the caller graph for this function:

◆ setSubStyleSubTabs()

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

Definition at line 128 of file class.ilSystemStyleIconsGUI.php.

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

Referenced by executeCommand().

128  : void
129  {
130  $this->tabs->addSubTab('edit', $this->lng->txt('edit_by_color'), $this->ctrl->getLinkTarget($this, 'edit'));
131  $this->tabs->addSubTab(
132  'editIcon',
133  $this->lng->txt('edit_by_icon'),
134  $this->ctrl->getLinkTarget($this, 'editIcon')
135  );
136  $this->tabs->addSubTab(
137  'preview',
138  $this->lng->txt('icons_gallery'),
139  $this->ctrl->getLinkTarget($this, 'preview')
140  );
141 
142  if ($active == 'preview') {
143  $this->tabs->activateSubTab($active);
144  } elseif ($active == 'cancelIcon' || $active == 'editIcon') {
145  $this->tabs->activateSubTab('editIcon');
146  } else {
147  $this->tabs->activateSubTab('edit');
148  }
149  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilSystemStyleIconsGUI::update ( )
protected

Definition at line 269 of file class.ilSystemStyleIconsGUI.php.

References ilSystemStyleMessageStack\addMessage(), ILIAS\Repository\ctrl(), getIconFolder(), getStyleContainer(), ILIAS\Repository\lng(), ilSystemStyleMessageStack\sendMessages(), setIconFolder(), ilSystemStyleMessage\TYPE_ERROR, and ilSystemStyleMessage\TYPE_SUCCESS.

269  : void
270  {
271  $form = $this->initByColorForm();
272  if ($form->checkInput()) {
273  $message_stack = new ilSystemStyleMessageStack($this->tpl);
274 
275  $color_changes = [];
276  foreach ($this->getIconFolder()->getColorSet()->getColors() as $old_color) {
277  $new_color = $form->getInput($old_color->getId());
278  if (!preg_match('/[\dabcdef]{6}/i', $new_color)) {
280  $this->lng->txt('invalid_color') . $new_color,
282  ));
283  } elseif ($new_color != $old_color->getColor()) {
284  $color_changes[$old_color->getColor()] = $new_color;
286  $this->lng->txt('color_changed_from') . ' ' . $old_color->getColor() . ' ' .
287  $this->lng->txt('color_changed_to') . ' ' . $new_color,
289  ));
290  }
291  }
292  $this->getIconFolder()->changeIconColors($color_changes);
293  $this->setIconFolder(new ilSystemStyleIconFolder($this->getStyleContainer()->getImagesSkinPath($this->style_id)));
294  $skin = $this->getStyleContainer()->getSkin();
295  $skin->getVersionStep($skin->getVersion());
296  $this->getStyleContainer()->updateSkin($skin);
298  $this->lng->txt('color_update'),
300  ));
302  $this->ctrl->redirect($this, 'edit');
303  }
304  $form->setValuesByPost();
305  $this->tpl->setContent($form->getHTML());
306  }
ilSystemStyleMessageStack $message_stack
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
setIconFolder(ilSystemStyleIconFolder $icon_folder)
sendMessages(bool $keep=true)
Send messages via ilUtil to be displayed, still needed for messagees, that need to survive a redirect...
Abstracts a folder containing a set of icons.
Used to stack messages to be shown to the user.
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilSystemStyleIconsGUI::$ctrl
protected

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

Referenced by __construct().

◆ $icon_folder

ilSystemStyleIconFolder ilSystemStyleIconsGUI::$icon_folder
protected

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

Referenced by getIconFolder(), and setIconFolder().

◆ $lng

ilLanguage ilSystemStyleIconsGUI::$lng
protected

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

Referenced by __construct().

◆ $message_stack

ilSystemStyleMessageStack ilSystemStyleIconsGUI::$message_stack
protected

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

◆ $refinery

Refinery ilSystemStyleIconsGUI::$refinery
protected

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

Referenced by __construct().

◆ $renderer

Renderer ilSystemStyleIconsGUI::$renderer
protected

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

Referenced by __construct().

◆ $request_wrapper

WrapperFactory ilSystemStyleIconsGUI::$request_wrapper
protected

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

Referenced by __construct().

◆ $skin_factory

ilSkinFactory ilSystemStyleIconsGUI::$skin_factory
protected

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

Referenced by __construct().

◆ $style_container

ilSkinStyleContainer ilSystemStyleIconsGUI::$style_container
protected

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

Referenced by getStyleContainer(), and setStyleContainer().

◆ $style_id

string ilSystemStyleIconsGUI::$style_id
protected

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

Referenced by __construct().

◆ $tabs

ilTabsGUI ilSystemStyleIconsGUI::$tabs
protected

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

Referenced by __construct().

◆ $toolbar

ilToolbarGUI ilSystemStyleIconsGUI::$toolbar
protected

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

Referenced by __construct().

◆ $tpl

ilGlobalTemplateInterface ilSystemStyleIconsGUI::$tpl
protected

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

Referenced by __construct().

◆ $ui_factory

Factory ilSystemStyleIconsGUI::$ui_factory
protected

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

Referenced by __construct().

◆ $upload

FileUpload ilSystemStyleIconsGUI::$upload
protected

Definition at line 46 of file class.ilSystemStyleIconsGUI.php.

Referenced by __construct().


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