19 declare(strict_types=1);
    63             $skin_id = self::getCurrentSkin();
    66         if (!$system_style_config) {
    75             $this->
setSkin($this->skin_factory->skinFromXML($this->getSystemStylesConf()->getCustomizingSkinPath() . $skin_id . 
'/template.xml'));
    77             $this->
setSkin($this->skin_factory->skinFromXML($this->getSystemStylesConf()->getDefaultTemplatePath()));
    90         if (!$DIC || is_array($DIC)) {
    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()) && property_exists(
   102                 $skin_id = $DIC->user()->skin;
   103                 if ($skin_id && !self::skinExists($skin_id)) {
   104                     if($DIC->isDependencyAvailable(
'systemStyle')) {
   106                         $message_text = $DIC->language()->txt(
'set_skin_does_not_exist') . 
' ' . $skin_id;
   108                         $messages->sendMessages();
   110                     $skin_id = $system_style_conf->getDefaultSkinId();
   112                 return $skin_id === 
'' ? $system_style_conf->getDefaultSkinId() : $skin_id;
   124         return $this->
getSkin()->getStyles();
   129         return $this->
getSkin()->getName();
   137         return $this->
getSkin()->getStyle($a_id);
   145         return $this->
getSkin()->getStyle($a_id)->getName();
   157             return $this->
getSkin()->getStyle($style_id)->getImageDirectory();
   168         return $this->
getSkin()->getStyle($style_id)->getSoundDirectory();
   174     public static function getAllSkins(?
ilSystemStyleConfig $system_style_config = null): array
   177             if (!$system_style_config) {
   194                     FilesystemIterator::SKIP_DOTS
   196                 foreach ($cust_skins_directory as $skin_folder) {
   197                     if ($skin_folder->isDir()) {
   198                         $template_path = $skin_folder->getRealPath() . 
'/template.xml';
   199                         if (file_exists($template_path)) {
   200                             $skin = $skin_factory->skinFromXML($template_path);
   207             self::setSkins($skins);
   218         if (!$system_style_config) {
   242         if (isset(self::$current_style)) {
   243             return self::$current_style;
   246         if (!$DIC || is_array($DIC) || !$DIC->isDependencyAvailable(
'user')) {
   250         if (array_key_exists(
'style', $DIC->user()->prefs) && $DIC->user()->prefs[
'style']) {
   251             self::setCurrentStyle($DIC->user()->prefs[
'style']);
   257         if ($DIC->isDependencyAvailable(
'systemStyle') && self::styleExistsForCurrentSkin(self::$current_style)) {
   258             if ($DIC->systemStyle()->getSkin()->hasStyleSubstyles(self::$current_style)) {
   261                     self::getCurrentSkin(),
   264                 if (count($assignments) > 0) {
   266                     foreach ($assignments as 
$a) {
   267                         if ($DIC->systemStyle()->getSkin()->hasStyle($a[
'substyle'])) {
   268                             $ref_ass[$a[
'ref_id']] = $a[
'substyle'];
   274                     if ($DIC->http()->wrapper()->query()->has(
'ref_id')) {
   275                         $ref_id = $DIC->http()->wrapper()->query()->retrieve(
   277                             $DIC->refinery()->kindlyTo()->string()
   279                     } elseif ($DIC->http()->wrapper()->query()->has(
'target')) {
   280                         $target = $DIC->http()->wrapper()->query()->retrieve(
   282                             $DIC->refinery()->kindlyTo()->string()
   284                         $target_arr = explode(
'_', $target);
   285                         $ref_id = $target_arr[1] ?? 
'';
   289                     if ($DIC->isDependencyAvailable(
'repositoryTree') && 
$ref_id && $DIC->repositoryTree()->isInTree((
int) 
$ref_id)) {
   290                         $path = $DIC->repositoryTree()->getPathId((
int) $ref_id);
   291                         for ($i = count(
$path) - 1; $i >= 0; $i--) {
   292                             if (isset($ref_ass[
$path[$i]])) {
   293                                 self::$current_style = $ref_ass[
$path[$i]];
   294                                 return self::$current_style;
   302         if ($DIC->isDependencyAvailable(
'systemStyle') && !self::styleExistsForCurrentSkin(self::$current_style)) {
   304             $message_text = $DIC->language()->txt(
'set_style_does_not_exist') . 
' ' . self::$current_style;
   306             $messages->sendMessages();
   312         return self::$current_style;
   324         if (!self::getCachedAllStylesInformation()) {
   327             $skins = $DIC->systemStyle()->getSkins();
   329             foreach ($skins as $skin) {
   330                 foreach ($skin->getStyles() as $style) {
   334                     if ($style->getSubstyleOf()) {
   335                         $parent_name = $skin->getStyle($style->getSubstyleOf())->getName();
   343                     $all_styles[$skin->getId() . 
':' . $style->getId()] = [
   344                         'title' => $skin->getName() . 
' / ' . $style->getName(),
   345                         'id' => $skin->getId() . 
':' . $style->getId(),
   346                         'skin_id' => $skin->getId(),
   347                         'skin_name' => $skin->getName(),
   348                         'template_id' => $skin->getId(),
   349                         'template_name' => $skin->getName(),
   350                         'style_id' => $style->getId(),
   351                         'style_name' => $style->getName(),
   352                         'substyle_of' => $style->getSubstyleOf(),
   353                         'substyle_of_name' => $parent_name,
   354                         'users' => $num_users,
   359             self::setCachedAllStylesInformation($all_styles);
   362         return self::getCachedAllStylesInformation();
   372         if ($DIC->isDependencyAvailable(
'systemStyle') && $DIC->systemStyle()->getSkin()->getName() != $a_skin) {
   374             if (!self::styleExistsForCurrentSkin(self::$current_style)) {
   375                 $styleDefinition->setCurrentStyle($DIC->systemStyle()->getSkin()->getDefaultStyle()->getId());
   385         foreach (self::getSkins() as $skin) {
   386             if ($skin->hasStyle($style_id)) {
   400         if (!self::skinExists($skin_id)) {
   404         $skin = $factory->skinStyleContainerFromId($skin_id, 
new ilSystemStyleMessageStack($DIC->ui()->mainTemplate()))->getSkin();
   405         return $skin->hasStyle($style_id);
   412         return $DIC->systemStyle()->getSkin()->hasStyle($style_id);
   417         self::$current_style = $a_style;
   426         return self::getAllSkins();
   432     public static function setSkins(array $skins): void
   449         if (!isset(self::$cached_all_styles_information)) {
   452         return self::$cached_all_styles_information;
 static setCachedAllStylesInformation(array $cached_all_styles_information)
 
static setCurrentStyle(string $a_style)
 
getStyleName(string $a_id)
 
getSoundDirectory(string $style_id)
 
ilSystemStyleConfig $system_style_config
Used to wire this component up with the correct paths into the customizing directory. 
 
static styleExists(string $style_id)
 
Factory to create Skin classes holds an manages the basic data of a skin as provide by the template o...
 
static getCachedAllStylesInformation()
 
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack. 
 
static string $current_style
currently selected style, used for caching 
 
static styleExistsForCurrentSkin(string $style_id)
 
static getSystemStyleCategoryAssignments(string $a_skin_id, string $a_style_id)
Get all system sub styles category assignments. 
 
static _getNumberOfUsersForStyle(string $a_skin, string $a_style)
 
static getAllSkinStyles()
Get all skins/styles as array (convenient for tables) Attention: tempalte_name/template_id in this ar...
 
static getCurrentSkin()
get the current skin use always this function instead of getting the account's skin the current skin ...
 
ilSkinFactory $skin_factory
 
static styleExistsForSkinId(string $skin_id, string $style_id)
 
static setSkins(array $skins)
 
static array $cached_all_styles_information
Used for caching. 
 
ilSkin $skin
Sets the current skin. 
 
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
 
setSystemStylesConf(ilSystemStyleConfig $system_style_config)
 
static skinExists(string $skin_id, ?ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists. 
 
__construct(string $skin_id='', ilSystemStyleConfig $system_style_config=null)
ilStyleDefinition constructor. 
 
static setCurrentSkin(string $a_skin)
 
getImageDirectory(string $style_id)
 
Used to stack messages to be shown to the user. 
 
ilStyleDefinition acts as a wrapper of style related actions. 
 
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples 
 
static array $skins
Skins available, used for caching. 
 
static getCurrentStyle()
get the current style or sub style use always this function instead of getting the account's style th...
 
ilSkin holds an manages the basic data of a skin as provide by the template of the skin...