ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSystemStyleIcon Class Reference

Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. More...

+ Collaboration diagram for ilSystemStyleIcon:

Public Member Functions

 __construct ($name, $path, $type)
 ilSystemStyleIcon constructor. More...
 
 changeColors (array $color_changes)
 Changes colors in the svg file of the icon and updates the icon abstraction by extracting the colors again. More...
 
 getType ()
 
 setType ($type)
 
 getName ()
 
 setName ($name)
 
 __toString ()
 
 getPath ()
 
 setPath ($path)
 
 getColorSet ()
 
 setColorSet ($color_set)
 
 usesColor ($color_id)
 

Protected Member Functions

 extractColorSet ()
 Extracts all colors from the icon by parsing the svg file for a regular expresion. More...
 

Protected Attributes

 $path = ""
 
 $name = ""
 
 $type = ""
 
 $color_set = null
 

Detailed Description

Abstracts an Icon and the necessary actions to get all colors out of an svg Icon.

Author
Timon Amstutz timon.nosp@m..ams.nosp@m.tutz@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$

Definition at line 11 of file class.ilSystemStyleIcon.php.

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleIcon::__construct (   $name,
  $path,
  $type 
)

ilSystemStyleIcon constructor.

Parameters
$name
$path
$type

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

References $name, $path, $type, setName(), setPath(), and setType().

+ Here is the call graph for this function:

Member Function Documentation

◆ __toString()

ilSystemStyleIcon::__toString ( )
Returns
mixed

Definition at line 104 of file class.ilSystemStyleIcon.php.

References getName().

105  {
106  return $this->getName();
107  }
+ Here is the call graph for this function:

◆ changeColors()

ilSystemStyleIcon::changeColors ( array  $color_changes)

Changes colors in the svg file of the icon and updates the icon abstraction by extracting the colors again.

Parameters
array$color_changes

Definition at line 57 of file class.ilSystemStyleIcon.php.

References extractColorSet(), getPath(), and getType().

Referenced by ilSystemStyleIconsGUI\updateIcon().

57  {
58  if($this->getType() == "svg"){
59  $icon = file_get_contents($this->getPath());
60  foreach($color_changes as $old_color => $new_color){
61  $icon = preg_replace ( '/'.$old_color.'/i' , $new_color, $icon, -1 );
62  }
63  file_put_contents ($this->getPath(),$icon);
64  }
65  $this->extractColorSet();
66  }
extractColorSet()
Extracts all colors from the icon by parsing the svg file for a regular expresion.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extractColorSet()

ilSystemStyleIcon::extractColorSet ( )
protected

Extracts all colors from the icon by parsing the svg file for a regular expresion.

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

References getColorSet(), getPath(), and getType().

Referenced by changeColors(), and getColorSet().

139  {
140  $regex_for_extracting_color = '/(?<=#)[\dabcdef]{6}/i';
141 
142  $this->color_set = new ilSystemStyleIconColorSet();
143  if($this->getType() == "svg"){
144  $icon_content = file_get_contents($this->getPath());
145  $color_matches = [];
146  preg_match_all ($regex_for_extracting_color ,$icon_content,$color_matches);
147  if(is_array($color_matches) && is_array($color_matches[0]))
148  foreach($color_matches[0] as $color_value){
149  $numeric = strtoupper(str_replace("#","",$color_value));
150  $color = new ilSystemStyleIconColor($numeric,$color_value,$numeric,$color_value);
151  $this->getColorSet()->addColor($color);
152  }
153  }
154  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColorSet()

ilSystemStyleIcon::getColorSet ( )
Returns
ilSystemStyleIconColorSet

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

References $color_set, and extractColorSet().

Referenced by ilSystemStyleIconsGUI\addSelectIconToolbar(), extractColorSet(), ilSystemStyleIconsGUI\updateIcon(), and usesColor().

129  {
130  if(!$this->color_set){
131  $this->extractColorSet();
132  }
133  return $this->color_set;
134  }
extractColorSet()
Extracts all colors from the icon by parsing the svg file for a regular expresion.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getName()

ilSystemStyleIcon::getName ( )

◆ getPath()

ilSystemStyleIcon::getPath ( )
Returns
string

Definition at line 112 of file class.ilSystemStyleIcon.php.

References $path.

Referenced by changeColors(), extractColorSet(), and ilSystemStyleIconsGUI\renderIconPreview().

113  {
114  return $this->path;
115  }
+ Here is the caller graph for this function:

◆ getType()

ilSystemStyleIcon::getType ( )
Returns
string

Definition at line 71 of file class.ilSystemStyleIcon.php.

References $type.

Referenced by changeColors(), extractColorSet(), and ilSystemStyleIconFolder\sortIcons().

72  {
73  return $this->type;
74  }
+ Here is the caller graph for this function:

◆ setColorSet()

ilSystemStyleIcon::setColorSet (   $color_set)
Parameters
ilSystemStyleIconColorSet$color_set

Definition at line 159 of file class.ilSystemStyleIcon.php.

References $color_set.

160  {
161  $this->color_set = $color_set;
162  }

◆ setName()

ilSystemStyleIcon::setName (   $name)
Parameters
string$name

Definition at line 95 of file class.ilSystemStyleIcon.php.

References $name.

Referenced by __construct().

96  {
97  $this->name = $name;
98  }
+ Here is the caller graph for this function:

◆ setPath()

ilSystemStyleIcon::setPath (   $path)
Parameters
string$path

Definition at line 120 of file class.ilSystemStyleIcon.php.

References $path.

Referenced by __construct().

121  {
122  $this->path = $path;
123  }
+ Here is the caller graph for this function:

◆ setType()

ilSystemStyleIcon::setType (   $type)
Parameters
string$type

Definition at line 79 of file class.ilSystemStyleIcon.php.

References $type.

Referenced by __construct().

80  {
81  $this->type = $type;
82  }
+ Here is the caller graph for this function:

◆ usesColor()

ilSystemStyleIcon::usesColor (   $color_id)
Parameters
$color_id
Returns
bool

Definition at line 168 of file class.ilSystemStyleIcon.php.

References getColorSet().

168  {
169  return $this->getColorSet()->doesColorExist($color_id);
170  }
+ Here is the call graph for this function:

Field Documentation

◆ $color_set

ilSystemStyleIcon::$color_set = null
protected

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

Referenced by getColorSet(), and setColorSet().

◆ $name

ilSystemStyleIcon::$name = ""
protected

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

Referenced by __construct(), getName(), and setName().

◆ $path

ilSystemStyleIcon::$path = ""
protected

Definition at line 18 of file class.ilSystemStyleIcon.php.

Referenced by __construct(), getPath(), and setPath().

◆ $type

ilSystemStyleIcon::$type = ""
protected

Definition at line 30 of file class.ilSystemStyleIcon.php.

Referenced by __construct(), getType(), and setType().


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