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

ilSkin holds an manages the basic data of a skin as provide by the template of the skin. More...

+ Inheritance diagram for ilSkin:
+ Collaboration diagram for ilSkin:

Public Member Functions

 __construct (string $id, string $name)
 
 asXML ()
 Stores the skin and all it's styles as xml. More...
 
 writeToXMLFile (string $path)
 
 addStyle (ilSkinStyle $style)
 
 removeStyle (string $id)
 
 getStyle (string $id)
 
 hasStyle (string $id)
 
 getDefaultStyle ()
 
 valid ()
 
 key ()
 
 current ()
 
 next ()
 
 rewind ()
 
 count ()
 
 getId ()
 
 setId (string $id)
 
 getName ()
 
 setName (string $name)
 
 getStyles ()
 
 setStyles (array $styles)
 
 getVersion ()
 
 setVersion (string $version)
 
 getVersionStep (string $version)
 
 isVersionChangeable ()
 
 updateParentStyleOfSubstyles (string $old_parent_style_id, string $new_parent_style_id)
 
 getSubstylesOfStyle (string $style_id)
 
 hasStyleSubstyles (string $style_id)
 Returns wheter a given style has substyles. More...
 
 hasStyles ()
 

Protected Member Functions

 addChildToXML (SimpleXMLElement $xml, ilSkinStyle $style)
 Used to generate the xml for styles contained by the skin. More...
 

Protected Attributes

string $id = ''
 ID of the skin, equals the name of the folder this skin is stored in. More...
 
string $name = ''
 Name of the skin, as provided in the template. More...
 
array $styles = []
 
string $version = '0.1'
 Version of skin, as provided by the template. More...
 

Detailed Description

ilSkin holds an manages the basic data of a skin as provide by the template of the skin.

This class is also responsible to read this data from the xml and, after manipulations transfer the data back to xml.

To read a skin from xml do not use this class, us ilSkinContainer instead.

Definition at line 27 of file class.ilSkin.php.

Constructor & Destructor Documentation

◆ __construct()

ilSkin::__construct ( string  $id,
string  $name 
)

Definition at line 52 of file class.ilSkin.php.

References setId(), and setName().

53  {
54  $this->setId($id);
55  $this->setName($name);
56  }
string $name
Name of the skin, as provided in the template.
string $id
ID of the skin, equals the name of the folder this skin is stored in.
setId(string $id)
setName(string $name)
+ Here is the call graph for this function:

Member Function Documentation

◆ addChildToXML()

ilSkin::addChildToXML ( SimpleXMLElement  $xml,
ilSkinStyle  $style 
)
protected

Used to generate the xml for styles contained by the skin.

Definition at line 87 of file class.ilSkin.php.

References ilSkinStyle\getCssFile(), ilSkinStyle\getFontDirectory(), ilSkinStyle\getId(), ilSkinStyle\getImageDirectory(), ilSkinStyle\getName(), ilSkinStyle\getSoundDirectory(), and ilSkinStyle\isSubstyle().

Referenced by asXML().

87  : void
88  {
89  if ($style->isSubstyle()) {
90  $xml_style = $xml->addChild('substyle');
91  } else {
92  $xml_style = $xml->addChild('style');
93  }
94  $xml_style->addAttribute('id', $style->getId());
95  $xml_style->addAttribute('name', $style->getName());
96  $xml_style->addAttribute('image_directory', $style->getImageDirectory());
97  $xml_style->addAttribute('css_file', $style->getCssFile());
98  $xml_style->addAttribute('sound_directory', $style->getSoundDirectory());
99  $xml_style->addAttribute('font_directory', $style->getFontDirectory());
100  }
$xml
Definition: metadata.php:351
isSubstyle()
Return wheter this style is a substyle of another.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addStyle()

ilSkin::addStyle ( ilSkinStyle  $style)

Definition at line 107 of file class.ilSkin.php.

107  : void
108  {
109  $this->styles[] = $style;
110  }

◆ asXML()

ilSkin::asXML ( )

Stores the skin and all it's styles as xml.

Definition at line 61 of file class.ilSkin.php.

References $xml, addChildToXML(), getName(), getStyles(), getSubstylesOfStyle(), and getVersion().

Referenced by ilSkinFactoryTest\testSkinFromXML(), and writeToXMLFile().

61  : string
62  {
63  $xml = new SimpleXMLElement("<?xml version='1.0' encoding='UTF-8'?><template/>");
64  $xml->addAttribute('xmlns', 'http://www.w3.org');
65  $xml->addAttribute('version', $this->getVersion());
66  $xml->addAttribute('name', $this->getName());
67 
68  foreach ($this->getStyles() as $style) {
69  if (!$style->isSubstyle()) {
70  $this->addChildToXML($xml, $style);
71 
72  foreach ($this->getSubstylesOfStyle($style->getId()) as $substyle) {
73  $this->addChildToXML($xml, $substyle);
74  }
75  }
76  }
77 
78  $dom = new DOMDocument('1.0', 'utf-8');
79  $dom->formatOutput = true;
80  $dom->loadXML($xml->asXML());
81  return $dom->saveXML();
82  }
getSubstylesOfStyle(string $style_id)
$xml
Definition: metadata.php:351
addChildToXML(SimpleXMLElement $xml, ilSkinStyle $style)
Used to generate the xml for styles contained by the skin.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ count()

ilSkin::count ( )

Definition at line 179 of file class.ilSkin.php.

Referenced by getVersionStep(), and hasStyles().

179  : int
180  {
181  return count($this->styles);
182  }
+ Here is the caller graph for this function:

◆ current()

ilSkin::current ( )

Definition at line 164 of file class.ilSkin.php.

Referenced by valid().

164  : ilSkinStyle
165  {
166  return current($this->styles);
167  }
+ Here is the caller graph for this function:

◆ getDefaultStyle()

ilSkin::getDefaultStyle ( )

Definition at line 149 of file class.ilSkin.php.

149  : ilSkinStyle
150  {
151  return array_values($this->styles)[0];
152  }

◆ getId()

ilSkin::getId ( )

◆ getName()

ilSkin::getName ( )

Definition at line 200 of file class.ilSkin.php.

References $name.

Referenced by ilSystemStyleDeleteGUI\addStyle(), asXML(), ilSkinFactoryTest\testCopySkin(), and ilSkinFactoryTest\testCopySkinWithInjectedName().

200  : string
201  {
202  return $this->name;
203  }
string $name
Name of the skin, as provided in the template.
+ Here is the caller graph for this function:

◆ getStyle()

ilSkin::getStyle ( string  $id)
Exceptions
ilSystemStyleException

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

References $id, getStyles(), and ilSystemStyleException\INVALID_ID.

Referenced by ilSubStyleAssignmentGUI\assignStyle(), ilSubStyleAssignmentGUI\deleteAssignments(), ilSubStyleAssignmentGUI\saveAssignment(), and ilSkinStyleContainerTest\testUpdateStyle().

129  : ilSkinStyle
130  {
131  foreach ($this->getStyles() as $style) {
132  if ($style->getId() == $id) {
133  return $style;
134  }
135  }
137  }
string $id
ID of the skin, equals the name of the folder this skin is stored in.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStyles()

ilSkin::getStyles ( )
Returns
ilSkinStyle[]

Definition at line 213 of file class.ilSkin.php.

References $styles.

Referenced by asXML(), getStyle(), getSubstylesOfStyle(), hasStyle(), hasStyles(), hasStyleSubstyles(), and removeStyle().

213  : array
214  {
215  return $this->styles;
216  }
array $styles
+ Here is the caller graph for this function:

◆ getSubstylesOfStyle()

ilSkin::getSubstylesOfStyle ( string  $style_id)
Returns
ilSkinStyle[]

Definition at line 266 of file class.ilSkin.php.

References getStyles().

Referenced by asXML(), and updateParentStyleOfSubstyles().

266  : array
267  {
268  $substyles = [];
269 
270  foreach ($this->getStyles() as $style) {
271  if ($style->getId() != $style_id && $style->isSubstyle()) {
272  if ($style->getSubstyleOf() == $style_id) {
273  $substyles[$style->getId()] = $style;
274  }
275  }
276  }
277 
278  return $substyles;
279  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVersion()

ilSkin::getVersion ( )

Definition at line 226 of file class.ilSkin.php.

References $version.

Referenced by asXML().

226  : string
227  {
228  return $this->version;
229  }
string $version
Version of skin, as provided by the template.
+ Here is the caller graph for this function:

◆ getVersionStep()

ilSkin::getVersionStep ( string  $version)

Definition at line 238 of file class.ilSkin.php.

References $version, count(), ILIAS\Repository\int(), and isVersionChangeable().

238  : string
239  {
240  if ($this->isVersionChangeable()) {
241  $v = explode('.', ($version == '' ? '0.1' : $version));
242  $count = count($v) ;
243  $v[$count - 1] = ((int) $v[$count - 1] + 1); //ToDo PHP8 Review: You are adding an int to a string in strict_types.
244  $this->version = implode('.', $v);
245  }
246  return $this->version;
247  }
string $version
Version of skin, as provided by the template.
isVersionChangeable()
+ Here is the call graph for this function:

◆ hasStyle()

ilSkin::hasStyle ( string  $id)

Definition at line 139 of file class.ilSkin.php.

References $id, and getStyles().

139  : bool
140  {
141  foreach ($this->getStyles() as $style) {
142  if ($style->getId() == $id) {
143  return true;
144  }
145  }
146  return false;
147  }
string $id
ID of the skin, equals the name of the folder this skin is stored in.
+ Here is the call graph for this function:

◆ hasStyles()

ilSkin::hasStyles ( )

Definition at line 296 of file class.ilSkin.php.

References count(), and getStyles().

296  : bool
297  {
298  return count($this->getStyles()) > 0;
299  }
+ Here is the call graph for this function:

◆ hasStyleSubstyles()

ilSkin::hasStyleSubstyles ( string  $style_id)

Returns wheter a given style has substyles.

Definition at line 284 of file class.ilSkin.php.

References getStyles().

Referenced by updateParentStyleOfSubstyles().

284  : bool
285  {
286  foreach ($this->getStyles() as $style) {
287  if ($style->getId() != $style_id && $style->isSubstyle()) {
288  if ($style->getSubstyleOf() == $style_id) {
289  return true;
290  }
291  }
292  }
293  return false;
294  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isVersionChangeable()

ilSkin::isVersionChangeable ( )

Definition at line 249 of file class.ilSkin.php.

Referenced by getVersionStep(), and setVersion().

249  : bool
250  {
251  return ($this->version != '$Id$');
252  }
+ Here is the caller graph for this function:

◆ key()

ilSkin::key ( )

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

159  : int
160  {
161  return key($this->styles);
162  }

◆ next()

ilSkin::next ( )

Definition at line 169 of file class.ilSkin.php.

169  : void
170  {
171  next($this->styles);
172  }

◆ removeStyle()

ilSkin::removeStyle ( string  $id)
Exceptions
ilSystemStyleException

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

References $id, $index, getStyles(), and ilSystemStyleException\INVALID_ID.

115  : void
116  {
117  foreach ($this->getStyles() as $index => $style) {
118  if ($style->getId() == $id) {
119  unset($this->styles[$index]);
120  return;
121  }
122  }
124  }
string $id
ID of the skin, equals the name of the folder this skin is stored in.
$index
Definition: metadata.php:145
+ Here is the call graph for this function:

◆ rewind()

ilSkin::rewind ( )

Definition at line 174 of file class.ilSkin.php.

174  : void
175  {
176  reset($this->styles);
177  }

◆ setId()

ilSkin::setId ( string  $id)
Exceptions
ilSystemStyleException

Definition at line 192 of file class.ilSkin.php.

References ilSystemStyleException\INVALID_CHARACTERS_IN_ID.

Referenced by __construct().

192  : void
193  {
194  if (strpos($id, ' ') !== false) {
196  }
197  $this->id = str_replace(' ', '_', $id);
198  }
string $id
ID of the skin, equals the name of the folder this skin is stored in.
+ Here is the caller graph for this function:

◆ setName()

ilSkin::setName ( string  $name)

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

References $name.

Referenced by __construct().

205  : void
206  {
207  $this->name = $name;
208  }
string $name
Name of the skin, as provided in the template.
+ Here is the caller graph for this function:

◆ setStyles()

ilSkin::setStyles ( array  $styles)
Parameters
ilSkinStyle[]$styles

Definition at line 221 of file class.ilSkin.php.

References $styles.

221  : void
222  {
223  $this->styles = $styles;
224  }
array $styles

◆ setVersion()

ilSkin::setVersion ( string  $version)

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

References $version, and isVersionChangeable().

Referenced by ilSkinFactory\__construct().

231  : void
232  {
233  if ($version != '' && $this->isVersionChangeable()) {
234  $this->version = $version;
235  }
236  }
string $version
Version of skin, as provided by the template.
isVersionChangeable()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateParentStyleOfSubstyles()

ilSkin::updateParentStyleOfSubstyles ( string  $old_parent_style_id,
string  $new_parent_style_id 
)

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

References getSubstylesOfStyle(), and hasStyleSubstyles().

254  : void
255  {
256  if ($this->hasStyleSubstyles($old_parent_style_id)) {
257  foreach ($this->getSubstylesOfStyle($old_parent_style_id) as $substyle) {
258  $substyle->setSubstyleOf($new_parent_style_id);
259  }
260  }
261  }
hasStyleSubstyles(string $style_id)
Returns wheter a given style has substyles.
getSubstylesOfStyle(string $style_id)
+ Here is the call graph for this function:

◆ valid()

ilSkin::valid ( )

Definition at line 154 of file class.ilSkin.php.

References current().

154  : bool
155  {
156  return current($this->styles) !== false;
157  }
+ Here is the call graph for this function:

◆ writeToXMLFile()

ilSkin::writeToXMLFile ( string  $path)

Definition at line 102 of file class.ilSkin.php.

References asXML().

102  : void
103  {
104  file_put_contents($path, $this->asXML());
105  }
asXML()
Stores the skin and all it&#39;s styles as xml.
$path
Definition: ltiservices.php:32
+ Here is the call graph for this function:

Field Documentation

◆ $id

string ilSkin::$id = ''
protected

ID of the skin, equals the name of the folder this skin is stored in.

Definition at line 32 of file class.ilSkin.php.

Referenced by getId(), getStyle(), hasStyle(), and removeStyle().

◆ $name

string ilSkin::$name = ''
protected

Name of the skin, as provided in the template.

Definition at line 38 of file class.ilSkin.php.

Referenced by getName(), and setName().

◆ $styles

array ilSkin::$styles = []
protected

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

Referenced by getStyles(), and setStyles().

◆ $version

string ilSkin::$version = '0.1'
protected

Version of skin, as provided by the template.

Definition at line 50 of file class.ilSkin.php.

Referenced by getVersion(), getVersionStep(), and setVersion().


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