ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

References $id, $name, $path, $style, $xml, ilSystemStyleException\FILE_OPENING_FAILED, ilSystemStyleException\NO_PARENT_STYLE, ilSkinStyleXML\parseFromXMLElement(), setId(), setName(), and string.

50  {
51  $this->setId($id);
52  $this->setName($name);
53  }
+ 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.

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

Referenced by asXML().

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  }
isSubstyle()
Return wheter this style is a substyle of another.
$xml
Definition: metadata.php:240
+ Here is the call graph for this function:
+ 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.

References $style.

160  {
161  $this->styles[] = $style;
162  }
$style
Definition: example_012.php:70

◆ asXML()

ilSkinXML::asXML ( )

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

Returns
string

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

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

Referenced by writeToXMLFile().

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  }
$style
Definition: example_012.php:70
getSubstylesOfStyle($style_id)
$xml
Definition: metadata.php:240
addChildToXML(SimpleXMLElement $xml, ilSkinStyleXML $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()

ilSkinXML::count ( )

Countable implementations.

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

Referenced by getVersionStep(), and hasStyles().

255  {
256  return count($this->styles);
257  }
count()
Countable implementations.
+ Here is the caller graph for this function:

◆ current()

ilSkinXML::current ( )
Returns
mixed

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

Referenced by valid().

238  {
239  return current($this->styles);
240  }
+ 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.

References $id.

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

263  {
264  return $this->id;
265  }
+ Here is the caller graph for this function:

◆ getName()

ilSkinXML::getName ( )
Returns
string

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

References $name.

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

284  {
285  return $this->name;
286  }
+ 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.

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

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

185  {
186  foreach ($this->getStyles() as $style) {
187  if ($style->getId() == $id) {
188  return $style;
189  }
190  }
192  }
$style
Definition: example_012.php:70
Class for advanced editing exception handling in ILIAS.
+ 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.

References $styles.

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

300  {
301  return $this->styles;
302  }
+ 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.

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

Referenced by asXML().

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  }
$style
Definition: example_012.php:70
Create styles array
The data for the language used.
+ 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.

References $version.

Referenced by asXML().

316  {
317  return $this->version;
318  }
+ Here is the caller graph for this function:

◆ getVersionStep()

ilSkinXML::getVersionStep (   $version)
Returns
string

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

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

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  }
count()
Countable implementations.
+ 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.

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

199  {
200  foreach ($this->getStyles() as $style) {
201  if ($style->getId() == $id) {
202  return true;
203  }
204  }
205  return false;
206  }
$style
Definition: example_012.php:70
+ Here is the call graph for this function:

◆ hasStyles()

ilSkinXML::hasStyles ( )
Returns
bool

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

References count(), and getStyles().

391  {
392  return count($this->getStyles()) > 0;
393  }
count()
Countable implementations.
+ 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.

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

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  }
$style
Definition: example_012.php:70
+ Here is the call graph for this function:

◆ isVersionChangeable()

ilSkinXML::isVersionChangeable ( )

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

Referenced by getVersionStep(), and setVersion().

344  {
345  return ($this->version != '$Id$');
346  }
+ 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  }

◆ next()

ilSkinXML::next ( )

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

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

◆ removeStyle()

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

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

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

169  {
170  foreach ($this->getStyles() as $index => $style) {
171  if ($style->getId() == $id) {
172  unset($this->styles[$index]);
173  return;
174  }
175  }
177  }
$style
Definition: example_012.php:70
$index
Definition: metadata.php:60
Class for advanced editing exception handling in ILIAS.
+ 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.

References $id, and ilSystemStyleException\INVALID_CHARACTERS_IN_ID.

Referenced by __construct().

272  {
273  if (strpos($id, ' ') !== false) {
275  }
276  $this->id = str_replace(" ", "_", $id);
277  }
Class for advanced editing exception handling in ILIAS.
+ Here is the caller graph for this function:

◆ setName()

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

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

References $name.

Referenced by __construct().

292  {
293  $this->name = $name;
294  }
+ Here is the caller graph for this function:

◆ setStyles()

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

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

References $styles.

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

◆ setVersion()

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

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

References $version, and isVersionChangeable().

324  {
325  if ($version != null && $version != '' && $this->isVersionChangeable()) {
326  $this->version = $version;
327  }
328  }
+ Here is the call graph for this function:

◆ valid()

ilSkinXML::valid ( )

Iterator implementations.

Returns
bool

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

References current().

222  {
223  return current($this->styles) !== false;
224  }
+ Here is the call graph for this function:

◆ writeToXMLFile()

ilSkinXML::writeToXMLFile (   $path)
Parameters
$path

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

References $path, and asXML().

153  {
154  file_put_contents($path, $this->asXML());
155  }
asXML()
Stores the skin and all it&#39;s styles as xml.
+ 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: