ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSystemStyleIconFolder Class Reference

Abstracts a folder containing a set of icons. More...

+ Collaboration diagram for ilSystemStyleIconFolder:

Public Member Functions

 __construct ($path)
 ilSystemStyleIconFolder constructor. More...
 
 read ()
 Reads the folder recursively and sorts the icons by name and type. More...
 
 changeIconColors (array $color_changes)
 Changes a set of colors in all icons contained in the folder. More...
 
 addIcon (ilSystemStyleIcon $icon)
 Adds an icon to the folders abstraction. More...
 
 getIcons ()
 Gets an Icon from the folders abstraction. More...
 
 getIconByName ($name)
 
 getIconsSortedByFolder ()
 Sorts all icons by their occurrence in folders. More...
 
 setIcons ($icons)
 
 getPath ()
 
 setPath ($path)
 
 getColorSet ()
 
 getUsagesOfColor ($color_id)
 Gets the usages of a certain color. More...
 
 getUsagesOfColorAsString ($color_id)
 Gets the usages of a color as string. More...
 
 setColorSet ($color_set)
 

Protected Member Functions

 sortIcons ()
 Sorts the Icons by name and type. More...
 
 xRead ($src="", $rel_path="")
 
 extractColorSet ()
 Gets the color sets of all icons an merges them into one. More...
 

Protected Attributes

 $icons = []
 
 $path = ""
 
 $color_set = null
 

Detailed Description

Abstracts a folder containing a set of icons.

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

Class ilSystemStyleIconFolder

Definition at line 15 of file class.ilSystemStyleIconFolder.php.

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleIconFolder::__construct (   $path)

ilSystemStyleIconFolder constructor.

Parameters
string$path

Definition at line 42 of file class.ilSystemStyleIconFolder.php.

43 {
44 $this->setPath($path);
45 $this->read();
46 }
read()
Reads the folder recursively and sorts the icons by name and type.

References $path, read(), and setPath().

+ Here is the call graph for this function:

Member Function Documentation

◆ addIcon()

ilSystemStyleIconFolder::addIcon ( ilSystemStyleIcon  $icon)

Adds an icon to the folders abstraction.

Parameters
ilSystemStyleIcon$icon

Definition at line 127 of file class.ilSystemStyleIconFolder.php.

128 {
129 $this->icons[] = $icon;
130 }

◆ changeIconColors()

ilSystemStyleIconFolder::changeIconColors ( array  $color_changes)

Changes a set of colors in all icons contained in the folder.

Parameters
array$color_changes

Definition at line 115 of file class.ilSystemStyleIconFolder.php.

116 {
117 foreach ($this->getIcons() as $icon) {
118 $icon->changeColors($color_changes);
119 }
120 }
getIcons()
Gets an Icon from the folders abstraction.

◆ extractColorSet()

ilSystemStyleIconFolder::extractColorSet ( )
protected

Gets the color sets of all icons an merges them into one.

Definition at line 216 of file class.ilSystemStyleIconFolder.php.

217 {
218 $this->color_set = new ilSystemStyleIconColorSet();
219 foreach ($this->getIcons() as $icon) {
220 $this->color_set->mergeColorSet($icon->getColorSet());
221 }
222 }

◆ getColorSet()

ilSystemStyleIconFolder::getColorSet ( )
Returns
ilSystemStyleIconColorSet

Definition at line 205 of file class.ilSystemStyleIconFolder.php.

206 {
207 if (!$this->color_set) {
208 $this->extractColorSet();
209 }
210 return $this->color_set;
211 }
extractColorSet()
Gets the color sets of all icons an merges them into one.

◆ getIconByName()

ilSystemStyleIconFolder::getIconByName (   $name)
Parameters
$name
Returns
ilSystemStyleIcon
Exceptions
ilSystemStyleIconException

Definition at line 147 of file class.ilSystemStyleIconFolder.php.

148 {
149 foreach ($this->icons as $icon) {
150 if ($icon->getName() == $name) {
151 return $icon;
152 }
153 }
155 }
Class for advanced editing exception handling in ILIAS.

References $name, and ilSystemStyleIconException\ICON_DOES_NOT_EXIST.

◆ getIcons()

ilSystemStyleIconFolder::getIcons ( )

Gets an Icon from the folders abstraction.

Returns
ilSystemStyleIcon[]

Definition at line 137 of file class.ilSystemStyleIconFolder.php.

◆ getIconsSortedByFolder()

ilSystemStyleIconFolder::getIconsSortedByFolder ( )

Sorts all icons by their occurrence in folders.

Returns
array array(folder_path_name => [$icons])

Definition at line 162 of file class.ilSystemStyleIconFolder.php.

163 {
164 $folders = [];
165
166 foreach ($this->getIcons() as $icon) {
167 $folders[dirname($icon->getPath())][] = $icon;
168 }
169
170 ksort($folders);
171
172 foreach ($folders as $id => $folder) {
173 ksort($folders[$id]);
174 }
175
176 return $folders;
177 }
if(!array_key_exists('StateId', $_REQUEST)) $id

References $id.

◆ getPath()

ilSystemStyleIconFolder::getPath ( )
Returns
string

Definition at line 189 of file class.ilSystemStyleIconFolder.php.

190 {
191 return $this->path;
192 }

References $path.

Referenced by read().

+ Here is the caller graph for this function:

◆ getUsagesOfColor()

ilSystemStyleIconFolder::getUsagesOfColor (   $color_id)

Gets the usages of a certain color.

Parameters
$color_id
Returns
ilSystemStyleIcon[]

Definition at line 230 of file class.ilSystemStyleIconFolder.php.

231 {
232 $icons = [];
233 foreach ($this->getIcons() as $icon) {
234 if ($icon->usesColor($color_id)) {
235 $icons[] = $icon;
236 }
237 }
238 return $icons;
239 }

◆ getUsagesOfColorAsString()

ilSystemStyleIconFolder::getUsagesOfColorAsString (   $color_id)

Gets the usages of a color as string.

Parameters
$color_id
Returns
string

Definition at line 247 of file class.ilSystemStyleIconFolder.php.

248 {
249 $usage_string = "";
250 foreach ($this->getUsagesOfColor($color_id) as $icon) {
251 $usage_string .= rtrim($icon->getName(), ".svg") . "; ";
252 }
253 return $usage_string;
254 }
getUsagesOfColor($color_id)
Gets the usages of a certain color.

◆ read()

ilSystemStyleIconFolder::read ( )

Reads the folder recursively and sorts the icons by name and type.

Exceptions
ilSystemStyleException

Definition at line 53 of file class.ilSystemStyleIconFolder.php.

54 {
55 $this->xRead($this->getPath(), "");
56 $this->sortIcons();
57 }
sortIcons()
Sorts the Icons by name and type.

References getPath(), sortIcons(), and xRead().

Referenced by __construct().

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

◆ setColorSet()

ilSystemStyleIconFolder::setColorSet (   $color_set)
Parameters
$color_set

Definition at line 259 of file class.ilSystemStyleIconFolder.php.

260 {
261 $this->color_set = $color_set;
262 }

◆ setIcons()

ilSystemStyleIconFolder::setIcons (   $icons)
Parameters
ilSystemStyleIcon[]$icons

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

182 {
183 $this->icons = $icons;
184 }

◆ setPath()

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

Definition at line 197 of file class.ilSystemStyleIconFolder.php.

198 {
199 $this->path = $path;
200 }

References $path.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ sortIcons()

ilSystemStyleIconFolder::sortIcons ( )
protected

Sorts the Icons by name and type.

Definition at line 62 of file class.ilSystemStyleIconFolder.php.

63 {
64 usort($this->icons, function (ilSystemStyleIcon $a, ilSystemStyleIcon $b) {
65 if ($a->getType() == $b->getType()) {
66 return strcmp($a->getName(), $b->getName());
67 } else {
68 if ($a->getType() == "svg") {
69 return false;
70 } elseif ($b->getType() == "svg") {
71 return true;
72 } else {
73 return strcmp($a->getType(), $b->getType());
74 }
75 }
76 });
77 }
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon.

References ilSystemStyleIcon\getType().

Referenced by read().

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

◆ xRead()

ilSystemStyleIconFolder::xRead (   $src = "",
  $rel_path = "" 
)
protected
Parameters
string$src
string$rel_path
Exceptions
ilSystemStyleException
ilSystemStyleIconException

Definition at line 85 of file class.ilSystemStyleIconFolder.php.

86 {
87 if (!is_dir($src)) {
89 }
90 foreach (scandir($src) as $file) {
91 $src_file = rtrim($src, '/') . '/' . $file;
92 if (!is_readable($src_file)) {
94 }
95 if (substr($file, 0, 1) != ".") {
96 if (is_dir($src_file)) {
97 self::xRead($src_file, $rel_path . "/" . $file);
98 } else {
99 $info = new SplFileInfo($src_file);
100 $extension = $info->getExtension();
101 if ($extension == "gif" || $extension == "svg" || $extension == "png") {
102 $this->addIcon(new ilSystemStyleIcon($file, $this->getPath() . $rel_path . "/" . $file, $extension));
103 }
104 }
105 }
106 }
107 }
Class for advanced editing exception handling in ILIAS.
addIcon(ilSystemStyleIcon $icon)
Adds an icon to the folders abstraction.
$info
Definition: index.php:5

References $info, ilSystemStyleException\FILE_OPENING_FAILED, and ilSystemStyleIconException\IMAGES_FOLDER_DOES_NOT_EXIST.

Referenced by read().

+ Here is the caller graph for this function:

Field Documentation

◆ $color_set

ilSystemStyleIconFolder::$color_set = null
protected

Definition at line 36 of file class.ilSystemStyleIconFolder.php.

◆ $icons

ilSystemStyleIconFolder::$icons = []
protected

Definition at line 22 of file class.ilSystemStyleIconFolder.php.

◆ $path

ilSystemStyleIconFolder::$path = ""
protected

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

Referenced by __construct().


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