2include_once(
"Services/Style/System/classes/Exceptions/class.ilSystemStyleException.php");
3include_once(
"Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php");
60 public static function parseFromXML(
$path =
"")
63 $xml =
new SimpleXMLElement(file_get_contents(
$path));
64 }
catch (Exception $e) {
69 $skin =
new self(
$id, (string)
$xml->attributes()[
"name"]);
70 $skin->setVersion((
string)
$xml->attributes()[
"version"]);
78 foreach (
$xml->children() as $style_xml) {
84 if ($style_xml->getName() ==
"substyle") {
88 $style->setSubstyleOf($last_style->getId());
104 $xml =
new SimpleXMLElement(
'<?xml version="1.0" encoding="UTF-8"?><template/>');
105 $xml->addAttribute(
"xmlns",
"http://www.w3.org");
112 if (!
$style->isSubstyle()) {
121 $dom =
new DOMDocument(
'1.0',
'utf-8');
122 $dom->formatOutput =
true;
123 $dom->loadXML(
$xml->asXML());
124 return $dom->saveXML();
136 if (
$style->isSubstyle()) {
137 $xml_style =
$xml->addChild(
"substyle");
139 $xml_style =
$xml->addChild(
"style");
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());
172 unset($this->styles[
$index]);
213 return array_values($this->styles)[0];
223 return current($this->styles) !==
false;
231 return key($this->styles);
248 reset($this->styles);
256 return count($this->styles);
273 if (strpos(
$id,
' ') !==
false) {
276 $this->
id = str_replace(
" ",
"_",
$id);
338 $this->version = implode(
'.', $v);
345 return ($this->version !=
'$Id$');
354 $substyles = array();
358 if (
$style->getId() != $style_id &&
$style->isSubstyle()) {
359 if (
$style->getSubstyleOf() == $style_id) {
377 if (
$style->getId() != $style_id &&
$style->isSubstyle()) {
378 if (
$style->getSubstyleOf() == $style_id) {
An exception for terminatinating execution or to throw for unit testing.
static parseFromXMLElement(SimpleXMLElement $xml_element)
ilSkinXml holds an manages the basic data of a skin as provide by the template of the skin.
asXML()
Stores the skin and all it's styles as xml.
valid()
Iterator implementations.
hasStyleSubstyles($style_id)
Returns wheter a given style has substyles.
getSubstylesOfStyle($style_id)
addChildToXML(SimpleXMLElement $xml, ilSkinStyleXML $style)
Used to generate the xml for styles contained by the skin.
__construct($id, $name)
ilSkinXML constructor.
addStyle(ilSkinStyleXML $style)
count()
Countable implementations.
Class for advanced editing exception handling in ILIAS.
const INVALID_CHARACTERS_IN_ID
const FILE_OPENING_FAILED