ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSkinFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
21
26{
28 protected Language $lng;
29
31 {
32 $this->lng = $lng;
33
34 if ($config) {
35 $this->config = $config;
36 } else {
37 $this->config = new ilSystemStyleConfig();
38 }
39 }
40
45 public function skinFromXML(string $path = ''): ilSkin
46 {
47 if (strpos($path, '../') === 0) { // we must resolve relative paths here
48 $path = realpath(__DIR__ . '/../../../../../../templates/' . $path);
49 }
50
51 try {
52 $xml = new SimpleXMLElement(file_get_contents($path));
53 } catch (Exception) {
55 }
56
57 $id = basename(dirname($path));
58 $skin = new ilSkin($id, (string) $xml->attributes()['name']);
59 $skin->setVersion((string) $xml->attributes()['version']);
60
64 $last_style = null;
65
66 foreach ($xml->children() as $style_xml) {
67 $style = ilSkinStyle::parseFromXMLElement($style_xml);
68
72 if ($style_xml->getName() == 'substyle') {
73 if (!$last_style) {
75 }
76 $style->setSubstyleOf($last_style->getId());
77 } else {
78 $last_style = $style;
79 }
80 $skin->addStyle($style);
81 }
82 return $skin;
83 }
84
90 public function skinStyleContainerFromId(
91 string $skin_id,
92 ilSystemStyleMessageStack $message_stack
94 if (!$skin_id) {
96 }
97
98 if ($skin_id != 'default' && $skin_id != 'other') {
99 return new ilSkinStyleContainer(
100 $this->lng,
101 $this->skinFromXML($this->config->getCustomizingSkinPath() . $skin_id . '/template.xml'),
102 $message_stack,
103 $this->config
104 );
105 } else {
106 return new ilSkinStyleContainer(
107 $this->lng,
108 $this->skinFromXML($this->config->getDefaultTemplatePath()),
109 $message_stack,
110 $this->config,
111 );
112 }
113 }
114}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Factory to create Skin classes holds an manages the basic data of a skin as provide by the template o...
__construct(Language $lng, ?ilSystemStyleConfig $config=null)
skinStyleContainerFromId(string $skin_id, ilSystemStyleMessageStack $message_stack)
Get container class is responsible for all file system related actions related actions of a skin such...
ilSystemStyleConfig $config
This class is responsible for all file system related actions related actions of a skin such as copyi...
static parseFromXMLElement(SimpleXMLElement $xml_element)
ilSkin holds an manages the basic data of a skin as provide by the template of the skin.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Class for advanced editing exception handling in ILIAS.
Used to stack messages to be shown to the user.
$path
Definition: ltiservices.php:30
if(!file_exists('../ilias.ini.php'))