ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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)
 
 updateIcon ()
 
 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 51 of file class.ilSystemStyleIconsGUI.php.

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

52  {
53  global $DIC;
54 
55  $this->ctrl = $DIC->ctrl();
56  $this->lng = $DIC->language();
57  $this->tpl = $DIC["tpl"];
58  $this->tabs = $DIC->tabs();
59 
60  if($skin_id == ""){
61  $skin_id = $_GET["skin_id"];
62  }
63  if($style_id == ""){
64  $style_id = $_GET["style_id"];
65  }
67  if($this->ctrl->getCmd() != "reset"){
68  try{
69  $this->setIconFolder(new ilSystemStyleIconFolder($this->getStyleContainer()->getImagesSkinPath($style_id)));
70  }catch(ilSystemStyleExceptionBase $e){
71  ilUtil::sendFailure($e->getMessage());
72  $this->ctrl->setCmd("fail");
73  }
74  }
75 
76  }
$_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.
global $DIC
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 308 of file class.ilSystemStyleIconsGUI.php.

References $DIC, $options, $si, $title, array, ilSystemStyleIcon\getColorSet(), getIconFolder(), ilSubmitButton\getInstance(), ilSystemStyleIcon\getName(), ilUtil\sendFailure(), ilFormPropertyGUI\setRequired(), and ilFileInputGUI\setSuffixes().

Referenced by editIcon().

308  {
309  global $DIC;
310 
311  $toolbar = $DIC->toolbar();
312 
313  $si = new ilSelectInputGUI($this->lng->txt("select_icon"), "selected_icon");
314 
315  $options = array();
316  foreach($this->getIconFolder()->getIcons() as $icon) {
317  if($icon->getType()=="svg"){
318  $options[$icon->getName()] = $icon->getName();
319  }
320  }
321 
322  $si->setOptions($options);
323 
324  $si->setValue($icon_name);
325 
326  $toolbar->addInputItem($si, true);
327 
328  $select_btn = ilSubmitButton::getInstance();
329  $select_btn->setCaption($this->lng->txt("select"),false);
330  $toolbar->addButtonInstance($select_btn);
331  $toolbar->setFormAction($this->ctrl->getLinkTarget($this, 'editIcon'));
332  }
This class represents a selection list property in a property form.
if(!is_array($argv)) $options
Create styles array
The data for the language used.
global $DIC
+ 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().

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

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

Referenced by executeCommand().

292  {
293  $icon_name = $_POST['selected_icon']?$_POST['selected_icon']:$_GET['selected_icon'];
294 
295  $this->addSelectIconToolbar($icon_name);
296 
297  if($icon_name){
298  $icon = $this->getIconFolder()->getIconByName($icon_name);
299  $form = $this->initByIconForm($icon);
300  $this->getByIconValues($form, $icon);
301  $this->tpl->setContent($form->getHTML().$this->renderIconPreview($icon));
302  }
303  }
$_GET["client_id"]
getByIconValues(ilPropertyFormGUI $form, 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 81 of file class.ilSystemStyleIconsGUI.php.

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

82  {
83  $cmd = $this->ctrl->getCmd();
84  $this->setSubStyleSubTabs($cmd);
85 
86  switch ($cmd)
87  {
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  }
$cmd
Definition: sahs_server.php:35
+ Here is the call graph for this function:

◆ fail()

ilSystemStyleIconsGUI::fail ( )
protected

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

Referenced by executeCommand().

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

◆ getByColorValues()

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

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

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

Referenced by edit().

226  {
227  $values = [];
228 
229  if($this->getIconFolder()){
230  $colors = $this->getIconFolder()->getColorSet()->getColors();
231  foreach($colors as $color){
232  $id = $color->getId();
233  if($colors[$color->getId()]){
234  $values[$id] = $colors[$color->getId()]->getColor();
235  }else{
236  $values[$id] = $color->getColor();
237  }
238  }
239  }
240 
241 
242  $form->setValuesByArray($values);
243  }
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 392 of file class.ilSystemStyleIconsGUI.php.

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

Referenced by editIcon().

393  {
394  $values = [];
395 
396  $colors = $this->getIconFolder()->getColorSet()->getColors();
397  foreach($icon-> getColorSet()->getColors() as $color){
398  $id = $color->getId();
399  if($colors[$color->getId()]){
400  $values[$id] = $colors[$color->getId()]->getColor();
401  }else{
402  $values[$id] = $color->getColor();
403  }
404  }
405  $values["selected_icon"] = $icon->getName();
406 
407  $form->setValuesByArray($values);
408  }
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 540 of file class.ilSystemStyleIconsGUI.php.

References $icon_folder.

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

+ Here is the caller graph for this function:

◆ getStyleContainer()

ilSystemStyleIconsGUI::getStyleContainer ( )
Returns
ilSystemStyleSkinContainer

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

References $style_container.

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

+ Here is the caller graph for this function:

◆ preview()

ilSystemStyleIconsGUI::preview ( )
protected

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

References $section, $title, ilSystemStyleIconColor\BLUE, getIconFolder(), ilSystemStyleIconColor\GREEN, ilSystemStyleIconColor\GREY, ilSystemStyleIconColor\RED, ilUtil\sendFailure(), and ilFormPropertyGUI\setRequired().

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

◆ renderIconPreview()

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

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

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

465  {
466  global $DIC;
467 
468  $f = $DIC->ui()->factory();
469 
470  $icon_image = $f->image()->standard($icon->getPath(),$icon->getName());
471 
472  $card = $f->card(
473  $icon->getName(),
474  $icon_image
475  );
476 
477  $report = $f->panel()->standard($this->lng->txt("preview"),$f->deck([$card]));
478 
479  return $DIC->ui()->renderer()->render($report);
480  }
global $DIC
+ Here is the call graph for this function:

◆ reset()

ilSystemStyleIconsGUI::reset ( )

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

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

246  {
247  $style = $this->getStyleContainer()->getSkin()->getStyle($_GET["style_id"]);
248  $this->getStyleContainer()->resetImages($style);
249  $this->setIconFolder(new ilSystemStyleIconFolder($this->getStyleContainer()->getImagesSkinPath($style->getId())));
250  $message_stack = new ilSystemStyleMessageStack();
251  $message_stack->sendMessages(true);
252  $message_stack->addMessage(new ilSystemStyleMessage(
253  $this->lng->txt("color_reset"),
255  $this->ctrl->redirect($this,"edit");
256  }
$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 548 of file class.ilSystemStyleIconsGUI.php.

References $icon_folder.

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

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

◆ setStyleContainer()

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

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

References $style_container.

Referenced by __construct().

533  {
534  $this->style_container = $style_container;
535  }
+ Here is the caller graph for this function:

◆ setSubStyleSubTabs()

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

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

Referenced by executeCommand().

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

◆ update()

ilSystemStyleIconsGUI::update ( )

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

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

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

◆ updateIcon()

ilSystemStyleIconsGUI::updateIcon ( )

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

References $_POST, ilSystemStyleIcon\changeColors(), ilSystemStyleIcon\getColorSet(), getIconFolder(), ilSystemStyleIcon\getName(), getStyleContainer(), ilSystemStyleMessage\TYPE_ERROR, and ilSystemStyleMessage\TYPE_SUCCESS.

411  {
412 
413  $icon_name = $_POST['selected_icon'];
414  $icon = $this->getIconFolder()->getIconByName($icon_name);
415 
416  $form = $this->initByIconForm($icon);
417 
418  if ($form->checkInput())
419  {
420  $message_stack = new ilSystemStyleMessageStack();
421 
422  $color_changes = [];
423  foreach($icon->getColorSet()->getColors() as $old_color){
424  $new_color = $form->getInput($old_color->getId());
425  if(!preg_match("/[\dabcdef]{6}/i",$new_color)){
426  $message_stack->addMessage(new ilSystemStyleMessage($this->lng->txt("invalid_color").$new_color,
428  }else if($new_color != $old_color->getId()){
429  $color_changes[$old_color->getId()] = $new_color;
430 
431  $message_stack->addMessage(new ilSystemStyleMessage(
432  $this->lng->txt("color_changed_from")." ".$old_color->getId()." ".
433  $this->lng->txt("color_changed_to")." ".$new_color,
435  }
436  }
437  $icon->changeColors($color_changes);
438 
439  if($_POST["changed_icon"]){
440  $old_icon = $this->getIconFolder()->getIconByName($icon_name);
441  move_uploaded_file($_POST["changed_icon"]["tmp_name"],$old_icon->getPath());
442  }
443 
444 
445  foreach ($message_stack->getJoinedMessages() as $type => $message) {
447  $skin = $this->getStyleContainer()->getSkin();
448  $skin->getVersionStep($skin->getVersion());
449  $this->getStyleContainer()->updateSkin($skin);
450  continue;
451  }
452  }
453  $message_stack->sendMessages(true);
454  $this->ctrl->setParameter($this,"selected_icon",$icon->getName());
455  $this->ctrl->redirect($this,"editIcon");
456  }
457  $form->setValuesByPost();
458  $this->tpl->setContent($form->getHTML());
459  }
Used to stack messages to be shown to the user.
$_POST["username"]
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilSystemStyleIconsGUI::$ctrl
protected

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

◆ $icon_folder

ilSystemStyleIconsGUI::$icon_folder = null
protected

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

Referenced by getIconFolder(), and setIconFolder().

◆ $lng

ilSystemStyleIconsGUI::$lng
protected

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

◆ $style_container

ilSystemStyleIconsGUI::$style_container
protected

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

Referenced by getStyleContainer(), and setStyleContainer().

◆ $tabs

ilSystemStyleIconsGUI::$tabs
protected

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

◆ $tpl

ilSystemStyleIconsGUI::$tpl
protected

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


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