ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilSkinFactory Class Reference

Factory to create Skin classes holds an manages the basic data of a skin as provide by the template of the skin. More...

+ Collaboration diagram for ilSkinFactory:

Public Member Functions

 __construct (ilLanguage $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 as copying files and folders, generating a new skin, deleting a skin etc. More...
 
 skinStyleContainerFromZip (string $import_zip_path, string $name, ilSystemStyleMessageStack $message_stack)
 Imports a skin from zip. More...
 
 copyFromSkinStyleContainer (ilSkinStyleContainer $container, ilFileSystemHelper $file_system, ilSystemStyleMessageStack $message_stack, string $new_skin_txt_addon='Copy')
 Copies a complete Skin. More...
 

Protected Attributes

ilSystemStyleConfig $config
 
ilLanguage $lng
 

Private Attributes

Archives $archives
 

Detailed Description

Factory to create Skin classes holds an manages the basic data of a skin as provide by the template of the skin.

Definition at line 30 of file class.ilSkinFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilSkinFactory::__construct ( ilLanguage  $lng,
?ilSystemStyleConfig  $config = null 
)

Definition at line 36 of file class.ilSkinFactory.php.

References $config, $DIC, Vendor\Package\$e, $id, $lng, $path, ilSystemStyleException\FILE_OPENING_FAILED, ILIAS\Repository\lng(), ilSystemStyleException\NO_PARENT_STYLE, ilSkinStyle\parseFromXMLElement(), and ilSkin\setVersion().

37  {
38  global $DIC;
39  $this->lng = $lng;
40  $this->archives = new Archives();
41 
42  if ($config) {
43  $this->config = $config;
44  } else {
45  $this->config = new ilSystemStyleConfig();
46  }
47  }
ilSystemStyleConfig $config
global $DIC
Definition: feed.php:28
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
+ Here is the call graph for this function:

Member Function Documentation

◆ copyFromSkinStyleContainer()

ilSkinFactory::copyFromSkinStyleContainer ( ilSkinStyleContainer  $container,
ilFileSystemHelper  $file_system,
ilSystemStyleMessageStack  $message_stack,
string  $new_skin_txt_addon = 'Copy' 
)

Copies a complete Skin.

Exceptions
ilSystemStyleException

Definition at line 161 of file class.ilSkinFactory.php.

References ilSkinStyleContainer\getSkin(), ilSkinStyleContainer\getSkinDirectory(), ilSkinStyleContainer\getSystemStylesConf(), ilFileSystemHelper\recursiveCopy(), ilStyleDefinition\skinExists(), and skinStyleContainerFromId().

167  $new_skin_id_addon = '';
168  $new_skin_name_addon = '';
169 
171  $container->getSkin()->getId() . $new_skin_id_addon,
172  $container->getSystemStylesConf()
173  )) {
174  $new_skin_id_addon .= $new_skin_txt_addon;
175  $new_skin_name_addon .= ' ' . $new_skin_txt_addon;
176  }
177 
178  $new_skin_path = rtrim($container->getSkinDirectory(), '/') . $new_skin_id_addon;
179 
180  mkdir($new_skin_path, 0775, true);
181  $file_system->recursiveCopy($container->getSkinDirectory(), $new_skin_path);
182  $skin_container = $this->skinStyleContainerFromId($container->getSkin()->getId() . $new_skin_id_addon, $message_stack);
183  $skin_container->getSkin()->setName($skin_container->getSkin()->getName() . $new_skin_name_addon);
184  $skin_container->getSkin()->setVersion('0.1');
185  $skin_container->updateSkin($skin_container->getSkin());
186  return $skin_container;
187  }
This class is responsible for all file system related actions related actions of a skin such as copyi...
skinStyleContainerFromId(string $skin_id, ilSystemStyleMessageStack $message_stack)
Get container class is responsible for all file system related actions related actions of a skin such...
static skinExists(string $skin_id, ?ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists.
recursiveCopy(string $src, string $dest)
Recursive copy of a folder.
+ Here is the call graph for this function:

◆ skinStyleContainerFromId()

ilSkinFactory::skinStyleContainerFromId ( string  $skin_id,
ilSystemStyleMessageStack  $message_stack 
)

Get container class is responsible for all file system related actions related actions of a skin such as copying files and folders, generating a new skin, deleting a skin etc.

Exceptions
ilSystemStyleException

Definition at line 94 of file class.ilSkinFactory.php.

References ILIAS\Repository\lng(), and ilSystemStyleException\NO_SKIN_ID.

Referenced by ilSystemStyleScssGUI\__construct(), ilSystemStyleIconsGUI\__construct(), ilSystemStyleOverviewGUI\__construct(), copyFromSkinStyleContainer(), and skinStyleContainerFromZip().

98  if (!$skin_id) {
100  }
101 
102  if ($skin_id != 'default') {
103  return new ilSkinStyleContainer(
104  $this->lng,
105  $this->skinFromXML($this->config->getCustomizingSkinPath() . $skin_id . '/template.xml'),
106  $message_stack,
107  $this->config
108  );
109  } else {
110  return new ilSkinStyleContainer(
111  $this->lng,
112  $this->skinFromXML($this->config->getDefaultTemplatePath()),
113  $message_stack,
114  $this->config,
115  );
116  }
117  }
This class is responsible for all file system related actions related actions of a skin such as copyi...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ skinStyleContainerFromZip()

ilSkinFactory::skinStyleContainerFromZip ( string  $import_zip_path,
string  $name,
ilSystemStyleMessageStack  $message_stack 
)

Imports a skin from zip.

Exceptions
ilSystemStyleException

Definition at line 123 of file class.ilSkinFactory.php.

References $container, ilStyleDefinition\skinExists(), and skinStyleContainerFromId().

128  $original_skin_id = preg_replace('/[^A-Za-z0-9\-_]/', '', rtrim($name, '.zip'));
129  $skin_id = $original_skin_id;
130 
131  while (ilStyleDefinition::skinExists($skin_id, $this->config)) {
132  $skin_id .= 'Copy';
133  }
134 
135  $skin_path = $this->config->getCustomizingSkinPath() . $skin_id;
136  $temp_skin_path = $skin_path."temp";
137  $zip_path = $temp_skin_path . ".zip";
138  rename($import_zip_path, $zip_path);
139 
140  $this->archives->unzip(
141  Streams::ofResource(fopen($zip_path, 'rb')),
142  $this->archives->unzipOptions()
143  ->withZipOutputPath($temp_skin_path)
144  ->withOverwrite(false)
145  ->withDirectoryHandling(ZipDirectoryHandling::KEEP_STRUCTURE)
146  )->extract();
147  unlink($zip_path);
148  rename($temp_skin_path."/".$original_skin_id, $skin_path);
149  rmdir($temp_skin_path);
150  $container = $this->skinStyleContainerFromId($skin_id, $message_stack);
151  $container->getSkin()->setId($skin_id);
152  $container->setSkin($container->getSkin());
153  $container->updateSkin();
154  return $container;
155  }
$container
Definition: wac.php:14
This class is responsible for all file system related actions related actions of a skin such as copyi...
skinStyleContainerFromId(string $skin_id, ilSystemStyleMessageStack $message_stack)
Get container class is responsible for all file system related actions related actions of a skin such...
static skinExists(string $skin_id, ?ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists.
+ Here is the call graph for this function:

Field Documentation

◆ $archives

Archives ilSkinFactory::$archives
private

Definition at line 32 of file class.ilSkinFactory.php.

◆ $config

ilSystemStyleConfig ilSkinFactory::$config
protected

Definition at line 33 of file class.ilSkinFactory.php.

Referenced by __construct().

◆ $lng

ilLanguage ilSkinFactory::$lng
protected

Definition at line 34 of file class.ilSkinFactory.php.

Referenced by __construct().


The documentation for this class was generated from the following file: