ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 124 of file class.ilSystemStyleIconFolder.php.

124 {
125 $this->icons[] = $icon;
126 }

◆ 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 113 of file class.ilSystemStyleIconFolder.php.

113 {
114 foreach($this->getIcons() as $icon){
115 $icon->changeColors($color_changes);
116 }
117 }
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 210 of file class.ilSystemStyleIconFolder.php.

210 {
211 $this->color_set = new ilSystemStyleIconColorSet();
212 foreach($this->getIcons() as $icon){
213 $this->color_set->mergeColorSet($icon->getColorSet());
214 }
215 }

◆ getColorSet()

ilSystemStyleIconFolder::getColorSet ( )
Returns
ilSystemStyleIconColorSet

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

200 {
201 if(!$this->color_set){
202 $this->extractColorSet();
203 }
204 return $this->color_set;
205 }
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 143 of file class.ilSystemStyleIconFolder.php.

143 {
144 foreach($this->icons as $icon){
145 if($icon->getName() == $name){
146 return $icon;
147 }
148 }
150 }
Class for advanced editing exception handling in ILIAS.

References ilSystemStyleIconException\ICON_DOES_NOT_EXIST.

◆ getIcons()

ilSystemStyleIconFolder::getIcons ( )

Gets an Icon from the folders abstraction.

Returns
ilSystemStyleIcon[]

Definition at line 133 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 157 of file class.ilSystemStyleIconFolder.php.

157 {
158 $folders = [];
159
160 foreach($this->getIcons() as $icon){
161 $folders[dirname($icon->getPath())][] = $icon;
162 }
163
164 ksort($folders);
165
166 foreach($folders as $id => $folder){
167 ksort($folders[$id]);
168 }
169
170 return $folders;
171 }

◆ getPath()

ilSystemStyleIconFolder::getPath ( )
Returns
string

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

184 {
185 return $this->path;
186 }

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 223 of file class.ilSystemStyleIconFolder.php.

223 {
224 $icons = [];
225 foreach($this->getIcons() as $icon){
226 if($icon->usesColor($color_id)){
227 $icons[] = $icon;
228 }
229 }
230 return $icons;
231 }

◆ getUsagesOfColorAsString()

ilSystemStyleIconFolder::getUsagesOfColorAsString (   $color_id)

Gets the usages of a color as string.

Parameters
$color_id
Returns
string

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

240 {
241 $usage_string = "";
242 foreach($this->getUsagesOfColor($color_id) as $icon){
243 $usage_string .= rtrim($icon->getName(),".svg")."; ";
244 }
245 return $usage_string;
246 }
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.

53 {
54 $this->xRead($this->getPath(),"");
55 $this->sortIcons();
56 }
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 251 of file class.ilSystemStyleIconFolder.php.

252 {
253 $this->color_set = $color_set;
254 }

◆ setIcons()

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

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

176 {
177 $this->icons = $icons;
178 }

◆ setPath()

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

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

192 {
193 $this->path = $path;
194 }

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 61 of file class.ilSystemStyleIconFolder.php.

61 {
62 usort($this->icons, function(ilSystemStyleIcon $a, ilSystemStyleIcon $b){
63 if($a->getType() == $b->getType()){
64 return strcmp($a->getName(),$b->getName());
65 }
66 else{
67 if($a->getType() == "svg"){
68 return false;
69 }else if($b->getType() == "svg"){
70 return true;
71 }else{
72 return strcmp($a->getType(),$b->getType());
73 }
74 }
75 });
76 }
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 84 of file class.ilSystemStyleIconFolder.php.

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

References $file, $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: