ILIAS  release_8 Revision v8.24
class.ilSkinStyle.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
26 protected string $id = '';
27
31 protected string $name = '';
32
36 protected string $sound_directory = '';
37
41 protected string $image_directory = '';
42
46 protected string $font_directory = '';
47
51 protected string $css_file = '';
52
56 protected string $substyle_of = '';
57
58 public function __construct(
59 string $id,
60 string $name,
61 string $css_file = '',
62 string $image_directory = '',
63 string $font_directory = '',
64 string $sound_directory = '',
65 string $parent_style = ''
66 ) {
67 $this->setId($id);
68 $this->setName($name);
69
70 if ($css_file == '') {
71 $css_file = $this->getId();
72 }
73
74 if ($image_directory == '') {
75 $image_directory = 'images';
76 }
77
78 if ($font_directory == '') {
79 $font_directory = 'fonts';
80 }
81
82 if ($sound_directory == '') {
83 $sound_directory = 'sound';
84 }
85
86 $this->setCssFile($css_file);
87 $this->setImageDirectory($image_directory);
88 $this->setFontDirectory($font_directory);
89 $this->setSoundDirectory($sound_directory);
90 $this->setSubstyleOf($parent_style);
91 }
92
96 public static function parseFromXMLElement(SimpleXMLElement $xml_element): ilSkinStyle
97 {
98 return new self(
99 (string) $xml_element->attributes()['id'],
100 (string) $xml_element->attributes()['name'],
101 (string) $xml_element->attributes()['css_file'],
102 (string) $xml_element->attributes()['image_directory'],
103 (string) $xml_element->attributes()['font_directory'],
104 (string) $xml_element->attributes()['sound_directory']
105 );
106 }
107
108 public function getId(): string
109 {
110 return $this->id;
111 }
112
116 public function setId(string $id): void
117 {
118 if (strpos($id, ' ') !== false) {
120 }
121 $this->id = str_replace(' ', '_', $id);
122 }
123
124 public function getName(): string
125 {
126 return $this->name;
127 }
128
129 public function setName(string $name): void
130 {
131 $this->name = $name;
132 }
133
134 public function getSoundDirectory(): string
135 {
137 }
138
139 public function setSoundDirectory(string $sound_directory): void
140 {
141 $this->sound_directory = $sound_directory;
142 }
143
144 public function getImageDirectory(): string
145 {
147 }
148
149 public function setImageDirectory(string $image_directory): void
150 {
151 $this->image_directory = $image_directory;
152 }
153
154 public function getCssFile(): string
155 {
156 return $this->css_file;
157 }
158
159 public function setCssFile(string $css_file): void
160 {
161 $this->css_file = $css_file;
162 }
163
164 public function getFontDirectory(): string
165 {
167 }
168
169 public function setFontDirectory(string $font_directory): void
170 {
171 $this->font_directory = $font_directory;
172 }
173
177 public function getSubstyleOf(): string
178 {
179 return $this->substyle_of;
180 }
181
185 public function setSubstyleOf(string $substyle_of): void
186 {
187 $this->substyle_of = $substyle_of;
188 }
189
193 public function isSubstyle(): bool
194 {
195 return $this->getSubstyleOf() != '';
196 }
197
201 public function referencesResource(string $resource): bool
202 {
203 return $this->getCssFile() == $resource
204 || $this->getImageDirectory() == $resource
205 || $this->getFontDirectory() == $resource
206 || $this->getSoundDirectory() == $resource;
207 }
208}
string $css_file
Css file name of the skin.
setFontDirectory(string $font_directory)
string $name
Name of the style visible in all UI elements.
isSubstyle()
Return wheter this style is a substyle of another.
setCssFile(string $css_file)
setId(string $id)
string $id
Id of the skin.
string $font_directory
Directory to store fonts into.
__construct(string $id, string $name, string $css_file='', string $image_directory='', string $font_directory='', string $sound_directory='', string $parent_style='')
getSubstyleOf()
Returns the parent style of this style if set.
referencesResource(string $resource)
Checks if a resource (folder) relative to the style is referenced by this style.
string $sound_directory
Directory to store sound files into.
setSoundDirectory(string $sound_directory)
string $image_directory
Directory to store image files into.
setImageDirectory(string $image_directory)
string $substyle_of
Parent of the skin if set.
static parseFromXMLElement(SimpleXMLElement $xml_element)
setSubstyleOf(string $substyle_of)
Sets style as sub style of another.
setName(string $name)
Class for advanced editing exception handling in ILIAS.