ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 48 of file class.ilSkinXML.php.

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

49  {
50  $this->setId($id);
51  $this->setName($name);
52  }
+ 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 132 of file class.ilSkinXML.php.

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

Referenced by asXML().

132  {
133  $xml_style = null;
134  if($style->isSubstyle()){
135  $xml_style = $xml->addChild("substyle");
136  }
137  else{
138  $xml_style = $xml->addChild("style");
139  }
140  $xml_style->addAttribute("id", $style->getId());
141  $xml_style->addAttribute("name", $style->getName());
142  $xml_style->addAttribute("image_directory", $style->getImageDirectory());
143  $xml_style->addAttribute("css_file", $style->getCssFile());
144  $xml_style->addAttribute("sound_directory", $style->getSoundDirectory());
145  $xml_style->addAttribute("font_directory", $style->getFontDirectory());
146  }
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()

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

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

References $style.

157  {
158  $this->styles[] = $style;
159  }
$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, addChildToXML(), getName(), getStyles(), getSubstylesOfStyle(), and getVersion().

Referenced by writeToXMLFile().

102  {
103  $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><template/>');
104  $xml->addAttribute("xmlns","http://www.w3.org");
105  $xml->addAttribute("version",$this->getVersion());
106  $xml->addAttribute("name",$this->getName());
107 
108  $last_style = null;
109 
110  foreach($this->getStyles() as $style){
111  if(!$style->isSubstyle()){
112  $this->addChildToXML($xml, $style);
113 
114  foreach($this->getSubstylesOfStyle($style->getId()) as $substyle){
115  $this->addChildToXML($xml, $substyle);
116  }
117  }
118  }
119 
120  $dom = new DOMDocument('1.0', 'utf-8');
121  $dom->formatOutput = true;
122  $dom->loadXML($xml->asXML());
123  return $dom->saveXML();
124  }
$style
Definition: example_012.php:70
getSubstylesOfStyle($style_id)
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 242 of file class.ilSkinXML.php.

Referenced by getVersionStep(), and hasStyles().

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

◆ current()

ilSkinXML::current ( )
Returns
mixed

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

Referenced by valid().

228  {
229  return current($this->styles);
230  }
+ Here is the caller graph for this function:

◆ getDefaultStyle()

ilSkinXML::getDefaultStyle ( )
Returns
ilSkinStyleXML

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

205  {
206  return array_values($this->styles)[0];
207  }

◆ getId()

ilSkinXML::getId ( )
Returns
string

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

References $id.

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

250  {
251  return $this->id;
252  }
+ Here is the caller graph for this function:

◆ getName()

ilSkinXML::getName ( )
Returns
string

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

References $name.

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

271  {
272  return $this->name;
273  }
+ Here is the caller graph for this function:

◆ getStyle()

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

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

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

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

180  {
181  foreach($this->getStyles() as $style){
182  if($style->getId() == $id){
183  return $style;
184  }
185  }
187  }
$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 286 of file class.ilSkinXML.php.

References $styles.

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

287  {
288  return $this->styles;
289  }
+ Here is the caller graph for this function:

◆ getSubstylesOfStyle()

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

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

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

Referenced by asXML().

339  {
340  $substyles = array();
341 
342  if($this->getStyle($style_id)){
343  foreach($this->getStyles() as $style){
344  if($style->getId() != $style_id && $style->isSubstyle()){
345  if($style->getSubstyleOf() == $style_id){
346  $substyles[$style->getId()] = $style;
347  }
348  }
349  }
350  }
351  return $substyles;
352  }
$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 302 of file class.ilSkinXML.php.

References $version.

Referenced by asXML().

303  {
304  return $this->version;
305  }
+ Here is the caller graph for this function:

◆ getVersionStep()

ilSkinXML::getVersionStep (   $version)
Returns
string

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

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

321  {
322  if($this->isVersionChangeable()) {
323  $v = explode('.', ($version == "" ? '0.1' : $version));
324  $v[count($v) - 1] = ($v[count($v) - 1] + 1);
325  $this->version = implode('.', $v);
326  }
327  return $this->version;
328  }
count()
Countable implementations.
+ Here is the call graph for this function:

◆ hasStyle()

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

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

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

193  {
194  foreach($this->getStyles() as $style){
195  if($style->getId() == $id){
196  return true;
197  }
198  }
199  return false;
200  }
$style
Definition: example_012.php:70
+ Here is the call graph for this function:

◆ hasStyles()

ilSkinXML::hasStyles ( )
Returns
bool

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

References count(), and getStyles().

376  {
377  return count($this->getStyles()) > 0;
378  }
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 359 of file class.ilSkinXML.php.

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

359  {
360  if($this->getStyle($style_id)){
361  foreach($this->getStyles() as $style){
362  if($style->getId() != $style_id && $style->isSubstyle()){
363  if($style->getSubstyleOf() == $style_id){
364  return true;
365  }
366  }
367  }
368  }
369  return false;
370 
371  }
$style
Definition: example_012.php:70
+ Here is the call graph for this function:

◆ isVersionChangeable()

ilSkinXML::isVersionChangeable ( )

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

Referenced by getVersionStep(), and setVersion().

331  {
332  return ($this->version != '$Id$');
333  }
+ Here is the caller graph for this function:

◆ key()

ilSkinXML::key ( )
Returns
mixed

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

221  {
222  return key($this->styles);
223  }

◆ next()

ilSkinXML::next ( )

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

232  {
233  next($this->styles);
234  }

◆ removeStyle()

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

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

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

165  {
166  foreach($this->getStyles() as $index => $style){
167  if($style->getId() == $id){
168  unset($this->styles[$index]);
169  return;
170  }
171  }
173  }
$style
Definition: example_012.php:70
Class for advanced editing exception handling in ILIAS.
+ Here is the call graph for this function:

◆ rewind()

ilSkinXML::rewind ( )

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

235  {
236  reset($this->styles);
237  }

◆ setId()

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

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

References $id, and ilSystemStyleException\INVALID_CHARACTERS_IN_ID.

Referenced by __construct().

259  {
260  if (strpos($id, ' ') !== false) {
262  }
263  $this->id = str_replace(" ","_",$id);
264  }
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 278 of file class.ilSkinXML.php.

References $name.

Referenced by __construct().

279  {
280  $this->name = $name;
281  }
+ Here is the caller graph for this function:

◆ setStyles()

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

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

References $styles.

295  {
296  $this->styles = $styles;
297  }

◆ setVersion()

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

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

References $version, and isVersionChangeable().

311  {
312  if($version != null && $version != '' && $this->isVersionChangeable()) {
313  $this->version = $version;
314  }
315  }
+ Here is the call graph for this function:

◆ valid()

ilSkinXML::valid ( )

Iterator implementations.

Returns
bool

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

References current().

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

◆ writeToXMLFile()

ilSkinXML::writeToXMLFile (   $path)
Parameters
$path

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

References $path, and asXML().

151  {
152  file_put_contents($path, $this->asXML());
153  }
$path
Definition: aliased.php:25
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 20 of file class.ilSkinXML.php.

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

◆ $name

ilSkinXML::$name = ""
protected

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

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

◆ $styles

ilSkinXML::$styles = array()
protected

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

Referenced by getStyles(), and setStyles().

◆ $version

ilSkinXML::$version = "0.1"
protected

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

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


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