ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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

References setId(), and setName().

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

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 }
isSubstyle()
Return wheter this style is a substyle of another.

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

Referenced by asXML().

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

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 }
addChildToXML(SimpleXMLElement $xml, ilSkinStyle $style)
Used to generate the xml for styles contained by the skin.
getSubstylesOfStyle(string $style_id)

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

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

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

179 : int
180 {
181 return count($this->styles);
182 }

References count().

Referenced by count(), getVersionStep(), and hasStyles().

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

◆ current()

ilSkin::current ( )

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

165 {
166 return current($this->styles);
167 }

References current().

Referenced by current(), and valid().

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

◆ getDefaultStyle()

ilSkin::getDefaultStyle ( )

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

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

◆ getId()

ilSkin::getId ( )

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

184 : string
185 {
186 return $this->id;
187 }

References $id.

Referenced by ilSubStyleAssignmentGUI\assignStyle(), ilSubStyleAssignmentGUI\deleteAssignments(), ilStyleDefinition\getAllSkinStyles(), and ilSubStyleAssignmentGUI\saveAssignment().

+ Here is the caller graph for this function:

◆ getName()

ilSkin::getName ( )

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

200 : string
201 {
202 return $this->name;
203 }

References $name.

Referenced by asXML(), and ilStyleDefinition\getAllSkinStyles().

+ Here is the caller graph for this function:

◆ getStyle()

ilSkin::getStyle ( string  $id)
Exceptions
ilSystemStyleException

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

130 {
131 foreach ($this->getStyles() as $style) {
132 if ($style->getId() == $id) {
133 return $style;
134 }
135 }
137 }
Class for advanced editing exception handling in ILIAS.

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

Referenced by ilSubStyleAssignmentGUI\assignStyle(), ilSubStyleAssignmentGUI\deleteAssignments(), ilStyleDefinition\getAllSkinStyles(), and ilSubStyleAssignmentGUI\saveAssignment().

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

213 : array
214 {
215 return $this->styles;
216 }
array $styles

References $styles.

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

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

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 }

References getStyles().

Referenced by asXML(), and updateParentStyleOfSubstyles().

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

226 : string
227 {
228 return $this->version;
229 }
string $version
Version of skin, as provided by the template.

References $version.

Referenced by asXML(), and ilStyleDefinition\getAllSkinStyles().

+ Here is the caller graph for this function:

◆ getVersionStep()

ilSkin::getVersionStep ( string  $version)

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

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 }
isVersionChangeable()

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

+ Here is the call graph for this function:

◆ hasStyle()

ilSkin::hasStyle ( string  $id)

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

139 : bool
140 {
141 foreach ($this->getStyles() as $style) {
142 if ($style->getId() == $id) {
143 return true;
144 }
145 }
146 return false;
147 }

References $id, and getStyles().

Referenced by ilStyleDefinition\styleExists(), and ilStyleDefinition\styleExistsForSkinId().

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

◆ hasStyles()

ilSkin::hasStyles ( )

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

296 : bool
297 {
298 return count($this->getStyles()) > 0;
299 }

References count(), and getStyles().

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

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 }

References getStyles().

Referenced by updateParentStyleOfSubstyles().

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

249 : bool
250 {
251 return ($this->version != '$Id$');
252 }

Referenced by getVersionStep(), and setVersion().

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

References key().

Referenced by key().

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

◆ next()

ilSkin::next ( )

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

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

References next().

Referenced by next().

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

◆ removeStyle()

ilSkin::removeStyle ( string  $id)
Exceptions
ilSystemStyleException

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

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 }

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

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

192 : void
193 {
194 if (strpos($id, ' ') !== false) {
196 }
197 $this->id = str_replace(' ', '_', $id);
198 }

References $id, and ilSystemStyleException\INVALID_CHARACTERS_IN_ID.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setName()

ilSkin::setName ( string  $name)

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

205 : void
206 {
207 $this->name = $name;
208 }

References $name.

Referenced by __construct().

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

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

References $styles.

◆ setVersion()

ilSkin::setVersion ( string  $version)

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

231 : void
232 {
233 if ($version != '' && $this->isVersionChangeable()) {
234 $this->version = $version;
235 }
236 }

References $version, and isVersionChangeable().

+ Here is the call 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.

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.

References getSubstylesOfStyle(), and hasStyleSubstyles().

+ Here is the call graph for this function:

◆ valid()

ilSkin::valid ( )

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

154 : bool
155 {
156 return current($this->styles) !== false;
157 }

References current().

+ Here is the call graph for this function:

◆ writeToXMLFile()

ilSkin::writeToXMLFile ( string  $path)

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

102 : void
103 {
104 file_put_contents($path, $this->asXML());
105 }
asXML()
Stores the skin and all it's styles as xml.
$path
Definition: ltiservices.php:30

References $path, and asXML().

+ 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(), removeStyle(), and setId().

◆ $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: