ILIAS  release_8 Revision v8.23
ilSkinStyleContainer Class Reference

This 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...

+ Collaboration diagram for ilSkinStyleContainer:

Public Member Functions

 __construct (ilLanguage $lng, ilSkin $skin, ilSystemStyleMessageStack $message_stack, ilSystemStyleConfig $system_styles_conf=null, ilFileSystemHelper $file_system=null)
 
 create (ilSystemStyleMessageStack $message_stack)
 Creates a new skin. More...
 
 updateSkin (ilSkin $old_skin=null)
 Updates the skin. More...
 
 updateStyle (string $style_id, ilSkinStyle $old_style)
 Updates one single style. More...
 
 createMainLessFile (ilSkinStyle $style)
 Creates the main less file. More...
 
 copyVariablesFromDefault (ilSkinStyle $style)
 Copies (resets) the variables file from delos. More...
 
 resetImages (ilSkinStyle $style)
 Copies (resets) the images from delos. More...
 
 copyCSSFromDefault (ilSkinStyle $style)
 Copies (resets) the images from delos. More...
 
 delete ()
 Deletes the container of a skin completely. More...
 
 deleteStyle (ilSkinStyle $style)
 Deletes a style completely. More...
 
 export ()
 Exports the complete skin to an zip file. More...
 
 createTempZip ()
 Creates a temp zip file. More...
 
 compileLess (string $style_id)
 
 getSkin ()
 
 setSkin (ilSkin $skin)
 
 getSkinDirectory ()
 
 getCSSFilePath (string $style_id)
 
 getLessFilePath (string $style_id)
 
 getLessVariablesFilePath (string $style_id)
 
 getLessVariablesName (string $style_id)
 
 getImagesSkinPath (string $style_id)
 
 getMessageStack ()
 
 setMessageStack (ilSystemStyleMessageStack $message_stack)
 
 addStyle (ilSkinStyle $style)
 
 getSystemStylesConf ()
 
 setSystemStylesConf (ilSystemStyleConfig $system_styles_conf)
 

Protected Member Functions

 resourcesStyleReferences (string $resource)
 Checks if a given resource (folder) is still referenced by a style of the containers skin. More...
 
 createLessStructure (ilSkinStyle $style)
 Creates the less/css structure of a style. More...
 
 getLessMainFileDefautContent (ilSkinStyle $style)
 Returns the main less default content if a new style is created. More...
 
 changeVariablesImport (string $main_path, string $old_style_import, string $new_style_import)
 
 writeSkinToXML ()
 

Protected Attributes

ilLanguage $lng
 
ilSkin $skin
 Data-scope for the skin this container capsules. More...
 
ilSystemStyleMessageStack $message_stack
 Used to stack messages to be displayed to the user (mostly reports for failed actions) More...
 
ilSystemStyleConfig $system_styles_conf
 Used to wire this component up with the correct pathes into the customizing directory. More...
 
ilFileSystemHelper $file_system
 

Detailed Description

This 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.

It contains exactly one skin containing several styles. Use this class to parse a skin from xml.

Definition at line 26 of file class.ilSkinStyleContainer.php.

Constructor & Destructor Documentation

◆ __construct()

ilSkinStyleContainer::__construct ( ilLanguage  $lng,
ilSkin  $skin,
ilSystemStyleMessageStack  $message_stack,
ilSystemStyleConfig  $system_styles_conf = null,
ilFileSystemHelper  $file_system = null 
)

Definition at line 47 of file class.ilSkinStyleContainer.php.

References $file_system, $lng, $skin, ILIAS\Repository\lng(), setMessageStack(), and setSystemStylesConf().

53  {
54  $this->lng = $lng;
55  $this->skin = $skin;
56  $this->setMessageStack($message_stack);
57 
58  if (!$system_styles_conf) {
60  } else {
61  $this->setSystemStylesConf($system_styles_conf);
62  }
63 
64  if (!$file_system) {
65  $this->file_system = new ilFileSystemHelper($this->lng, $message_stack);
66  } else {
67  $this->file_system = $file_system;
68  }
69  }
setSystemStylesConf(ilSystemStyleConfig $system_styles_conf)
setMessageStack(ilSystemStyleMessageStack $message_stack)
ilSkin $skin
Data-scope for the skin this container capsules.
File System Helper, to reduce deps.
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

◆ addStyle()

ilSkinStyleContainer::addStyle ( ilSkinStyle  $style)

Definition at line 487 of file class.ilSkinStyleContainer.php.

References ilSkinStyle\getId(), getSkin(), and updateStyle().

Referenced by ilSkinStyleContainerTest\testAddStyle().

487  : void
488  {
489  $this->getSkin()->addStyle($style);
490  $old_style = new ilSkinStyle('', '');
491  $this->updateStyle($style->getId(), $old_style);
492  }
updateStyle(string $style_id, ilSkinStyle $old_style)
Updates one single style.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ changeVariablesImport()

ilSkinStyleContainer::changeVariablesImport ( string  $main_path,
string  $old_style_import,
string  $new_style_import 
)
protected

Definition at line 400 of file class.ilSkinStyleContainer.php.

Referenced by updateStyle().

404  : void {
405  $main_less_content = file_get_contents($main_path);
406  $main_less_content = str_replace(
407  "@import \"" . $old_style_import,
408  "@import \"" . $new_style_import,
409  $main_less_content
410  );
411  file_put_contents($main_path, $main_less_content);
412  }
+ Here is the caller graph for this function:

◆ compileLess()

ilSkinStyleContainer::compileLess ( string  $style_id)
Exceptions
ilSystemStyleException

Definition at line 417 of file class.ilSkinStyleContainer.php.

References getCSSFilePath(), getLessFilePath(), ilSystemStyleException\LESS_COMPILE_FAILED, and ilSystemStyleException\LESSC_NOT_INSTALLED.

Referenced by createLessStructure(), and updateStyle().

417  : void
418  {
419  if (!PATH_TO_LESSC) {
421  }
422 
423  $output = shell_exec(PATH_TO_LESSC . ' ' . $this->getLessFilePath($style_id));
424  if (!$output) {
425  $less_error = shell_exec(PATH_TO_LESSC . ' ' . $this->getLessFilePath($style_id) . ' 2>&1');
426  if (!$less_error) {
427  throw new ilSystemStyleException(
429  'Empty css output, unknown error.'
430  );
431  }
433  }
434  file_put_contents($this->getCSSFilePath($style_id), $output);
435  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyCSSFromDefault()

ilSkinStyleContainer::copyCSSFromDefault ( ilSkinStyle  $style)

Copies (resets) the images from delos.

Definition at line 296 of file class.ilSkinStyleContainer.php.

References getCSSFilePath(), ilSkinStyle\getId(), and getSystemStylesConf().

Referenced by createLessStructure().

296  : void
297  {
298  copy($this->getSystemStylesConf()->getDelosPath() . '.css', $this->getCSSFilePath($style->getId()));
299  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyVariablesFromDefault()

ilSkinStyleContainer::copyVariablesFromDefault ( ilSkinStyle  $style)

Copies (resets) the variables file from delos.

Definition at line 273 of file class.ilSkinStyleContainer.php.

References ilSkinStyle\getId(), getLessVariablesFilePath(), and getSystemStylesConf().

Referenced by createLessStructure(), and updateStyle().

274  {
275  $less_file = new ilSystemStyleLessFile($this->getSystemStylesConf()->getDefaultVariablesPath());
276  $less_file->setLessVariablesFilePathName($this->getLessVariablesFilePath($style->getId()));
277  $less_file->write();
278  return $less_file;
279  }
getLessVariablesFilePath(string $style_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilSkinStyleContainer::create ( ilSystemStyleMessageStack  $message_stack)

Creates a new skin.

This includes the generation of the XML and the corresponding folders of all contained styles.

Exceptions
ilSystemStyleException

Definition at line 75 of file class.ilSkinStyleContainer.php.

References Vendor\Package\$e, ilSystemStyleMessageStack\addMessage(), createLessStructure(), getImagesSkinPath(), getSkin(), getSkinDirectory(), getSystemStylesConf(), ILIAS\Repository\lng(), ilSystemStyleException\SKIN_ALREADY_EXISTS, ilSystemStyleMessage\TYPE_ERROR, and writeSkinToXML().

Referenced by ilSkinStyleContainerTest\testCreateDelete().

75  : void
76  {
77  if (file_exists($this->getSkinDirectory())) {
79  }
80 
81  mkdir($this->getSkinDirectory(), 0777, true);
82 
83  foreach ($this->getSkin()->getStyles() as $style) {
84  $this->file_system->createResourceDirectory(
85  $this->getSystemStylesConf()->getDefaultImagesPath(),
86  $this->getImagesSkinPath($style->getId())
87  );
88  $this->file_system->createResourceDirectory(
89  $this->getSystemStylesConf()->getDefaultSoundsPath(),
90  $this->getSkinDirectory() . $style->getSoundDirectory()
91  );
92  $this->file_system->createResourceDirectory(
93  $this->getSystemStylesConf()->getDefaultFontsPath(),
94  $this->getSkinDirectory() . $style->getFontDirectory()
95  );
96  try {
97  $this->createLessStructure($style);
98  } catch (Exception $e) {
99  $message_stack->addMessage(new ilSystemStyleMessage(
100  $this->lng->txt('less_compile_failed') . ' ' . $e->getMessage(),
102  ));
103  }
104  }
105  $this->writeSkinToXML();
106  }
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
createLessStructure(ilSkinStyle $style)
Creates the less/css structure of a style.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createLessStructure()

ilSkinStyleContainer::createLessStructure ( ilSkinStyle  $style)
protected

Creates the less/css structure of a style.

Exceptions
ilSystemStyleException

Definition at line 247 of file class.ilSkinStyleContainer.php.

References compileLess(), copyCSSFromDefault(), copyVariablesFromDefault(), createMainLessFile(), and ilSkinStyle\getId().

Referenced by create().

247  : void
248  {
249  $this->createMainLessFile($style);
250  $this->copyVariablesFromDefault($style);
251  $this->copyCSSFromDefault($style);
252  $this->compileLess($style->getId());
253  }
copyVariablesFromDefault(ilSkinStyle $style)
Copies (resets) the variables file from delos.
createMainLessFile(ilSkinStyle $style)
Creates the main less file.
copyCSSFromDefault(ilSkinStyle $style)
Copies (resets) the images from delos.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createMainLessFile()

ilSkinStyleContainer::createMainLessFile ( ilSkinStyle  $style)

Creates the main less file.

Definition at line 258 of file class.ilSkinStyleContainer.php.

References $path, ilSkinStyle\getId(), getLessFilePath(), getLessMainFileDefautContent(), getMessageStack(), ILIAS\Repository\lng(), and ilSystemStyleMessage\TYPE_SUCCESS.

Referenced by createLessStructure(), and updateStyle().

258  : void
259  {
260  $path = $this->getLessFilePath($style->getId());
261  file_put_contents($path, $this->getLessMainFileDefautContent($style));
262  $this->getMessageStack()->addMessage(
264  $this->lng->txt('main_less_created') . ' ' . $path,
266  )
267  );
268  }
getLessMainFileDefautContent(ilSkinStyle $style)
Returns the main less default content if a new style is created.
$path
Definition: ltiservices.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createTempZip()

ilSkinStyleContainer::createTempZip ( )

Creates a temp zip file.

Definition at line 393 of file class.ilSkinStyleContainer.php.

References getSkin(), getSkinDirectory(), and ilFileUtils\zip().

Referenced by export(), and ilSkinFactoryTest\testImportSkin().

393  : string
394  {
395  $rel_tmp_zip = '../' . $this->getSkin()->getId() . '.zip';
396  ilFileUtils::zip($this->getSkinDirectory(), $rel_tmp_zip, true);
397  return rtrim($this->getSkinDirectory(), '/') . '.zip';
398  }
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilSkinStyleContainer::delete ( )

Deletes the container of a skin completely.

Definition at line 316 of file class.ilSkinStyleContainer.php.

References getMessageStack(), getSkinDirectory(), ILIAS\Repository\lng(), and ilSystemStyleMessage\TYPE_SUCCESS.

Referenced by ilSkinStyleContainerTest\testCreateDelete(), and ilSkinStyleContainerTest\testDeleteSkin().

316  : void
317  {
318  $this->file_system->recursiveRemoveDir(self::getSkinDirectory());
319  $this->getMessageStack()->addMessage(
321  $this->lng->txt('skin_deleted') . $this->getSkinDirectory(),
323  )
324  );
325  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteStyle()

ilSkinStyleContainer::deleteStyle ( ilSkinStyle  $style)

Deletes a style completely.

Definition at line 330 of file class.ilSkinStyleContainer.php.

References ilSystemStyleSettings\deleteSubStyleCategoryAssignments(), getCSSFilePath(), ilSkinStyle\getFontDirectory(), ILIAS\Survey\Mode\getId(), ilSkinStyle\getId(), ilSkinStyle\getImageDirectory(), getLessFilePath(), getLessVariablesFilePath(), getMessageStack(), ilSkinStyle\getName(), getSkin(), getSkinDirectory(), ilSkinStyle\getSoundDirectory(), ilSkinStyle\getSubstyleOf(), ilSkinStyle\isSubstyle(), ILIAS\Repository\lng(), resourcesStyleReferences(), ilSystemStyleMessage\TYPE_SUCCESS, and writeSkinToXML().

Referenced by ilSkinStyleContainerTest\testDeleteStyle().

330  : void
331  {
332  if ($style->isSubstyle()) {
334  $this->getSkin()->getId(),
335  $style->getSubstyleOf(),
336  $style->getId()
337  );
338  $this->getMessageStack()->prependMessage(
340  $this->lng->txt('style_assignments_deleted') . ' ' . $style->getName(),
342  )
343  );
344  }
345 
346  $this->file_system->saveDeleteFile($this->getLessFilePath($style->getId()));
347  $this->file_system->saveDeleteFile($this->getCSSFilePath($style->getId()));
348  $this->file_system->saveDeleteFile($this->getLessVariablesFilePath($style->getId()));
349 
350  $this->getSkin()->removeStyle($style->getId());
351 
352  $this->file_system->removeResourceDirectory(
353  $this->getSkinDirectory(),
354  $style->getImageDirectory(),
355  count($this->resourcesStyleReferences($style->getImageDirectory())) > 0
356  );
357  $this->file_system->removeResourceDirectory(
358  $this->getSkinDirectory(),
359  $style->getFontDirectory(),
360  count($this->resourcesStyleReferences($style->getImageDirectory())) > 0
361  );
362  $this->file_system->removeResourceDirectory(
363  $this->getSkinDirectory(),
364  $style->getSoundDirectory(),
365  count($this->resourcesStyleReferences($style->getImageDirectory())) > 0
366  );
367 
368  $this->writeSkinToXML();
369  $this->getMessageStack()->prependMessage(
371  $this->lng->txt('style_deleted') . ' ' . $style->getName(),
373  )
374  );
375  }
getLessVariablesFilePath(string $style_id)
static deleteSubStyleCategoryAssignments(string $a_skin_id, string $a_style_id, string $a_substyle)
Delets a sub styles category assignment.
resourcesStyleReferences(string $resource)
Checks if a given resource (folder) is still referenced by a style of the containers skin...
isSubstyle()
Return wheter this style is a substyle of another.
getSubstyleOf()
Returns the parent style of this style if set.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ export()

ilSkinStyleContainer::export ( )

Exports the complete skin to an zip file.

Definition at line 380 of file class.ilSkinStyleContainer.php.

References createTempZip(), ilFileDelivery\deliverFileAttached(), ILIAS\Survey\Mode\getId(), and getSkin().

380  : void
381  {
383  $this->createTempZip(),
384  $this->getSkin()->getId() . '.zip',
385  '',
386  true
387  );
388  }
static deliverFileAttached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, bool $delete_file=false)
createTempZip()
Creates a temp zip file.
+ Here is the call graph for this function:

◆ getCSSFilePath()

ilSkinStyleContainer::getCSSFilePath ( string  $style_id)

Definition at line 452 of file class.ilSkinStyleContainer.php.

References getSkin(), and getSkinDirectory().

Referenced by compileLess(), copyCSSFromDefault(), deleteStyle(), and updateStyle().

452  : string
453  {
454  return $this->getSkinDirectory() . $this->getSkin()->getStyle($style_id)->getCssFile() . '.css';
455  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImagesSkinPath()

ilSkinStyleContainer::getImagesSkinPath ( string  $style_id)

Definition at line 472 of file class.ilSkinStyleContainer.php.

References getSkin(), and getSkinDirectory().

Referenced by create(), resetImages(), and updateStyle().

472  : string
473  {
474  return $this->getSkinDirectory() . $this->getSkin()->getStyle($style_id)->getImageDirectory();
475  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLessFilePath()

ilSkinStyleContainer::getLessFilePath ( string  $style_id)

Definition at line 457 of file class.ilSkinStyleContainer.php.

References getSkin(), and getSkinDirectory().

Referenced by compileLess(), createMainLessFile(), deleteStyle(), and updateStyle().

457  : string
458  {
459  return $this->getSkinDirectory() . $this->getSkin()->getStyle($style_id)->getCssFile() . '.less';
460  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLessMainFileDefautContent()

ilSkinStyleContainer::getLessMainFileDefautContent ( ilSkinStyle  $style)
protected

Returns the main less default content if a new style is created.

Definition at line 304 of file class.ilSkinStyleContainer.php.

References ilSkinStyle\getId(), getLessVariablesName(), and getSystemStylesConf().

Referenced by createMainLessFile().

304  : string
305  {
306  $content = "@import \"" . $this->getSystemStylesConf()->getRelDelosPath() . "\";\n";
307  $content .= "// Import Custom Less Files here\n";
308 
309  $content .= "@import \"" . $this->getLessVariablesName($style->getId()) . "\";\n";
310  return $content;
311  }
getLessVariablesName(string $style_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLessVariablesFilePath()

ilSkinStyleContainer::getLessVariablesFilePath ( string  $style_id)

Definition at line 462 of file class.ilSkinStyleContainer.php.

References getLessVariablesName(), and getSkinDirectory().

Referenced by copyVariablesFromDefault(), deleteStyle(), and updateStyle().

462  : string
463  {
464  return $this->getSkinDirectory() . $this->getLessVariablesName($style_id);
465  }
getLessVariablesName(string $style_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLessVariablesName()

ilSkinStyleContainer::getLessVariablesName ( string  $style_id)

Definition at line 467 of file class.ilSkinStyleContainer.php.

References getSkin().

Referenced by getLessMainFileDefautContent(), getLessVariablesFilePath(), and updateStyle().

467  : string
468  {
469  return $this->getSkin()->getStyle($style_id)->getCssFile() . '-variables.less';
470  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMessageStack()

ilSkinStyleContainer::getMessageStack ( )

Definition at line 477 of file class.ilSkinStyleContainer.php.

References $message_stack.

Referenced by createMainLessFile(), delete(), deleteStyle(), and updateStyle().

478  {
479  return $this->message_stack;
480  }
ilSystemStyleMessageStack $message_stack
Used to stack messages to be displayed to the user (mostly reports for failed actions) ...
Used to stack messages to be shown to the user.
+ Here is the caller graph for this function:

◆ getSkin()

◆ getSkinDirectory()

ilSkinStyleContainer::getSkinDirectory ( )

Definition at line 447 of file class.ilSkinStyleContainer.php.

References getSkin(), and getSystemStylesConf().

Referenced by ilSkinFactory\copyFromSkinStyleContainer(), create(), createTempZip(), delete(), deleteStyle(), getCSSFilePath(), getImagesSkinPath(), getLessFilePath(), getLessVariablesFilePath(), resetImages(), updateSkin(), updateStyle(), and writeSkinToXML().

447  : string
448  {
449  return $this->getSystemStylesConf()->getCustomizingSkinPath() . $this->getSkin()->getId() . '/';
450  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSystemStylesConf()

ilSkinStyleContainer::getSystemStylesConf ( )

Definition at line 499 of file class.ilSkinStyleContainer.php.

References $system_styles_conf.

Referenced by copyCSSFromDefault(), ilSkinFactory\copyFromSkinStyleContainer(), copyVariablesFromDefault(), create(), getLessMainFileDefautContent(), getSkinDirectory(), resetImages(), updateSkin(), and updateStyle().

500  {
502  }
ilSystemStyleConfig $system_styles_conf
Used to wire this component up with the correct pathes into the customizing directory.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
+ Here is the caller graph for this function:

◆ resetImages()

ilSkinStyleContainer::resetImages ( ilSkinStyle  $style)

Copies (resets) the images from delos.

Definition at line 284 of file class.ilSkinStyleContainer.php.

References ilSkinStyle\getId(), ilSkinStyle\getImageDirectory(), getImagesSkinPath(), getSkinDirectory(), and getSystemStylesConf().

284  : void
285  {
286  $this->file_system->recursiveRemoveDir($this->getSkinDirectory() . $style->getImageDirectory());
287  $this->file_system->createResourceDirectory(
288  $this->getSystemStylesConf()->getDefaultImagesPath(),
289  $this->getImagesSkinPath($style->getId())
290  );
291  }
+ Here is the call graph for this function:

◆ resourcesStyleReferences()

ilSkinStyleContainer::resourcesStyleReferences ( string  $resource)
protected

Checks if a given resource (folder) is still referenced by a style of the containers skin.

Definition at line 232 of file class.ilSkinStyleContainer.php.

References getSkin().

Referenced by deleteStyle(), and updateStyle().

232  : array
233  {
234  $references_ids = [];
235  foreach ($this->getSkin()->getStyles() as $style) {
236  if ($style->referencesResource($resource)) {
237  $references_ids[] = $style->getId();
238  }
239  }
240  return $references_ids;
241  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMessageStack()

ilSkinStyleContainer::setMessageStack ( ilSystemStyleMessageStack  $message_stack)

Definition at line 482 of file class.ilSkinStyleContainer.php.

References $message_stack.

Referenced by __construct().

482  : void
483  {
484  $this->message_stack = $message_stack;
485  }
ilSystemStyleMessageStack $message_stack
Used to stack messages to be displayed to the user (mostly reports for failed actions) ...
+ Here is the caller graph for this function:

◆ setSkin()

ilSkinStyleContainer::setSkin ( ilSkin  $skin)

Definition at line 442 of file class.ilSkinStyleContainer.php.

References $skin.

442  : void
443  {
444  $this->skin = $skin;
445  }
ilSkin $skin
Data-scope for the skin this container capsules.

◆ setSystemStylesConf()

ilSkinStyleContainer::setSystemStylesConf ( ilSystemStyleConfig  $system_styles_conf)

Definition at line 504 of file class.ilSkinStyleContainer.php.

References $system_styles_conf.

Referenced by __construct().

504  : void
505  {
506  $this->system_styles_conf = $system_styles_conf;
507  }
ilSystemStyleConfig $system_styles_conf
Used to wire this component up with the correct pathes into the customizing directory.
+ Here is the caller graph for this function:

◆ updateSkin()

ilSkinStyleContainer::updateSkin ( ilSkin  $old_skin = null)

Updates the skin.

Style are not updated, use updateStyle for that.

Exceptions
ilSystemStyleException

Definition at line 112 of file class.ilSkinStyleContainer.php.

References getSkin(), getSkinDirectory(), getSystemStylesConf(), and writeSkinToXML().

Referenced by ilSkinStyleContainerTest\testUpdateSkinNoIdChange(), and ilSkinStyleContainerTest\testUpdateSkinWithChangedID().

112  : void
113  {
114  if (!$old_skin) {
115  $old_skin = $this->getSkin();
116  }
117  $old_customizing_skin_directory = $this->getSystemStylesConf()->getCustomizingSkinPath() . $old_skin->getId() . '/';
118 
119  //Move if skin id has been changed
120  if ($old_skin->getId() != $this->getSkin()->getId()) {
121  $this->file_system->move($old_customizing_skin_directory, $this->getSkinDirectory());
122  }
123 
124  //Delete old template.xml and write a new one
125  $this->file_system->delete($this->getSkinDirectory() . 'template.xml');
126  $this->writeSkinToXML();
127  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateStyle()

ilSkinStyleContainer::updateStyle ( string  $style_id,
ilSkinStyle  $old_style 
)

Updates one single style.

Definition at line 132 of file class.ilSkinStyleContainer.php.

References Vendor\Package\$e, changeVariablesImport(), compileLess(), copyVariablesFromDefault(), createMainLessFile(), ilSkinStyle\getCssFile(), getCSSFilePath(), ilSkinStyle\getFontDirectory(), ilSkinStyle\getImageDirectory(), getImagesSkinPath(), getLessFilePath(), getLessVariablesFilePath(), getLessVariablesName(), getMessageStack(), getSkin(), getSkinDirectory(), ilSkinStyle\getSoundDirectory(), getSystemStylesConf(), resourcesStyleReferences(), ilSystemStyleMessage\TYPE_ERROR, and writeSkinToXML().

Referenced by addStyle(), and ilSkinStyleContainerTest\testUpdateStyle().

132  : void
133  {
134  $style = $this->getSkin()->getStyle($style_id);
135  if ($style->getImageDirectory() != $old_style->getImageDirectory()) {
136  if (file_exists($this->getSkinDirectory() . $old_style->getImageDirectory())) {
137  $this->file_system->changeResourceDirectory(
138  $this->getSkinDirectory(),
139  $style->getImageDirectory(),
140  $old_style->getImageDirectory(),
141  count($this->resourcesStyleReferences($old_style->getImageDirectory())) > 0
142  );
143  } else {
144  $this->file_system->createResourceDirectory(
145  $this->getSystemStylesConf()->getDefaultImagesPath(),
146  $this->getImagesSkinPath($style->getId())
147  );
148  }
149  }
150 
151  if ($style->getFontDirectory() != $old_style->getFontDirectory()) {
152  if (file_exists($this->getSkinDirectory() . $old_style->getFontDirectory())) {
153  $this->file_system->changeResourceDirectory(
154  $this->getSkinDirectory(),
155  $style->getFontDirectory(),
156  $old_style->getFontDirectory(),
157  count($this->resourcesStyleReferences($old_style->getFontDirectory())) > 0
158  );
159  } else {
160  $this->file_system->createResourceDirectory(
161  $this->getSystemStylesConf()->getDefaultFontsPath(),
162  $this->getSkinDirectory() . $style->getFontDirectory()
163  );
164  }
165  }
166 
167  if ($style->getSoundDirectory() != $old_style->getSoundDirectory()) {
168  if (file_exists($this->getSkinDirectory() . $old_style->getSoundDirectory())) {
169  $this->file_system->changeResourceDirectory(
170  $this->getSkinDirectory(),
171  $style->getSoundDirectory(),
172  $old_style->getSoundDirectory(),
173  count($this->resourcesStyleReferences($old_style->getSoundDirectory())) > 0
174  );
175  } else {
176  $this->file_system->createResourceDirectory(
177  $this->getSystemStylesConf()->getDefaultSoundsPath(),
178  $this->getSkinDirectory() . $style->getSoundDirectory()
179  );
180  }
181  }
182 
183  if (file_exists($this->getSkinDirectory() . $old_style->getCssFile() . '.less')) {
184  rename(
185  $this->getSkinDirectory() . $old_style->getCssFile() . '.less',
186  $this->getLessFilePath($style->getId())
187  );
188  } else {
189  $this->createMainLessFile($style);
190  }
191 
192  if (file_exists($this->getSkinDirectory() . $old_style->getCssFile() . '-variables.less')) {
193  rename(
194  $this->getSkinDirectory() . $old_style->getCssFile() . '-variables.less',
195  $this->getLessVariablesFilePath($style->getId())
196  );
197  } else {
198  $this->copyVariablesFromDefault($style);
199  }
200 
201  $this->changeVariablesImport(
202  $this->getLessFilePath($style->getId()),
203  $old_style->getCssFile() . '-variables.less',
204  $this->getLessVariablesName($style->getId())
205  );
206 
207  if (file_exists($this->getSkinDirectory() . $old_style->getCssFile() . '.css')) {
208  rename(
209  $this->getSkinDirectory() . $old_style->getCssFile() . '.css',
210  $this->getCSSFilePath($style->getId())
211  );
212  } else {
213  try {
214  $this->compileLess($style->getId());
215  } catch (Exception $e) {
216  $this->getMessageStack()->addMessage(
218  $e->getMessage(),
220  )
221  );
222  copy($this->getSystemStylesConf()->getDelosPath() . '.css', $this->getCSSFilePath($style->getId()));
223  }
224  }
225 
226  $this->writeSkinToXML();
227  }
getLessVariablesFilePath(string $style_id)
changeVariablesImport(string $main_path, string $old_style_import, string $new_style_import)
copyVariablesFromDefault(ilSkinStyle $style)
Copies (resets) the variables file from delos.
createMainLessFile(ilSkinStyle $style)
Creates the main less file.
getLessVariablesName(string $style_id)
resourcesStyleReferences(string $resource)
Checks if a given resource (folder) is still referenced by a style of the containers skin...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeSkinToXML()

ilSkinStyleContainer::writeSkinToXML ( )
protected

Definition at line 494 of file class.ilSkinStyleContainer.php.

References getSkin(), and getSkinDirectory().

Referenced by create(), deleteStyle(), updateSkin(), and updateStyle().

494  : void
495  {
496  $this->getSkin()->writeToXMLFile($this->getSkinDirectory() . 'template.xml');
497  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $file_system

ilFileSystemHelper ilSkinStyleContainer::$file_system
protected

Definition at line 45 of file class.ilSkinStyleContainer.php.

Referenced by __construct().

◆ $lng

ilLanguage ilSkinStyleContainer::$lng
protected

Definition at line 28 of file class.ilSkinStyleContainer.php.

Referenced by __construct().

◆ $message_stack

ilSystemStyleMessageStack ilSkinStyleContainer::$message_stack
protected

Used to stack messages to be displayed to the user (mostly reports for failed actions)

Definition at line 38 of file class.ilSkinStyleContainer.php.

Referenced by getMessageStack(), and setMessageStack().

◆ $skin

ilSkin ilSkinStyleContainer::$skin
protected

Data-scope for the skin this container capsules.

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

Referenced by __construct(), getSkin(), and setSkin().

◆ $system_styles_conf

ilSystemStyleConfig ilSkinStyleContainer::$system_styles_conf
protected

Used to wire this component up with the correct pathes into the customizing directory.

Definition at line 43 of file class.ilSkinStyleContainer.php.

Referenced by getSystemStylesConf(), and setSystemStylesConf().


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