ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSystemStyleIconsGUI Class Reference
+ Collaboration diagram for ilSystemStyleIconsGUI:

Public Member Functions

 __construct ($skin_id="", $style_id="")
 ilSystemStyleIconsGUI constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getByColorValues (ilPropertyFormGUI $form)
 
 reset ()
 
 update ()
 
 getByIconValues (ilPropertyFormGUI $form, ilSystemStyleIcon $icon)
 
 getStyleContainer ()
 
 setStyleContainer ($style_container)
 
 getIconFolder ()
 
 setIconFolder ($icon_folder)
 

Protected Member Functions

 fail ()
 
 setSubStyleSubTabs ($active="")
 
 edit ()
 
 preview ()
 
 editIcon ()
 
 addSelectIconToolbar ($icon_name)
 
 renderIconPreview (ilSystemStyleIcon $icon)
 

Protected Attributes

 $ctrl
 
 $lng
 
 $tpl
 
 $style_container
 
 $icon_folder = null
 
 $tabs
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleIconsGUI::__construct (   $skin_id = "",
  $style_id = "" 
)

ilSystemStyleIconsGUI constructor.

Parameters
string$skin_id
string$style_id

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

References $_GET, $DIC, Vendor\Package\$e, ilSystemStyleSkinContainer\generateFromId(), getStyleContainer(), ilUtil\sendFailure(), setIconFolder(), and setStyleContainer().

54  {
55  global $DIC;
56 
57  $this->ctrl = $DIC->ctrl();
58  $this->lng = $DIC->language();
59  $this->tpl = $DIC["tpl"];
60  $this->tabs = $DIC->tabs();
61 
62  if ($skin_id == "") {
63  $skin_id = $_GET["skin_id"];
64  }
65  if ($style_id == "") {
66  $style_id = $_GET["style_id"];
67  }
69  if ($this->ctrl->getCmd() != "reset") {
70  try {
71  $this->setIconFolder(new ilSystemStyleIconFolder($this->getStyleContainer()->getImagesSkinPath($style_id)));
72  } catch (ilSystemStyleExceptionBase $e) {
73  ilUtil::sendFailure($e->getMessage());
74  $this->ctrl->setCmd("fail");
75  }
76  }
77  }
$_GET["client_id"]
global $DIC
Definition: goto.php:24
static generateFromId($skin_id, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
Generate the container class by parsing the corresponding XML.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Abstracts a folder containing a set of icons.
Class for advanced editing exception handling in ILIAS.
+ Here is the call graph for this function:

Member Function Documentation

◆ addSelectIconToolbar()

ilSystemStyleIconsGUI::addSelectIconToolbar (   $icon_name)
protected
Parameters
$icon_name

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

References $DIC, $si, ilSystemStyleIcon\getColorSet(), getIconFolder(), ilSubmitButton\getInstance(), ilSystemStyleIcon\getName(), ilSystemStyleIcon\getPath(), ilFormPropertyGUI\setRequired(), and ilFileInputGUI\setSuffixes().

Referenced by editIcon().

319  {
320  global $DIC;
321 
322  $toolbar = $DIC->toolbar();
323 
324  $si = new ilSelectInputGUI($this->lng->txt("select_icon"), "selected_icon");
325 
326  $options = array();
327  $this->getIconFolder()->sortIconsByPath();
328  $substr_len = strlen($this->getIconFolder()->getPath()) + 1;
329  foreach ($this->getIconFolder()->getIcons() as $icon) {
330  if ($icon->getType() == "svg") {
331  $options[$icon->getPath()] = substr($icon->getPath(), $substr_len);
332  }
333  }
334 
335  $si->setOptions($options);
336 
337  $si->setValue($icon_name);
338 
339  $toolbar->addInputItem($si, true);
340 
341  $select_btn = ilSubmitButton::getInstance();
342  $select_btn->setCaption($this->lng->txt("select"), false);
343  $toolbar->addButtonInstance($select_btn);
344  $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'editIcon'));
345  }
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ edit()

ilSystemStyleIconsGUI::edit ( )
protected

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

References getByColorValues().

Referenced by executeCommand().

134  {
135  $form = $this->initByColorForm();
136  $this->getByColorValues($form);
137  $this->tpl->setContent($form->getHTML());
138  }
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 302 of file class.ilSystemStyleIconsGUI.php.

References $_GET, $_POST, addSelectIconToolbar(), getIconFolder(), and renderIconPreview().

Referenced by executeCommand().

303  {
304  $icon_name = $_POST['selected_icon']?$_POST['selected_icon']:$_GET['selected_icon'];
305 
306  $this->addSelectIconToolbar($icon_name);
307 
308  if ($icon_name) {
309  $icon = $this->getIconFolder()->getIconByPath($icon_name);
310  $form = $this->initByIconForm($icon);
311  $this->tpl->setContent($form->getHTML() . $this->renderIconPreview($icon));
312  }
313  }
$_GET["client_id"]
renderIconPreview(ilSystemStyleIcon $icon)
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilSystemStyleIconsGUI::executeCommand ( )

Execute command.

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

References edit(), editIcon(), fail(), and setSubStyleSubTabs().

83  {
84  $cmd = $this->ctrl->getCmd();
85  $this->setSubStyleSubTabs($cmd);
86 
87  switch ($cmd) {
88  case "fail":
89  $this->fail();
90  break;
91  case "cancelIcon":
92  $this->editIcon();
93  break;
94  case "save":
95  case "edit":
96  case "editIcon":
97  case "update":
98  case "reset":
99  case "preview":
100  case "updateIcon":
101  $this->$cmd();
102  break;
103  default:
104  $this->edit();
105  break;
106  }
107  }
+ Here is the call graph for this function:

◆ fail()

ilSystemStyleIconsGUI::fail ( )
protected

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

Referenced by executeCommand().

110  {
111  $form = $this->initByColorForm();
112  $this->tpl->setContent($form->getHTML());
113  }
+ Here is the caller graph for this function:

◆ getByColorValues()

ilSystemStyleIconsGUI::getByColorValues ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

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

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

Referenced by edit().

228  {
229  $values = [];
230 
231  if ($this->getIconFolder()) {
232  $colors = $this->getIconFolder()->getColorSet()->getColors();
233  foreach ($colors as $color) {
234  $id = $color->getId();
235  if ($colors[$color->getId()]) {
236  $values[$id] = $colors[$color->getId()]->getColor();
237  } else {
238  $values[$id] = $color->getColor();
239  }
240  }
241  }
242 
243 
244  $form->setValuesByArray($values);
245  }
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getByIconValues()

ilSystemStyleIconsGUI::getByIconValues ( ilPropertyFormGUI  $form,
ilSystemStyleIcon  $icon 
)
Parameters
ilPropertyFormGUI$form
ilSystemStyleIcon$icon

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

References $_POST, $DIC, $message, $type, ilSystemStyleIcon\changeColors(), ilSystemStyleIcon\getColorSet(), getIconFolder(), ilSystemStyleIcon\getPath(), getStyleContainer(), ilPropertyFormGUI\setValuesByArray(), ilSystemStyleMessage\TYPE_ERROR, and ilSystemStyleMessage\TYPE_SUCCESS.

397  {
398  $values = [];
399 
400  foreach ($this->getIconFolder()->getColorSet()->getColors() as $color) {
401  $values[$color->getId()] = $color->getColor();
402  }
403  $values["selected_icon"] = $icon->getPath();
404 
405  $form->setValuesByArray($values);
406  }
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
+ Here is the call graph for this function:

◆ getIconFolder()

ilSystemStyleIconsGUI::getIconFolder ( )
Returns
ilSystemStyleIconFolder

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

References $icon_folder.

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

+ Here is the caller graph for this function:

◆ getStyleContainer()

ilSystemStyleIconsGUI::getStyleContainer ( )
Returns
ilSystemStyleSkinContainer

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

References $style_container.

Referenced by __construct(), getByIconValues(), reset(), and update().

+ Here is the caller graph for this function:

◆ preview()

ilSystemStyleIconsGUI::preview ( )
protected

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

References Vendor\Package\$e, $section, $type, ilSystemStyleIconColor\BLUE, getIconFolder(), ilSystemStyleIconColor\GREEN, ilSystemStyleIconColor\GREY, ilSystemStyleIconColor\RED, ilUtil\sendFailure(), and ilFormPropertyGUI\setRequired().

141  {
142  $this->tpl->setContent($this->renderIconsPreviews());
143  }
+ Here is the call graph for this function:

◆ renderIconPreview()

ilSystemStyleIconsGUI::renderIconPreview ( ilSystemStyleIcon  $icon)
protected
Parameters
ilSystemStyleIcon$icon
Returns
string

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

References $DIC, Vendor\Package\$f, getIconFolder(), ilSystemStyleIcon\getName(), and ilSystemStyleIcon\getPath().

Referenced by editIcon().

481  {
482  global $DIC;
483 
484  $f = $DIC->ui()->factory();
485 
486  $icon_image = $f->image()->standard($icon->getPath(), $icon->getName());
487 
488  $card = $f->card()->standard(
489  $icon->getName(),
490  $icon_image
491  );
492 
493  $report = $f->panel()->standard($this->lng->txt("preview"), $f->deck([$card]));
494 
495  return $DIC->ui()->renderer()->render($report);
496  }
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

ilSystemStyleIconsGUI::reset ( )

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

References $_GET, getStyleContainer(), setIconFolder(), and ilSystemStyleMessage\TYPE_SUCCESS.

248  {
249  $style = $this->getStyleContainer()->getSkin()->getStyle($_GET["style_id"]);
250  $this->getStyleContainer()->resetImages($style);
251  $this->setIconFolder(new ilSystemStyleIconFolder($this->getStyleContainer()->getImagesSkinPath($style->getId())));
252  $message_stack = new ilSystemStyleMessageStack();
253  $message_stack->addMessage(new ilSystemStyleMessage(
254  $this->lng->txt("color_reset"),
256  ));
257  $message_stack->sendMessages(true);
258 
259  $this->ctrl->redirect($this, "edit");
260  }
$_GET["client_id"]
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 (   $icon_folder)
Parameters
ilSystemStyleIconFolder$icon_folder

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

References $icon_folder.

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

566  {
567  $this->icon_folder = $icon_folder;
568  }
+ Here is the caller graph for this function:

◆ setStyleContainer()

ilSystemStyleIconsGUI::setStyleContainer (   $style_container)
Parameters
ilSystemStyleSkinContainer$style_container

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

References $style_container.

Referenced by __construct().

550  {
551  $this->style_container = $style_container;
552  }
+ Here is the caller graph for this function:

◆ setSubStyleSubTabs()

ilSystemStyleIconsGUI::setSubStyleSubTabs (   $active = "")
protected
Parameters
string$active

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

Referenced by executeCommand().

119  {
120  $this->tabs->addSubTab('edit', $this->lng->txt('edit_by_color'), $this->ctrl->getLinkTarget($this, 'edit'));
121  $this->tabs->addSubTab('editIcon', $this->lng->txt('edit_by_icon'), $this->ctrl->getLinkTarget($this, 'editIcon'));
122  $this->tabs->addSubTab('preview', $this->lng->txt('icons_gallery'), $this->ctrl->getLinkTarget($this, "preview"));
123 
124  if ($active == "preview") {
125  $this->tabs->activateSubTab($active);
126  } elseif ($active == "cancelIcon" || $active == "editIcon") {
127  $this->tabs->activateSubTab("editIcon");
128  } else {
129  $this->tabs->activateSubTab("edit");
130  }
131  }
+ Here is the caller graph for this function:

◆ update()

ilSystemStyleIconsGUI::update ( )

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

References $_GET, getIconFolder(), getStyleContainer(), setIconFolder(), ilSystemStyleMessage\TYPE_ERROR, and ilSystemStyleMessage\TYPE_SUCCESS.

263  {
264  $form = $this->initByColorForm();
265  if ($form->checkInput()) {
266  $message_stack = new ilSystemStyleMessageStack();
267 
268  $color_changes = [];
269  foreach ($this->getIconFolder()->getColorSet()->getColors() as $old_color) {
270  $new_color = $form->getInput($old_color->getId());
271  if (!preg_match("/[\dabcdef]{6}/i", $new_color)) {
272  $message_stack->addMessage(new ilSystemStyleMessage(
273  $this->lng->txt("invalid_color") . $new_color,
275  ));
276  } elseif ($new_color != $old_color->getColor()) {
277  $color_changes[$old_color->getColor()] = $new_color;
278  $message_stack->addMessage(new ilSystemStyleMessage(
279  $this->lng->txt("color_changed_from") . " " . $old_color->getColor() . " " .
280  $this->lng->txt("color_changed_to") . " " . $new_color,
282  ));
283  }
284  }
285  $this->getIconFolder()->changeIconColors($color_changes);
286  $this->setIconFolder(new ilSystemStyleIconFolder($this->getStyleContainer()->getImagesSkinPath($_GET["style_id"])));
287  $skin = $this->getStyleContainer()->getSkin();
288  $skin->getVersionStep($skin->getVersion());
289  $this->getStyleContainer()->updateSkin($skin);
290  $message_stack->addMessage(new ilSystemStyleMessage(
291  $this->lng->txt("color_update"),
293  ));
294  $message_stack->sendMessages(true);
295  $this->ctrl->redirect($this, "edit");
296  }
297  $form->setValuesByPost();
298  $this->tpl->setContent($form->getHTML());
299  }
$_GET["client_id"]
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

ilSystemStyleIconsGUI::$ctrl
protected

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

◆ $icon_folder

ilSystemStyleIconsGUI::$icon_folder = null
protected

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

Referenced by getIconFolder(), and setIconFolder().

◆ $lng

ilSystemStyleIconsGUI::$lng
protected

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

◆ $style_container

ilSystemStyleIconsGUI::$style_container
protected

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

Referenced by getStyleContainer(), and setStyleContainer().

◆ $tabs

ilSystemStyleIconsGUI::$tabs
protected

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

◆ $tpl

ilSystemStyleIconsGUI::$tpl
protected

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


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