19declare(strict_types=1);
72 $this->skin_factory =
new ilSkinFactory(
$DIC->language(), $this->getSystemStylesConf());
75 $this->
setSkin($this->skin_factory->skinFromXML($this->getSystemStylesConf()->getCustomizingSkinPath() . $skin_id .
'/template.xml'));
77 $this->
setSkin($this->skin_factory->skinFromXML($this->getSystemStylesConf()->getDefaultTemplatePath()));
93 if (
$DIC->isDependencyAvailable(
'systemStyle') && is_object(
$DIC->systemStyle()->getSkin())) {
94 return $DIC->systemStyle()->getSkin()->getId();
98 if (
$DIC->isDependencyAvailable(
'user') && is_object(
$DIC->user())) {
99 $skin_id =
$DIC->user()->getSkin();
100 if ($skin_id && !self::skinExists($skin_id)) {
101 if (
$DIC->isDependencyAvailable(
'systemStyle')) {
103 $message_text =
$DIC->language()->txt(
'set_skin_does_not_exist') .
' ' . $skin_id;
107 $skin_id = $system_style_conf->getDefaultSkinId();
109 return $skin_id ===
'' ? $system_style_conf->getDefaultSkinId() : $skin_id;
121 return $this->
getSkin()->getStyles();
126 return $this->
getSkin()->getName();
134 return $this->
getSkin()->getStyle($a_id);
142 return $this->
getSkin()->getStyle($a_id)->getName();
154 return $this->
getSkin()->getStyle($style_id)->getImageDirectory();
165 return $this->
getSkin()->getStyle($style_id)->getSoundDirectory();
189 $cust_skins_directory =
new RecursiveDirectoryIterator(
191 FilesystemIterator::SKIP_DOTS
193 foreach ($cust_skins_directory as $skin_folder) {
194 if ($skin_folder->isDir()) {
195 $template_path = $skin_folder->getRealPath() .
'/template.xml';
196 if (file_exists($template_path)) {
239 if (isset(self::$current_style)) {
243 if (!
$DIC || is_array(
$DIC) || !
$DIC->isDependencyAvailable(
'user')) {
247 if (
$DIC->user()->getPref(
'style')) {
254 if (
$DIC->isDependencyAvailable(
'systemStyle') && self::styleExistsForCurrentSkin(self::$current_style)) {
255 if (
$DIC->systemStyle()->getSkin()->hasStyleSubstyles(self::$current_style)) {
258 self::getCurrentSkin(),
261 if (count($assignments) > 0) {
263 foreach ($assignments as
$a) {
264 if (
$DIC->systemStyle()->getSkin()->hasStyle(
$a[
'substyle'])) {
265 $ref_ass[
$a[
'ref_id']] =
$a[
'substyle'];
271 if (
$DIC->http()->wrapper()->query()->has(
'ref_id')) {
272 $ref_id =
$DIC->http()->wrapper()->query()->retrieve(
274 $DIC->refinery()->kindlyTo()->string()
276 } elseif (
$DIC->http()->wrapper()->query()->has(
'target')) {
277 $target =
$DIC->http()->wrapper()->query()->retrieve(
279 $DIC->refinery()->kindlyTo()->string()
281 $target_arr = explode(
'_', $target);
282 $ref_id = $target_arr[1] ??
'';
286 if (
$DIC->isDependencyAvailable(
'repositoryTree') &&
$ref_id &&
$DIC->repositoryTree()->isInTree((
int)
$ref_id)) {
288 for ($i = count(
$path) - 1; $i >= 0; $i--) {
289 if (isset($ref_ass[
$path[$i]])) {
290 self::$current_style = $ref_ass[
$path[$i]];
299 if (
$DIC->isDependencyAvailable(
'systemStyle') && !self::styleExistsForCurrentSkin(self::$current_style)) {
321 if (!self::getCachedAllStylesInformation()) {
331 if ($style->getSubstyleOf()) {
332 $parent_name =
$skin->
getStyle($style->getSubstyleOf())->getName();
340 $all_styles[
$skin->
getId() .
':' . $style->getId()] = [
341 'title' =>
$skin->
getName() .
' / ' . $style->getName(),
342 'id' =>
$skin->
getId() .
':' . $style->getId(),
347 'style_id' => $style->getId(),
348 'style_name' => $style->getName(),
349 'substyle_of' => $style->getSubstyleOf(),
350 'substyle_of_name' => $parent_name,
351 'users' => $num_users,
369 if (
$DIC->isDependencyAvailable(
'systemStyle') &&
$DIC->systemStyle()->getSkin()->getName() != $a_skin) {
371 if (!self::styleExistsForCurrentSkin(self::$current_style)) {
372 $styleDefinition->setCurrentStyle(
$DIC->systemStyle()->getSkin()->getDefaultStyle()->getId());
382 foreach (self::getSkins() as
$skin) {
397 if (!self::skinExists($skin_id)) {
409 return $DIC->systemStyle()->getSkin()->hasStyle($style_id);
414 self::$current_style = $a_style;
423 return self::getAllSkins();
446 if (!isset(self::$cached_all_styles_information)) {
static _getNumberOfUsersForStyle(string $a_skin, string $a_style)
Factory to create Skin classes holds an manages the basic data of a skin as provide by the template o...
ilSkin holds an manages the basic data of a skin as provide by the template of the skin.
ilStyleDefinition acts as a wrapper of style related actions.
static setCachedAllStylesInformation(array $cached_all_styles_information)
static getCurrentSkin()
get the current skin use always this function instead of getting the account's skin the current skin ...
getSoundDirectory(string $style_id)
static string $current_style
currently selected style, used for caching
static skinExists(string $skin_id, ?ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists.
static getCachedAllStylesInformation()
ilSkin $skin
Sets the current skin.
static setCurrentSkin(string $a_skin)
ilSkinFactory $skin_factory
getStyleName(string $a_id)
static styleExistsForCurrentSkin(string $style_id)
ilSystemStyleConfig $system_style_config
Used to wire this component up with the correct paths into the customizing directory.
static array $skins
Skins available, used for caching.
static getAllSkinStyles()
Get all skins/styles as array (convenient for tables) Attention: tempalte_name/template_id in this ar...
static setCurrentStyle(string $a_style)
static array $cached_all_styles_information
Used for caching.
static setSkins(array $skins)
setSystemStylesConf(ilSystemStyleConfig $system_style_config)
getImageDirectory(string $style_id)
static styleExists(string $style_id)
__construct(string $skin_id='', ?ilSystemStyleConfig $system_style_config=null)
ilStyleDefinition constructor.
static getCurrentStyle()
get the current style or sub style use always this function instead of getting the account's style th...
static styleExistsForSkinId(string $skin_id, string $style_id)
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.
static getSystemStyleCategoryAssignments(string $a_skin_id, string $a_style_id)
Get all system sub styles category assignments.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples