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.

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

43  {
44  $this->setPath($path);
45  $this->read();
46  }
read()
Reads the folder recursively and sorts the icons by name and type.
+ 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.

Referenced by xRead().

124  {
125  $this->icons[] = $icon;
126  }
+ Here is the caller graph for this function:

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

References getIcons().

113  {
114  foreach($this->getIcons() as $icon){
115  $icon->changeColors($color_changes);
116  }
117  }
getIcons()
Gets an Icon from the folders abstraction.
+ Here is the call graph for this function:

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

References getIcons().

Referenced by getColorSet().

210  {
211  $this->color_set = new ilSystemStyleIconColorSet();
212  foreach($this->getIcons() as $icon){
213  $this->color_set->mergeColorSet($icon->getColorSet());
214  }
215  }
getIcons()
Gets an Icon from the folders abstraction.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColorSet()

ilSystemStyleIconFolder::getColorSet ( )
Returns
ilSystemStyleIconColorSet

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

References $color_set, and extractColorSet().

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.
+ Here is the call graph for this function:

◆ getIconByName()

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

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

References ilSystemStyleIconException\ICON_DOES_NOT_EXIST.

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.

◆ getIcons()

ilSystemStyleIconFolder::getIcons ( )

Gets an Icon from the folders abstraction.

Returns
ilSystemStyleIcon[]

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

References $icons.

Referenced by changeIconColors(), extractColorSet(), getIconsSortedByFolder(), and getUsagesOfColor().

+ Here is the caller graph for this function:

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

References getIcons().

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  }
getIcons()
Gets an Icon from the folders abstraction.
+ Here is the call graph for this function:

◆ getPath()

ilSystemStyleIconFolder::getPath ( )
Returns
string

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

References $path.

Referenced by read(), and xRead().

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

References $icons, and getIcons().

Referenced by getUsagesOfColorAsString().

223  {
224  $icons = [];
225  foreach($this->getIcons() as $icon){
226  if($icon->usesColor($color_id)){
227  $icons[] = $icon;
228  }
229  }
230  return $icons;
231  }
getIcons()
Gets an Icon from the folders abstraction.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

References getUsagesOfColor().

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.
+ Here is the call graph for this function:

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

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

Referenced by __construct().

53  {
54  $this->xRead($this->getPath(),"");
55  $this->sortIcons();
56  }
sortIcons()
Sorts the Icons by name and type.
+ 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.

References $color_set.

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

◆ setIcons()

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

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

References $icons.

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

◆ setPath()

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

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

References $path.

Referenced by __construct().

192  {
193  $this->path = $path;
194  }
+ 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.

References ilSystemStyleIcon\getName(), and ilSystemStyleIcon\getType().

Referenced by read().

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

References $file, $info, addIcon(), ilSystemStyleException\FILE_OPENING_FAILED, getPath(), and ilSystemStyleIconException\IMAGES_FOLDER_DOES_NOT_EXIST.

Referenced by read().

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.
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
$info
Definition: example_052.php:80
Class for advanced editing exception handling in ILIAS.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ Here is the call graph for this function:
+ 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.

Referenced by getColorSet(), and setColorSet().

◆ $icons

ilSystemStyleIconFolder::$icons = []
protected

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

Referenced by getIcons(), getUsagesOfColor(), and setIcons().

◆ $path

ilSystemStyleIconFolder::$path = ""
protected

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

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


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