ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSkinXML Class Reference

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

+ Inheritance diagram for ilSkinXML:
+ Collaboration diagram for ilSkinXML:

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

 $id = ""
 
 $name = ""
 
 $styles = array()
 
 $version = "0.1"
 

Detailed Description

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

Author
Timon Amstutz timon.nosp@m..ams.nosp@m.tutz@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$*

Definition at line 14 of file class.ilSkinXML.php.

Constructor & Destructor Documentation

◆ __construct()

ilSkinXML::__construct (   $id,
  $name 
)

ilSkinXML constructor.

Parameters
string$name

Definition at line 49 of file class.ilSkinXML.php.

50 {
51 $this->setId($id);
52 $this->setName($name);
53 }

References $id, $name, setId(), and setName().

+ Here is the call graph for this function:

Member Function Documentation

◆ addChildToXML()

ilSkinXML::addChildToXML ( SimpleXMLElement  $xml,
ilSkinStyleXML  $style 
)
protected

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

Parameters
SimpleXMLElement$xml
ilSkinStyleXML$style

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

134 {
135 $xml_style = null;
136 if ($style->isSubstyle()) {
137 $xml_style = $xml->addChild("substyle");
138 } else {
139 $xml_style = $xml->addChild("style");
140 }
141 $xml_style->addAttribute("id", $style->getId());
142 $xml_style->addAttribute("name", $style->getName());
143 $xml_style->addAttribute("image_directory", $style->getImageDirectory());
144 $xml_style->addAttribute("css_file", $style->getCssFile());
145 $xml_style->addAttribute("sound_directory", $style->getSoundDirectory());
146 $xml_style->addAttribute("font_directory", $style->getFontDirectory());
147 }
$style
Definition: example_012.php:70

References $style, and $xml.

Referenced by asXML().

+ Here is the caller graph for this function:

◆ addStyle()

ilSkinXML::addStyle ( ilSkinStyleXML  $style)
Parameters
ilSkinStyleXML$style

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

160 {
161 $this->styles[] = $style;
162 }

References $style.

◆ asXML()

ilSkinXML::asXML ( )

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

Returns
string

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

103 {
104 $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><template/>');
105 $xml->addAttribute("xmlns", "http://www.w3.org");
106 $xml->addAttribute("version", $this->getVersion());
107 $xml->addAttribute("name", $this->getName());
108
109 $last_style = null;
110
111 foreach ($this->getStyles() as $style) {
112 if (!$style->isSubstyle()) {
113 $this->addChildToXML($xml, $style);
114
115 foreach ($this->getSubstylesOfStyle($style->getId()) as $substyle) {
116 $this->addChildToXML($xml, $substyle);
117 }
118 }
119 }
120
121 $dom = new DOMDocument('1.0', 'utf-8');
122 $dom->formatOutput = true;
123 $dom->loadXML($xml->asXML());
124 return $dom->saveXML();
125 }
getSubstylesOfStyle($style_id)
addChildToXML(SimpleXMLElement $xml, ilSkinStyleXML $style)
Used to generate the xml for styles contained by the skin.

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

Referenced by writeToXMLFile().

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

◆ count()

ilSkinXML::count ( )

Countable implementations.

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

255 {
256 return count($this->styles);
257 }
count()
Countable implementations.

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

ilSkinXML::current ( )
Returns
mixed

Definition at line 237 of file class.ilSkinXML.php.

238 {
239 return current($this->styles);
240 }

References current().

Referenced by current(), and valid().

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

◆ getDefaultStyle()

ilSkinXML::getDefaultStyle ( )
Returns
ilSkinStyleXML

Definition at line 211 of file class.ilSkinXML.php.

212 {
213 return array_values($this->styles)[0];
214 }

◆ getId()

ilSkinXML::getId ( )
Returns
string

Definition at line 262 of file class.ilSkinXML.php.

263 {
264 return $this->id;
265 }

References $id.

Referenced by ilSystemStyleDeleteGUI\addStyle(), ilSubStyleAssignmentGUI\assignStyle(), ilSubStyleAssignmentGUI\deleteAssignments(), ilSubStyleAssignmentGUI\saveAssignment(), and ilSystemStyleSkinContainer\updateSkin().

+ Here is the caller graph for this function:

◆ getName()

ilSkinXML::getName ( )
Returns
string

Definition at line 283 of file class.ilSkinXML.php.

284 {
285 return $this->name;
286 }

References $name.

Referenced by ilSystemStyleDeleteGUI\addStyle(), and asXML().

+ Here is the caller graph for this function:

◆ getStyle()

ilSkinXML::getStyle (   $id)
Parameters
$id
Returns
ilSkinStyleXML
Exceptions
ilSystemStyleException

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

185 {
186 foreach ($this->getStyles() as $style) {
187 if ($style->getId() == $id) {
188 return $style;
189 }
190 }
192 }
Class for advanced editing exception handling in ILIAS.

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

Referenced by ilSubStyleAssignmentGUI\assignStyle(), ilSubStyleAssignmentGUI\deleteAssignments(), getSubstylesOfStyle(), hasStyleSubstyles(), and ilSubStyleAssignmentGUI\saveAssignment().

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

◆ getStyles()

ilSkinXML::getStyles ( )
Returns
ilSkinStyleXML[]

Definition at line 299 of file class.ilSkinXML.php.

300 {
301 return $this->styles;
302 }

References $styles.

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

+ Here is the caller graph for this function:

◆ getSubstylesOfStyle()

ilSkinXML::getSubstylesOfStyle (   $style_id)
Parameters
$style_id
Returns
array

Definition at line 352 of file class.ilSkinXML.php.

353 {
354 $substyles = array();
355
356 if ($this->getStyle($style_id)) {
357 foreach ($this->getStyles() as $style) {
358 if ($style->getId() != $style_id && $style->isSubstyle()) {
359 if ($style->getSubstyleOf() == $style_id) {
360 $substyles[$style->getId()] = $style;
361 }
362 }
363 }
364 }
365 return $substyles;
366 }

References $style, getStyle(), and getStyles().

Referenced by asXML().

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

◆ getVersion()

ilSkinXML::getVersion ( )
Returns
string

Definition at line 315 of file class.ilSkinXML.php.

316 {
317 return $this->version;
318 }

References $version.

Referenced by asXML().

+ Here is the caller graph for this function:

◆ getVersionStep()

ilSkinXML::getVersionStep (   $version)
Returns
string

Definition at line 333 of file class.ilSkinXML.php.

334 {
335 if ($this->isVersionChangeable()) {
336 $v = explode('.', ($version == "" ? '0.1' : $version));
337 $v[count($v) - 1] = ($v[count($v) - 1] + 1);
338 $this->version = implode('.', $v);
339 }
340 return $this->version;
341 }

References $version, count(), and isVersionChangeable().

+ Here is the call graph for this function:

◆ hasStyle()

ilSkinXML::hasStyle (   $id)
Parameters
$id
Returns
bool

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

199 {
200 foreach ($this->getStyles() as $style) {
201 if ($style->getId() == $id) {
202 return true;
203 }
204 }
205 return false;
206 }

References $id, $style, and getStyles().

+ Here is the call graph for this function:

◆ hasStyles()

ilSkinXML::hasStyles ( )
Returns
bool

Definition at line 390 of file class.ilSkinXML.php.

391 {
392 return count($this->getStyles()) > 0;
393 }

References count(), and getStyles().

+ Here is the call graph for this function:

◆ hasStyleSubstyles()

ilSkinXML::hasStyleSubstyles (   $style_id)

Returns wheter a given style has substyles.

Parameters
$style_id
Returns
bool

Definition at line 373 of file class.ilSkinXML.php.

374 {
375 if ($this->getStyle($style_id)) {
376 foreach ($this->getStyles() as $style) {
377 if ($style->getId() != $style_id && $style->isSubstyle()) {
378 if ($style->getSubstyleOf() == $style_id) {
379 return true;
380 }
381 }
382 }
383 }
384 return false;
385 }

References $style, getStyle(), and getStyles().

+ Here is the call graph for this function:

◆ isVersionChangeable()

ilSkinXML::isVersionChangeable ( )

Definition at line 343 of file class.ilSkinXML.php.

344 {
345 return ($this->version != '$Id$');
346 }

Referenced by getVersionStep(), and setVersion().

+ Here is the caller graph for this function:

◆ key()

ilSkinXML::key ( )
Returns
mixed

Definition at line 229 of file class.ilSkinXML.php.

230 {
231 return key($this->styles);
232 }

References key().

Referenced by key().

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

◆ next()

ilSkinXML::next ( )

Definition at line 242 of file class.ilSkinXML.php.

243 {
244 next($this->styles);
245 }

References next().

Referenced by next().

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

◆ removeStyle()

ilSkinXML::removeStyle (   $id)
Parameters
$id
Exceptions
ilSystemStyleException

Definition at line 168 of file class.ilSkinXML.php.

169 {
170 foreach ($this->getStyles() as $index => $style) {
171 if ($style->getId() == $id) {
172 unset($this->styles[$index]);
173 return;
174 }
175 }
177 }
$index
Definition: metadata.php:60

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

+ Here is the call graph for this function:

◆ rewind()

ilSkinXML::rewind ( )

Definition at line 246 of file class.ilSkinXML.php.

247 {
248 reset($this->styles);
249 }

◆ setId()

ilSkinXML::setId (   $id)
Parameters
$id
Exceptions
ilSystemStyleException

Definition at line 271 of file class.ilSkinXML.php.

272 {
273 if (strpos($id, ' ') !== false) {
275 }
276 $this->id = str_replace(" ", "_", $id);
277 }

References $id, and ilSystemStyleException\INVALID_CHARACTERS_IN_ID.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setName()

ilSkinXML::setName (   $name)
Parameters
string$name

Definition at line 291 of file class.ilSkinXML.php.

292 {
293 $this->name = $name;
294 }

References $name.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setStyles()

ilSkinXML::setStyles (   $styles)
Parameters
ilSkinStyleXML[]$styles

Definition at line 307 of file class.ilSkinXML.php.

308 {
309 $this->styles = $styles;
310 }

References $styles.

◆ setVersion()

ilSkinXML::setVersion (   $version)
Parameters
string$version

Definition at line 323 of file class.ilSkinXML.php.

324 {
325 if ($version != null && $version != '' && $this->isVersionChangeable()) {
326 $this->version = $version;
327 }
328 }

References $version, and isVersionChangeable().

+ Here is the call graph for this function:

◆ valid()

ilSkinXML::valid ( )

Iterator implementations.

Returns
bool

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

222 {
223 return current($this->styles) !== false;
224 }

References current().

+ Here is the call graph for this function:

◆ writeToXMLFile()

ilSkinXML::writeToXMLFile (   $path)
Parameters
$path

Definition at line 152 of file class.ilSkinXML.php.

153 {
154 file_put_contents($path, $this->asXML());
155 }
$path
Definition: aliased.php:25
asXML()
Stores the skin and all it's styles as xml.

References $path, and asXML().

+ Here is the call graph for this function:

Field Documentation

◆ $id

ilSkinXML::$id = ""
protected

Definition at line 21 of file class.ilSkinXML.php.

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

◆ $name

ilSkinXML::$name = ""
protected

Definition at line 28 of file class.ilSkinXML.php.

Referenced by __construct(), getName(), and setName().

◆ $styles

ilSkinXML::$styles = array()
protected

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

Referenced by getStyles(), and setStyles().

◆ $version

ilSkinXML::$version = "0.1"
protected

Definition at line 42 of file class.ilSkinXML.php.

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


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