ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSystemStyleIconFolder Class Reference

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

+ Collaboration diagram for ilSystemStyleIconFolder:

Public Member Functions

 __construct (string $path)
 ilSystemStyleIconFolder constructor. More...
 
 read ()
 Reads the folder recursively and sorts the icons by name and type. More...
 
 sortIconsByPath ()
 
 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 (string $name)
 
 getIconByPath (string $path)
 
 getIconsSortedByFolder ()
 Sorts all icons by their occurrence in folders. More...
 
 setIcons (array $icons)
 
 getPath ()
 
 setPath (string $path)
 
 getColorSet ()
 
 getUsagesOfColor (string $color_id)
 Gets the usages of a certain color. More...
 
 getUsagesOfColorAsString (string $color_id)
 Gets the usages of a color as string. More...
 
 setColorSet (ilSystemStyleIconColorSet $color_set)
 

Protected Member Functions

 sortIcons ()
 Sorts the Icons by name and type. More...
 
 compareIconsByName (ilSystemStyleIcon $a, ilSystemStyleIcon $b)
 
 readIconsFromFolder (string $src='')
 
 extractColorSet ()
 Gets the color sets of all icons an merges them into one. More...
 

Protected Attributes

array $icons = []
 
string $path = ''
 Path to the root of the folder. More...
 
ilSystemStyleIconColorSet $color_set
 Complete color set of all icons contained in this folder. More...
 

Detailed Description

Abstracts a folder containing a set of icons.

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

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleIconFolder::__construct ( string  $path)

ilSystemStyleIconFolder constructor.

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

References read(), and setPath().

46  {
47  $this->setPath($path);
48  $this->read();
49  }
string $path
Path to the root of the folder.
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.

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

Referenced by readIconsFromFolder().

129  : void
130  {
131  $this->icons[] = $icon;
132  }
+ 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.

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

References getIcons().

119  : void
120  {
121  foreach ($this->getIcons() as $icon) {
122  $icon->changeColors($color_changes);
123  }
124  }
getIcons()
Gets an Icon from the folders abstraction.
+ Here is the call graph for this function:

◆ compareIconsByName()

ilSystemStyleIconFolder::compareIconsByName ( ilSystemStyleIcon  $a,
ilSystemStyleIcon  $b 
)
protected

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

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

69  : int
70  {
71  if ($a->getType() == $b->getType()) {
72  return strcmp($a->getName(), $b->getName());
73  } elseif ($a->getType() == 'svg') {
74  return -1;
75  } elseif ($b->getType() == 'svg') {
76  return 1;
77  } else {
78  return strcmp($a->getType(), $b->getType());
79  }
80  }
+ 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 219 of file class.ilSystemStyleIconFolder.php.

References getIcons().

Referenced by getColorSet().

219  : void
220  {
221  $this->color_set = new ilSystemStyleIconColorSet();
222  foreach ($this->getIcons() as $icon) {
223  $this->color_set->mergeColorSet($icon->getColorSet());
224  }
225  }
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 ( )

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

References $color_set, and extractColorSet().

209  {
210  if (!isset($this->color_set)) {
211  $this->extractColorSet();
212  }
213  return $this->color_set;
214  }
extractColorSet()
Gets the color sets of all icons an merges them into one.
ilSystemStyleIconColorSet $color_set
Complete color set of all icons contained in this folder.
+ Here is the call graph for this function:

◆ getIconByName()

ilSystemStyleIconFolder::getIconByName ( string  $name)
Exceptions
ilSystemStyleIconException

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

References $name, and ilSystemStyleIconException\ICON_DOES_NOT_EXIST.

147  {
148  foreach ($this->icons as $icon) {
149  if ($icon->getName() == $name) {
150  return $icon;
151  }
152  }
154  }
Class for advanced editing exception handling in ILIAS.
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
if($format !==null) $name
Definition: metadata.php:247

◆ getIconByPath()

ilSystemStyleIconFolder::getIconByPath ( string  $path)
Exceptions
ilSystemStyleIconException

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

References $path, and ilSystemStyleIconException\ICON_DOES_NOT_EXIST.

160  {
161  foreach ($this->icons as $icon) {
162  if ($icon->getPath() == $path) {
163  return $icon;
164  }
165  }
167  }
Class for advanced editing exception handling in ILIAS.
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
string $path
Path to the root of the folder.

◆ getIcons()

ilSystemStyleIconFolder::getIcons ( )

Gets an Icon from the folders abstraction.

Returns
ilSystemStyleIcon[]

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

References $icons.

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

138  : array
139  {
140  return $this->icons;
141  }
+ 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 173 of file class.ilSystemStyleIconFolder.php.

References $id, and getIcons().

173  : array
174  {
175  $folders = [];
176 
177  foreach ($this->getIcons() as $icon) {
178  $folders[dirname($icon->getPath())][] = $icon;
179  }
180 
181  ksort($folders);
182 
183  foreach ($folders as $id => $folder) {
184  ksort($folders[$id]);
185  }
186 
187  return $folders;
188  }
getIcons()
Gets an Icon from the folders abstraction.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getPath()

ilSystemStyleIconFolder::getPath ( )

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

References $path.

Referenced by read().

198  : string
199  {
200  return $this->path;
201  }
string $path
Path to the root of the folder.
+ Here is the caller graph for this function:

◆ getUsagesOfColor()

ilSystemStyleIconFolder::getUsagesOfColor ( string  $color_id)

Gets the usages of a certain color.

Returns
ilSystemStyleIcon[]

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

References $icons, and getIcons().

Referenced by getUsagesOfColorAsString().

231  : array
232  {
233  $icons = [];
234  foreach ($this->getIcons() as $icon) {
235  if ($icon->usesColor($color_id)) {
236  $icons[] = $icon;
237  }
238  }
239  return $icons;
240  }
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 ( string  $color_id)

Gets the usages of a color as string.

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

References getUsagesOfColor().

245  : string
246  {
247  $usage_string = '';
248  foreach ($this->getUsagesOfColor($color_id) as $icon) {
249  $usage_string .= rtrim($icon->getName(), '.svg') . '; ';
250  }
251  return $usage_string;
252  }
getUsagesOfColor(string $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 55 of file class.ilSystemStyleIconFolder.php.

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

Referenced by __construct().

55  : void
56  {
57  $this->readIconsFromFolder($this->getPath());
58  $this->sortIcons();
59  }
sortIcons()
Sorts the Icons by name and type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readIconsFromFolder()

ilSystemStyleIconFolder::readIconsFromFolder ( string  $src = '')
protected
Exceptions
ilSystemStyleException
ilSystemStyleIconException

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

References Vendor\Package\$e, addIcon(), ilSystemStyleException\FILE_OPENING_FAILED, and ilSystemStyleIconException\IMAGES_FOLDER_DOES_NOT_EXIST.

Referenced by read().

93  : void
94  {
95  try {
96  $dir_iterator = new RecursiveDirectoryIterator($src);
97  } catch (UnexpectedValueException $e) {
99  }
100 
101  $rec_it = new RecursiveIteratorIterator($dir_iterator);
102 
103  foreach ($rec_it as $file) {
104  if (!$file->isReadable()) {
106  }
107  if ($file->isFile()) {
108  $extension = $file->getExtension();
109  if ($extension == 'gif' || $extension == 'svg' || $extension == 'png') {
110  $this->addIcon(new ilSystemStyleIcon($file->getFilename(), $file->getPathname(), $extension));
111  }
112  }
113  }
114  }
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. ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setColorSet()

ilSystemStyleIconFolder::setColorSet ( ilSystemStyleIconColorSet  $color_set)

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

References $color_set.

254  : void
255  {
256  $this->color_set = $color_set;
257  }
ilSystemStyleIconColorSet $color_set
Complete color set of all icons contained in this folder.

◆ setIcons()

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

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

References $icons.

193  : void
194  {
195  $this->icons = $icons;
196  }

◆ setPath()

ilSystemStyleIconFolder::setPath ( string  $path)

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

References $path.

Referenced by __construct().

203  : void
204  {
205  $this->path = $path;
206  }
string $path
Path to the root of the folder.
+ Here is the caller graph for this function:

◆ sortIcons()

ilSystemStyleIconFolder::sortIcons ( )
protected

Sorts the Icons by name and type.

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

Referenced by read().

64  : void
65  {
66  usort($this->icons, [$this, 'compareIconsByName']);
67  }
+ Here is the caller graph for this function:

◆ sortIconsByPath()

ilSystemStyleIconFolder::sortIconsByPath ( )

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

References Vendor\Package\$a, Vendor\Package\$b, and ilSystemStyleIcon\getPath().

82  : void
83  {
84  usort($this->icons, static function (ilSystemStyleIcon $a, ilSystemStyleIcon $b): int {
85  return strcmp($a->getPath(), $b->getPath());
86  });
87  }
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:

Field Documentation

◆ $color_set

ilSystemStyleIconColorSet ilSystemStyleIconFolder::$color_set
protected

Complete color set of all icons contained in this folder.

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

Referenced by getColorSet(), and setColorSet().

◆ $icons

array ilSystemStyleIconFolder::$icons = []
protected

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

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

◆ $path

string ilSystemStyleIconFolder::$path = ''
protected

Path to the root of the folder.

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

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


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