ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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, 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  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
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 319 of file class.ilSystemStyleIconsGUI.php.

References $DIC, $form, $id, $input, PHPMailer\PHPMailer\$options, $si, $title, $type, ilSystemStyleIcon\getColorSet(), getIconFolder(), ilSubmitButton\getInstance(), ilSystemStyleIcon\getName(), ilUtil\sendFailure(), and ilFileInputGUI\setSuffixes().

Referenced by editIcon().

320  {
321  global $DIC;
322 
323  $toolbar = $DIC->toolbar();
324 
325  $si = new ilSelectInputGUI($this->lng->txt("select_icon"), "selected_icon");
326 
327  $options = array();
328  foreach ($this->getIconFolder()->getIcons() as $icon) {
329  if ($icon->getType() == "svg") {
330  $options[$icon->getName()] = $icon->getName();
331  }
332  }
333 
334  $si->setOptions($options);
335 
336  $si->setValue($icon_name);
337 
338  $toolbar->addInputItem($si, true);
339 
340  $select_btn = ilSubmitButton::getInstance();
341  $select_btn->setCaption($this->lng->txt("select"), false);
342  $toolbar->addButtonInstance($select_btn);
343  $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'editIcon'));
344  }
This class represents a selection list property in a property form.
global $DIC
Definition: saml.php:7
+ 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 $form, and getByColorValues().

Referenced by executeCommand().

134  {
135  $form = $this->initByColorForm();
136  $this->getByColorValues($form);
137  $this->tpl->setContent($form->getHTML());
138  }
if(isset($_POST['submit'])) $form
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, $form, addSelectIconToolbar(), getByIconValues(), 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()->getIconByName($icon_name);
310  $form = $this->initByIconForm($icon);
311  $this->getByIconValues($form, $icon);
312  $this->tpl->setContent($form->getHTML() . $this->renderIconPreview($icon));
313  }
314  }
$_GET["client_id"]
if(isset($_POST['submit'])) $form
getByIconValues(ilPropertyFormGUI $form, ilSystemStyleIcon $icon)
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.

References $form.

Referenced by executeCommand().

110  {
111  $form = $this->initByColorForm();
112  $this->tpl->setContent($form->getHTML());
113  }
if(isset($_POST['submit'])) $form
+ 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 $id, $values, 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  }
if(!array_key_exists('StateId', $_REQUEST)) $id
$values
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 403 of file class.ilSystemStyleIconsGUI.php.

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

Referenced by editIcon().

404  {
405  $values = [];
406 
407  $colors = $this->getIconFolder()->getColorSet()->getColors();
408  foreach ($icon-> getColorSet()->getColors() as $color) {
409  $id = $color->getId();
410  if ($colors[$color->getId()]) {
411  $values[$id] = $colors[$color->getId()]->getColor();
412  } else {
413  $values[$id] = $color->getColor();
414  }
415  }
416  $values["selected_icon"] = $icon->getName();
417 
418  $form->setValuesByArray($values);
419  }
if(!array_key_exists('StateId', $_REQUEST)) $id
$values
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:

◆ getIconFolder()

ilSystemStyleIconsGUI::getIconFolder ( )
Returns
ilSystemStyleIconFolder

Definition at line 570 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 554 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 $form, $id, $input, $section, $title, $type, ilSystemStyleIconColor\BLUE, getIconFolder(), ilSystemStyleIconColor\GREEN, ilSystemStyleIconColor\GREY, ilSystemStyleIconColor\RED, and ilUtil\sendFailure().

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 493 of file class.ilSystemStyleIconsGUI.php.

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

Referenced by editIcon().

494  {
495  global $DIC;
496 
497  $f = $DIC->ui()->factory();
498 
499  $icon_image = $f->image()->standard($icon->getPath(), $icon->getName());
500 
501  $card = $f->card()->standard(
502  $icon->getName(),
503  $icon_image
504  );
505 
506  $report = $f->panel()->standard($this->lng->txt("preview"), $f->deck([$card]));
507 
508  return $DIC->ui()->renderer()->render($report);
509  }
global $DIC
Definition: saml.php:7
+ 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, $style, 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  }
$style
Definition: example_012.php:70
$_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 578 of file class.ilSystemStyleIconsGUI.php.

References $icon_folder.

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

579  {
580  $this->icon_folder = $icon_folder;
581  }
+ Here is the caller graph for this function:

◆ setStyleContainer()

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

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

References $style_container.

Referenced by __construct().

563  {
564  $this->style_container = $style_container;
565  }
+ 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, $form, 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->getId()) {
277  $color_changes[$old_color->getId()] = $new_color;
278  $message_stack->addMessage(new ilSystemStyleMessage(
279  $this->lng->txt("color_changed_from") . " " . $old_color->getId() . " " .
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"]
if(isset($_POST['submit'])) $form
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: