ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 
 getDirRelToCustomizing ()
 Only get dir rel to the Customizing dir without name and extension from. More...
 
 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 105 of file class.ilSystemStyleIcon.php.

106 {
107 return $this->getName();
108 }

References getName().

+ 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.

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

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

+ Here is the call 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 150 of file class.ilSystemStyleIcon.php.

151 {
152 $regex_for_extracting_color = '/(?<=#)[\dabcdef]{6}/i';
153
154 $this->color_set = new ilSystemStyleIconColorSet();
155 if ($this->getType() == "svg") {
156 $icon_content = file_get_contents($this->getPath());
157 $color_matches = [];
158 preg_match_all($regex_for_extracting_color, $icon_content, $color_matches);
159 if (is_array($color_matches) && is_array($color_matches[0])) {
160 foreach ($color_matches[0] as $color_value) {
161 $numeric = strtoupper(str_replace("#", "", $color_value));
162 $color = new ilSystemStyleIconColor($numeric, $color_value, $numeric, $color_value);
163 $this->getColorSet()->addColor($color);
164 }
165 }
166 }
167 }

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

Referenced by changeColors(), and getColorSet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColorSet()

ilSystemStyleIcon::getColorSet ( )
Returns
ilSystemStyleIconColorSet

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

140 {
141 if (!$this->color_set) {
142 $this->extractColorSet();
143 }
144 return $this->color_set;
145 }

References $color_set, and extractColorSet().

Referenced by extractColorSet(), and usesColor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDirRelToCustomizing()

ilSystemStyleIcon::getDirRelToCustomizing ( )

Only get dir rel to the Customizing dir without name and extension from.

Returns
string

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

132 {
133 return dirname(strstr($this->getPath(), 'global/skin'));
134 }

References getPath().

+ Here is the call graph for this function:

◆ getName()

ilSystemStyleIcon::getName ( )
Returns
string

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

89 {
90 return $this->name;
91 }

References $name.

Referenced by __toString(), ilSystemStyleIconsGUI\getByIconValues(), and ilSystemStyleIconsGUI\renderIconPreview().

+ Here is the caller graph for this function:

◆ getPath()

ilSystemStyleIcon::getPath ( )
Returns
string

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

114 {
115 return $this->path;
116 }

References $path.

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

+ Here is the caller graph for this function:

◆ getType()

ilSystemStyleIcon::getType ( )
Returns
string

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

73 {
74 return $this->type;
75 }

References $type.

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

+ Here is the caller graph for this function:

◆ setColorSet()

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

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

173 {
174 $this->color_set = $color_set;
175 }

References $color_set.

◆ setName()

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

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

97 {
98 $this->name = $name;
99 }

References $name.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setPath()

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

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

122 {
123 $this->path = $path;
124 }

References $path.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setType()

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

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

81 {
82 $this->type = $type;
83 }

References $type.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ usesColor()

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

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

182 {
183 return $this->getColorSet()->doesColorExist($color_id);
184 }

References getColorSet().

+ 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: