ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
All Data Structures Namespaces Files Functions Variables Typedefs Modules Pages
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.

References getName().

106  {
107  return $this->getName();
108  }
+ 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\getByIconValues().

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

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

Referenced by changeColors(), and getColorSet().

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

References $color_set, and extractColorSet().

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

140  {
141  if (!$this->color_set) {
142  $this->extractColorSet();
143  }
144  return $this->color_set;
145  }
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:

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

References getPath().

132  {
133  return dirname(strstr($this->getPath(), 'global/skin'));
134  }
+ Here is the call graph for this function:

◆ getName()

ilSystemStyleIcon::getName ( )

◆ getPath()

ilSystemStyleIcon::getPath ( )
Returns
string

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

References $path.

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

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

◆ getType()

ilSystemStyleIcon::getType ( )
Returns
string

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

References $type.

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

73  {
74  return $this->type;
75  }
+ 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.

References $color_set.

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

◆ setName()

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

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

References $name.

Referenced by __construct().

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

◆ setPath()

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

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

References $path.

Referenced by __construct().

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

◆ setType()

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

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

References $type.

Referenced by __construct().

81  {
82  $this->type = $type;
83  }
+ 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.

References getColorSet().

182  {
183  return $this->getColorSet()->doesColorExist($color_id);
184  }
+ 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: