ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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...
 
 createMainScssFile (ilSkinStyle $style)
 Creates the main Scss file. More...
 
 copySettingsFromDefault (ilSkinStyle $style)
 Copies (resets) the settings files 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...
 
 compileScss (string $style_id)
 
 getSkin ()
 
 setSkin (ilSkin $skin)
 
 getSkinDirectory ()
 
 getCSSFilePath (string $style_id)
 
 getScssFilePath (string $style_id)
 
 getScssSettingsPath (string $style_id)
 
 getScssSettingsFolderName ()
 
 getImagesStylePath (string $style_id)
 
 getSoundsStylePath (string $style_id)
 
 getFontsStylePath (string $style_id)
 
 getMessageStack ()
 
 setMessageStack (ilSystemStyleMessageStack $message_stack)
 
 addStyle (ilSkinStyle $style)
 
 getSystemStylesConf ()
 
 setSystemStylesConf (ilSystemStyleConfig $system_styles_conf)
 

Protected Member Functions

 createScssStructure (ilSkinStyle $style)
 Creates the Scss/css structure of a style. More...
 
 getNewMainScssFileContent (string $replacement_start, string $replacement_end)
 
 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 492 of file class.ilSkinStyleContainer.php.

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

Referenced by ilSkinStyleContainerTest\testAddStyle(), and ilSkinStyleContainerTest\testAddSubstyle().

492  : void
493  {
494  $this->getSkin()->addStyle($style);
495  $old_style = new ilSkinStyle('', '', '-', '-', '-', '-');
496  $this->updateStyle($style->getId(), $old_style);
497  }
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:

◆ compileScss()

ilSkinStyleContainer::compileScss ( string  $style_id)
Exceptions
ilSystemStyleException

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

References getCSSFilePath(), getScssFilePath(), ilSystemStyleException\SCSS_COMPILE_FAILED, and ilSystemStyleException\SCSS_NOT_INSTALLED.

Referenced by createScssStructure(), and updateStyle().

412  : void
413  {
414  if (!PATH_TO_SCSS) {
416  }
417 
418  $output = shell_exec(PATH_TO_SCSS . ' ' . $this->getScssFilePath($style_id));
419  if (!$output) {
420  $Scss_error = shell_exec(PATH_TO_SCSS . ' ' . $this->getScssFilePath($style_id) . ' 2>&1');
421  if (!$Scss_error) {
422  throw new ilSystemStyleException(
424  'Empty css output, unknown error.'
425  );
426  }
428  }
429  file_put_contents($this->getCSSFilePath($style_id), $output);
430  }
+ 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 317 of file class.ilSkinStyleContainer.php.

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

Referenced by createScssStructure().

317  : void
318  {
319  copy($this->getSystemStylesConf()->getDelosPath() . '.css', $this->getCSSFilePath($style->getId()));
320  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copySettingsFromDefault()

ilSkinStyleContainer::copySettingsFromDefault ( ilSkinStyle  $style)

Copies (resets) the settings files from delos.

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

References ILIAS\LTI\ToolProvider\$settings, ilSkinStyle\getId(), getScssSettingsFolderName(), getScssSettingsPath(), getSkinDirectory(), and getSystemStylesConf().

Referenced by createScssStructure(), and updateStyle().

282  {
283  if (is_dir($this->getScssSettingsPath($style->getId()))) {
284  $this->file_system->removeResourceDirectory($this->getSkinDirectory(), $style->getId()."/".$this->getScssSettingsFolderName());
285  }
286 
287  $this->file_system->createResourceDirectory(
288  $this->getSystemStylesConf()->getDefaultSettingsPath(),
289  $this->getScssSettingsPath($style->getId())
290  );
291 
293 
294  $settings->readAndreplaceContentOfFolder([
295  "@use \"../030-tools/" => "@use \"../../../../../../templates/default/030-tools/",
296  "@use \"../050-layout/" => "@use \"../../../../../../templates/default/050-layout/"
297  ]);
298 
299  return $settings;
300  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
+ 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 getSkin(), getSkinDirectory(), ilSystemStyleException\SKIN_ALREADY_EXISTS, updateStyle(), and writeSkinToXML().

Referenced by ilSkinStyleContainerTest\testCreateDelete().

75  : void
76  {
77  if (file_exists($this->getSkinDirectory())) {
79  }
80 
81  mkdir($this->getSkinDirectory(), 0775, true);
82 
83  foreach ($this->getSkin()->getStyles() as $style) {
84  $old_style = new ilSkinStyle('', '', '-', '-', '-', '-');
85  $this->updateStyle($style->getId(), $old_style);
86  }
87  $this->writeSkinToXML();
88  }
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:

◆ createMainScssFile()

ilSkinStyleContainer::createMainScssFile ( ilSkinStyle  $style)

Creates the main Scss file.

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

References $path, ILIAS\LTI\ToolProvider\$settings, ilSkinStyle\getId(), getMessageStack(), getNewMainScssFileContent(), getScssFilePath(), getScssSettingsPath(), ILIAS\Repository\lng(), and ilSystemStyleMessage\TYPE_SUCCESS.

Referenced by createScssStructure(), and updateStyle().

229  : void
230  {
231 
232  $replacement_start = "// ## Begin Replacement Variables";
233  $replacement_end = "// ## End Replacement Variables";
234 
235  $path = $this->getScssFilePath($style->getId());
236 
237  if(!is_file($path)) {
238  $main_scss_content = $this->getNewMainScssFileContent($replacement_start, $replacement_end);
239  } else {
240  $main_scss_content = file_get_contents($path);
241  }
242 
243  $regex_part_to_replace_start = "%$replacement_start.*?$replacement_end%s";
245  $replacement = $settings->getVariablesForDelosOverride();
246  $new_variabales_content = "$replacement_start $replacement $replacement_end";
247 
248  $main_scss_content = preg_replace(
249  $regex_part_to_replace_start,
250  $new_variabales_content,
251  $main_scss_content
252  );
253 
254  file_put_contents($path, $main_scss_content);
255 
256  $this->getMessageStack()->addMessage(
258  $this->lng->txt('main_scss_created') . ' ' . $path,
260  )
261  );
262  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
getNewMainScssFileContent(string $replacement_start, string $replacement_end)
$path
Definition: ltiservices.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createScssStructure()

ilSkinStyleContainer::createScssStructure ( ilSkinStyle  $style)
protected

Creates the Scss/css structure of a style.

Exceptions
ilSystemStyleException

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

References compileScss(), copyCSSFromDefault(), copySettingsFromDefault(), createMainScssFile(), and ilSkinStyle\getId().

218  : void
219  {
220  $this->copySettingsFromDefault($style);
221  $this->createMainScssFile($style);
222  $this->copyCSSFromDefault($style);
223  $this->compileScss($style->getId());
224  }
createMainScssFile(ilSkinStyle $style)
Creates the main Scss file.
copySettingsFromDefault(ilSkinStyle $style)
Copies (resets) the settings files from delos.
copyCSSFromDefault(ilSkinStyle $style)
Copies (resets) the images from delos.
+ Here is the call graph for this function:

◆ createTempZip()

ilSkinStyleContainer::createTempZip ( )

Creates a temp zip file.

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

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

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

399  : string
400  {
401  $skin_directory = $this->getSkinDirectory(); // parent of skin directory
402  $output_file = dirname($skin_directory) . '/' . $this->getSkin()->getId() . '.zip';
403 
404  ilFileUtils::zip($skin_directory, $output_file, true);
405 
406  return $output_file;
407  }
static zip(string $a_dir, string $a_file, bool $compress_content=false)
+ 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 325 of file class.ilSkinStyleContainer.php.

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

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

325  : void
326  {
327  $this->file_system->recursiveRemoveDir(self::getSkinDirectory());
328  $this->getMessageStack()->addMessage(
330  $this->lng->txt('skin_deleted') . $this->getSkinDirectory(),
332  )
333  );
334  }
+ 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 339 of file class.ilSkinStyleContainer.php.

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

Referenced by ilSkinStyleContainerTest\testDeleteStyle().

339  : void
340  {
341  if ($style->isSubstyle()) {
343  $this->getSkin()->getId(),
344  $style->getSubstyleOf(),
345  $style->getId()
346  );
347  $this->getMessageStack()->prependMessage(
349  $this->lng->txt('style_assignments_deleted') . ' ' . $style->getName(),
351  )
352  );
353  }
354 
355  $this->file_system->saveDeleteFile($this->getScssFilePath($style->getId()));
356  $this->file_system->saveDeleteFile($this->getCSSFilePath($style->getId()));
357  $this->file_system->removeResourceDirectory($this->getSkinDirectory(), $style->getId(), false);
358 
359  $this->getSkin()->removeStyle($style->getId());
360 
361  $this->file_system->removeResourceDirectory(
362  $this->getSkinDirectory(),
363  $style->getImageDirectory()
364  );
365  $this->file_system->removeResourceDirectory(
366  $this->getSkinDirectory(),
367  $style->getFontDirectory()
368  );
369  $this->file_system->removeResourceDirectory(
370  $this->getSkinDirectory(),
371  $style->getSoundDirectory()
372  );
373 
374  $this->writeSkinToXML();
375  $this->getMessageStack()->prependMessage(
377  $this->lng->txt('style_deleted') . ' ' . $style->getName(),
379  )
380  );
381  }
static deleteSubStyleCategoryAssignments(string $a_skin_id, string $a_style_id, string $a_substyle)
Delets a sub styles category assignment.
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 386 of file class.ilSkinStyleContainer.php.

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

386  : void
387  {
389  $this->createTempZip(),
390  $this->getSkin()->getId() . '.zip',
391  '',
392  true
393  );
394  }
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 447 of file class.ilSkinStyleContainer.php.

References getSkinDirectory().

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

447  : string
448  {
449  return $this->getSkinDirectory() . $style_id . "/".$this->getSkin()->getStyle($style_id)->getCssFile() . '.css';
450  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFontsStylePath()

ilSkinStyleContainer::getFontsStylePath ( string  $style_id)

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

References getSkin(), and getSkinDirectory().

Referenced by updateStyle().

477  : string
478  {
479  return $this->getSkinDirectory().$style_id."/".$this->getSkin()->getStyle($style_id)->getFontDirectory();
480  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImagesStylePath()

ilSkinStyleContainer::getImagesStylePath ( string  $style_id)

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

References getSkin(), and getSkinDirectory().

Referenced by resetImages(), and updateStyle().

467  : string
468  {
469  return $this->getSkinDirectory().$style_id."/".$this->getSkin()->getStyle($style_id)->getImageDirectory();
470  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMessageStack()

ilSkinStyleContainer::getMessageStack ( )

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

References $message_stack.

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

483  {
484  return $this->message_stack;
485  }
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:

◆ getNewMainScssFileContent()

ilSkinStyleContainer::getNewMainScssFileContent ( string  $replacement_start,
string  $replacement_end 
)
protected

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

References getScssSettingsFolderName(), and getSystemStylesConf().

Referenced by createMainScssFile().

264  : string
265  {
266  return "// # ITCSS structure
267  // Try to apply changes by only changing the variables in the settings
268  @use \"./" . $this->getScssSettingsFolderName() . "\" as globals;
269 
270  // Default Skin is loaded with the custom setting being applied.
271  @use \"" . $this->getSystemStylesConf()->getRelDelosPath() . "\" with ( \n".
272  $replacement_start . "\n" .
273  $replacement_end . "\n" .
274  ");" . "\n" .
275  "// Apply/load other styling changes here.";
276  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getScssFilePath()

ilSkinStyleContainer::getScssFilePath ( string  $style_id)

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

References getSkinDirectory().

Referenced by compileScss(), createMainScssFile(), deleteStyle(), and updateStyle().

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

◆ getScssSettingsFolderName()

ilSkinStyleContainer::getScssSettingsFolderName ( )

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

Referenced by copySettingsFromDefault(), getNewMainScssFileContent(), and updateStyle().

462  : string
463  {
464  return $this->system_styles_conf->getScssSettingsFolderName();
465  }
+ Here is the caller graph for this function:

◆ getScssSettingsPath()

ilSkinStyleContainer::getScssSettingsPath ( string  $style_id)

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

References getSkinDirectory().

Referenced by copySettingsFromDefault(), createMainScssFile(), and updateStyle().

457  : string
458  {
459  return $this->getSkinDirectory() . $style_id . "/".$this->getScssSettingsFolderName();
460  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSkin()

◆ getSkinDirectory()

ilSkinStyleContainer::getSkinDirectory ( )

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

References getSkin(), and getSystemStylesConf().

Referenced by ilSkinFactory\copyFromSkinStyleContainer(), copySettingsFromDefault(), create(), createTempZip(), delete(), deleteStyle(), getCSSFilePath(), getFontsStylePath(), getImagesStylePath(), getScssFilePath(), getScssSettingsPath(), getSoundsStylePath(), updateSkin(), updateStyle(), and writeSkinToXML().

442  : string
443  {
444  return $this->getSystemStylesConf()->getCustomizingSkinPath() . $this->getSkin()->getId() . '/';
445  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSoundsStylePath()

ilSkinStyleContainer::getSoundsStylePath ( string  $style_id)

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

References getSkin(), and getSkinDirectory().

Referenced by updateStyle().

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

◆ getSystemStylesConf()

ilSkinStyleContainer::getSystemStylesConf ( )

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

References $system_styles_conf.

Referenced by copyCSSFromDefault(), ilSkinFactory\copyFromSkinStyleContainer(), copySettingsFromDefault(), getNewMainScssFileContent(), getSkinDirectory(), resetImages(), updateSkin(), and updateStyle().

505  {
507  }
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 305 of file class.ilSkinStyleContainer.php.

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

305  : void
306  {
307  $this->file_system->recursiveRemoveDir($this->getImagesStylePath($style->getId()));
308  $this->file_system->createResourceDirectory(
309  $this->getSystemStylesConf()->getDefaultImagesPath(),
310  $this->getImagesStylePath($style->getId())
311  );
312  }
+ Here is the call graph for this function:

◆ setMessageStack()

ilSkinStyleContainer::setMessageStack ( ilSystemStyleMessageStack  $message_stack)

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

References $message_stack.

Referenced by __construct().

487  : void
488  {
489  $this->message_stack = $message_stack;
490  }
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 437 of file class.ilSkinStyleContainer.php.

References $skin.

437  : void
438  {
439  $this->skin = $skin;
440  }
ilSkin $skin
Data-scope for the skin this container capsules.

◆ setSystemStylesConf()

ilSkinStyleContainer::setSystemStylesConf ( ilSystemStyleConfig  $system_styles_conf)

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

References $system_styles_conf.

Referenced by __construct().

509  : void
510  {
511  $this->system_styles_conf = $system_styles_conf;
512  }
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 94 of file class.ilSkinStyleContainer.php.

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

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

94  : void
95  {
96  if (!$old_skin) {
97  $old_skin = $this->getSkin();
98  }
99  $old_customizing_skin_directory = $this->getSystemStylesConf()->getCustomizingSkinPath() . $old_skin->getId() . '/';
100 
101  //Move if skin id has been changed
102  if ($old_skin->getId() != $this->getSkin()->getId()) {
103  $this->file_system->move($old_customizing_skin_directory, $this->getSkinDirectory());
104  }
105 
106  //Delete old template.xml and write a new one
107  $this->file_system->delete($this->getSkinDirectory() . 'template.xml');
108  $this->writeSkinToXML();
109  }
+ 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 114 of file class.ilSkinStyleContainer.php.

References Vendor\Package\$e, compileScss(), copySettingsFromDefault(), createMainScssFile(), ilSkinStyle\getCssFile(), getCSSFilePath(), ilSkinStyle\getFontDirectory(), getFontsStylePath(), ilSkinStyle\getId(), ilSkinStyle\getImageDirectory(), getImagesStylePath(), getMessageStack(), getScssFilePath(), getScssSettingsFolderName(), getScssSettingsPath(), getSkin(), getSkinDirectory(), ilSkinStyle\getSoundDirectory(), getSoundsStylePath(), getSystemStylesConf(), ilSystemStyleMessage\TYPE_ERROR, and writeSkinToXML().

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

114  : void
115  {
116  $style = $this->getSkin()->getStyle($style_id);
117 
118  if(!is_dir($this->getSkinDirectory().$style->getId())) {
119  mkdir($this->getSkinDirectory().$style->getId(), 0775, true);
120  }
121 
122  if ($style->getId()."/".$style->getImageDirectory() != $old_style->getId()."/".$old_style->getImageDirectory()
123  && !is_dir($this->getImagesStylePath($style->getId()))) {
124  if (is_dir($this->getSkinDirectory() .$old_style->getId()."/". $old_style->getImageDirectory())) {
125  $this->file_system->changeResourceDirectory(
126  $this->getSkinDirectory(),
127  $style->getId()."/".$style->getImageDirectory(),
128  $old_style->getId()."/".$old_style->getImageDirectory()
129  );
130  } else {
131  $this->file_system->createResourceDirectory(
132  $this->getSystemStylesConf()->getDefaultImagesPath(),
133  $this->getImagesStylePath($style->getId())
134  );
135  }
136  }
137 
138  if ($style->getId()."/".$style->getFontDirectory() != $old_style->getId()."/".$old_style->getFontDirectory()
139  && !is_dir($this->getFontsStylePath($style->getId()))) {
140  if (is_dir($this->getSkinDirectory() . $old_style->getId()."/". $old_style->getFontDirectory())) {
141  $this->file_system->changeResourceDirectory(
142  $this->getSkinDirectory(),
143  $style->getId()."/".$style->getFontDirectory(),
144  $old_style->getId()."/".$old_style->getFontDirectory()
145  );
146  } else {
147  $this->file_system->createResourceDirectory(
148  $this->getSystemStylesConf()->getDefaultFontsPath(),
149  $this->getFontsStylePath($style->getId())
150  );
151  }
152  }
153 
154  if ($style->getId()."/".$style->getSoundDirectory() != $old_style->getId()."/".$old_style->getSoundDirectory()
155  && !is_dir($this->getSoundsStylePath($style->getId()))) {
156  if (is_dir($this->getSkinDirectory() . $old_style->getId()."/". $old_style->getSoundDirectory())) {
157  $this->file_system->changeResourceDirectory(
158  $this->getSkinDirectory(),
159  $style->getId()."/".$style->getSoundDirectory(),
160  $old_style->getId()."/".$old_style->getSoundDirectory()
161  );
162  } else {
163  $this->file_system->createResourceDirectory(
164  $this->getSystemStylesConf()->getDefaultSoundsPath(),
165  $this->getSoundsStylePath($style->getId())
166  );
167  }
168  }
169 
170  if($style->getId() != $old_style->getId()) {
171  if (is_dir($this->getScssSettingsPath($old_style->getId()))) {
172  $this->file_system->changeResourceDirectory(
173  $this->getSkinDirectory(),
174  $style->getId().'/'.$this->getScssSettingsFolderName(),
175  $old_style->getId().'/'.$this->getScssSettingsFolderName()
176  );
177  } elseif(!is_dir($this->getScssSettingsPath($old_style->getId()))) {
178  $this->copySettingsFromDefault($style);
179  }
180 
181  if (file_exists($this->getSkinDirectory() .$old_style->getId().'/'.$old_style->getCssFile() . '.scss')) {
182  rename(
183  $this->getSkinDirectory().$old_style->getId().'/'.$old_style->getCssFile().'.scss',
184  $this->getScssFilePath($style->getId())
185  );
186  } else {
187  $this->createMainScssFile($style);
188  }
189 
190  if (file_exists($this->getSkinDirectory().$old_style->getId().'/'.$old_style->getCssFile().'.css')) {
191  rename(
192  $this->getSkinDirectory().$old_style->getId().'/'.$old_style->getCssFile().'.css',
193  $this->getCSSFilePath($style->getId())
194  );
195  } else {
196  try {
197  $this->compileScss($style->getId());
198  } catch (Exception $e) {
199  $this->getMessageStack()->addMessage(
201  $e->getMessage(),
203  )
204  );
205  copy($this->getSystemStylesConf()->getDelosPath() . '.css', $this->getCSSFilePath($style->getId()));
206  }
207  }
208  }
209 
210 
211  $this->writeSkinToXML();
212  }
createMainScssFile(ilSkinStyle $style)
Creates the main Scss file.
copySettingsFromDefault(ilSkinStyle $style)
Copies (resets) the settings files from delos.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeSkinToXML()

ilSkinStyleContainer::writeSkinToXML ( )
protected

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

References getSkin(), and getSkinDirectory().

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

499  : void
500  {
501  $this->getSkin()->writeToXMLFile($this->getSkinDirectory() . 'template.xml');
502  }
+ 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: