ILIAS  release_7 Revision v7.30-3-g800a261c036
ilSystemStyleSkinContainer 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 ilSystemStyleSkinContainer:

Public Member Functions

 __construct (ilSkinXML $skin, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
 ilSystemStyleSkinContainer constructor. More...
 
 create (ilSystemStyleMessageStack $message_stack)
 Creates a new skin. More...
 
 updateSkin (ilSkinXML $old_skin=null)
 Updates the skin. More...
 
 updateStyle ($style_id, ilSkinStyleXML $old_style)
 Updates one single style. More...
 
 createMainLessFile (ilSkinStyleXML $style)
 Creates the main less file. More...
 
 copyVariablesFromDefault (ilSkinStyleXML $style)
 Copies (resets) the variables file from delos. More...
 
 resetImages (ilSkinStyleXML $style)
 Copies (resets) the images from delos. More...
 
 copyCSSFromDefault (ilSkinStyleXML $style)
 Copies (resets) the images from delos. More...
 
 move ($from, $to)
 Used to move a complete directory of a skin. More...
 
 delete ()
 Deletes the container of a skin completely. More...
 
 deleteStyle (ilSkinStyleXML $style)
 Deletes a style completely. More...
 
 copy (string $new_skin_txt_addon="Copy")
 Copies a complete Skin. More...
 
 export ()
 Exports the complete skin to an zip file. More...
 
 createTempZip ()
 Creates a temp zip file. More...
 
 compileLess ($style_id)
 
 getSkin ()
 
 setSkin ($skin)
 
 getSkinDirectory ()
 
 getCSSFilePath ($style_id)
 
 getLessFilePath ($style_id)
 
 getLessVariablesFilePath ($style_id)
 
 getLessVariablesName ($style_id)
 
 getImagesSkinPath ($style_id)
 
 addStyle (ilSkinStyleXML $style)
 
 getSystemStylesConf ()
 
 setSystemStylesConf ($system_styles_conf)
 

Static Public Member Functions

static generateFromId ($skin_id, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
 Generate the container class by parsing the corresponding XML. More...
 
static xCopy ($src, $dest)
 Recursive copy of a folder. More...
 
static recursiveRemoveDir ($dir)
 Recursive delete of a folder. More...
 
static import ($import_zip_path, $name, ilSystemStyleMessageStack $message_stack=null, $system_styles_conf=null, $uploaded=true)
 Imports a skin from zip. More...
 
static getMessageStack ()
 
static setMessageStack ($message_stack)
 

Protected Member Functions

 resourcesStyleReferences ($resource)
 Checks if a given resource (folder) is still referenced by a style of the containers skin. More...
 
 createResourceDirectory ($source, $target)
 Creates a resource directory (sound, images or fonts) by copying from the source (mostly delos) More...
 
 changeResourceDirectory ($new_dir, $old_dir)
 Alters the name/path of a resource directory. More...
 
 removeResourceDirectory ($dir)
 Deletes a resource directory. More...
 
 createLessStructure (ilSkinStyleXML $style)
 Creates the less/css structure of a style. More...
 
 getLessMainFileDefautContent (ilSkinStyleXML $style)
 Returns the main less default content if a new style is created. More...
 
 deleteFile ($path)
 Deletes a given file in the container. More...
 
 changeVariablesImport ($main_path, $old_style_import, $new_style_import)
 
 writeSkinToXML ()
 

Protected Attributes

 $lng
 
 $skin
 
 $system_styles_conf
 

Static Protected Attributes

static $message_stack = null
 

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.

Author
Timon Amstutz timon.nosp@m..ams.nosp@m.tutz@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$*

Definition at line 19 of file class.ilSystemStyleSkinContainer.php.

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleSkinContainer::__construct ( ilSkinXML  $skin,
ilSystemStyleMessageStack  $message_stack = null,
ilSystemStyleConfig  $system_styles_conf = null 
)

ilSystemStyleSkinContainer constructor.

Parameters
ilSkinXML$skin
ilSystemStyleMessageStack | null$message_stack
ilSystemStyleConfig$system_styles_conf

Definition at line 55 of file class.ilSystemStyleSkinContainer.php.

56 {
57 global $DIC;
58
59 $this->lng = $DIC->language();
60
61 $this->skin = $skin;
62
63 if (!$message_stack) {
65 } else {
66 $this->setMessageStack($message_stack);
67 }
68
71 } else {
72 $this->setSystemStylesConf($system_styles_conf);
73 }
74 }
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Used to stack messages to be shown to the user.
global $DIC
Definition: goto.php:24

References $DIC, $message_stack, $skin, $system_styles_conf, setMessageStack(), and setSystemStylesConf().

+ Here is the call graph for this function:

Member Function Documentation

◆ addStyle()

ilSystemStyleSkinContainer::addStyle ( ilSkinStyleXML  $style)
Parameters
ilSkinStyleXML$style

Definition at line 776 of file class.ilSystemStyleSkinContainer.php.

777 {
778 $this->getSkin()->addStyle($style);
779 $old_style = new ilSkinStyleXML("", "");
780 $this->updateStyle($style->getId(), $old_style);
781 }
updateStyle($style_id, ilSkinStyleXML $old_style)
Updates one single style.

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

+ Here is the call graph for this function:

◆ changeResourceDirectory()

ilSystemStyleSkinContainer::changeResourceDirectory (   $new_dir,
  $old_dir 
)
protected

Alters the name/path of a resource directory.

Parameters
$new_dir
$old_dir
Exceptions
ilSystemStyleException

Definition at line 270 of file class.ilSystemStyleSkinContainer.php.

271 {
272 $absolut_new_dir = $this->getSkinDirectory() . $new_dir;
273 $absolut_old_dir = $this->getSkinDirectory() . $old_dir;
274
275 if (file_exists($absolut_new_dir)) {
276 $this->getMessageStack()->addMessage(
278 $this->lng->txt("dir_changed_to") . " " . $absolut_new_dir,
280 )
281 );
282 $this->getMessageStack()->addMessage(
284 $this->lng->txt("dir_preserved_backup") . " " . $absolut_old_dir,
286 )
287 );
288 } else {
289 mkdir($absolut_new_dir, 0777, true);
290 self::xCopy($absolut_old_dir, $absolut_new_dir);
291 $this->getMessageStack()->addMessage(
293 $this->lng->txt("dir_copied_from") . " " . $absolut_old_dir . " " . $this->lng->txt("sty_copy_to") . " " . $absolut_new_dir,
295 )
296 );
297 if (count($this->resourcesStyleReferences($old_dir)) == 0) {
298 self::recursiveRemoveDir(self::getSkinDirectory() . $old_dir);
299 $this->getMessageStack()->addMessage(
301 $this->lng->txt("dir_deleted") . " " . $absolut_old_dir,
303 )
304 );
305 } else {
306 $this->getMessageStack()->addMessage(
308 $this->lng->txt("dir_preserved_linked") . " " . $absolut_old_dir,
310 )
311 );
312 }
313 }
314 }
static recursiveRemoveDir($dir)
Recursive delete of a folder.
static xCopy($src, $dest)
Recursive copy of a folder.
resourcesStyleReferences($resource)
Checks if a given resource (folder) is still referenced by a style of the containers skin.

References getMessageStack(), getSkinDirectory(), recursiveRemoveDir(), resourcesStyleReferences(), ilSystemStyleMessage\TYPE_SUCCESS, and xCopy().

Referenced by updateStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ changeVariablesImport()

ilSystemStyleSkinContainer::changeVariablesImport (   $main_path,
  $old_style_import,
  $new_style_import 
)
protected
Parameters
$main_path
$old_style_import
$new_style_import

Definition at line 656 of file class.ilSystemStyleSkinContainer.php.

657 {
658 $main_less_content = file_get_contents($main_path);
659 $main_less_content = str_replace(
660 "@import \"" . $old_style_import,
661 "@import \"" . $new_style_import,
662 $main_less_content
663 );
664 file_put_contents($main_path, $main_less_content);
665 }

Referenced by updateStyle().

+ Here is the caller graph for this function:

◆ compileLess()

ilSystemStyleSkinContainer::compileLess (   $style_id)
Parameters
$style_id
Exceptions
ilSystemStyleException

Definition at line 671 of file class.ilSystemStyleSkinContainer.php.

672 {
673 if (!PATH_TO_LESSC) {
675 }
676
677 $output = shell_exec(PATH_TO_LESSC . " " . $this->getLessFilePath($style_id));
678 if (!$output) {
679 $less_error = shell_exec(PATH_TO_LESSC . " " . $this->getLessFilePath($style_id) . " 2>&1");
680 if (!$less_error) {
681 throw new ilSystemStyleException(ilSystemStyleException::LESS_COMPILE_FAILED, "Empty css output, unknown error.");
682 }
684 }
685 file_put_contents($this->getCSSFilePath($style_id), $output);
686 }
Class for advanced editing exception handling in ILIAS.

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

Referenced by createLessStructure(), and updateStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copy()

ilSystemStyleSkinContainer::copy ( string  $new_skin_txt_addon = "Copy")

Copies a complete Skin.

Returns
ilSystemStyleSkinContainer
Exceptions
ilSystemStyleException

Definition at line 571 of file class.ilSystemStyleSkinContainer.php.

572 {
573 $new_skin_id_addon = "";
574 $new_skin_name_addon = "";
575
576 while (ilStyleDefinition::skinExists($this->getSkin()->getId() . $new_skin_id_addon, $this->getSystemStylesConf())) {
577 $new_skin_id_addon .= $new_skin_txt_addon;
578 $new_skin_name_addon .= " " . $new_skin_txt_addon;
579 }
580
581 $new_skin_path = rtrim($this->getSkinDirectory(), "/") . $new_skin_id_addon;
582
583 mkdir($new_skin_path, 0777, true);
584 $this->xCopy($this->getSkinDirectory(), $new_skin_path);
585 $this->getMessageStack()->addMessage(new ilSystemStyleMessage($this->lng->txt("directory_created") . " " . $new_skin_path, ilSystemStyleMessage::TYPE_SUCCESS));
586 $skin_container = self::generateFromId($this->getSkin()->getId() . $new_skin_id_addon, null, $this->getSystemStylesConf());
587 $skin_container->getSkin()->setName($skin_container->getSkin()->getName() . $new_skin_name_addon);
588 $skin_container->getSkin()->setVersion("0.1");
589 $skin_container->updateSkin($skin_container->getSkin());
590 return $skin_container;
591 }
static skinExists($skin_id, ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists.
static generateFromId($skin_id, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
Generate the container class by parsing the corresponding XML.

References generateFromId(), getMessageStack(), getSkin(), getSkinDirectory(), getSystemStylesConf(), ilStyleDefinition\skinExists(), ilSystemStyleMessage\TYPE_SUCCESS, and xCopy().

Referenced by copyCSSFromDefault(), updateStyle(), and xCopy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyCSSFromDefault()

ilSystemStyleSkinContainer::copyCSSFromDefault ( ilSkinStyleXML  $style)

Copies (resets) the images from delos.

Parameters
ilSkinStyleXML$style

Definition at line 406 of file class.ilSystemStyleSkinContainer.php.

407 {
408 copy($this->getSystemStylesConf()->getDelosPath() . ".css", $this->getCSSFilePath($style->getId()));
409 }
copy(string $new_skin_txt_addon="Copy")
Copies a complete Skin.

References copy(), getCSSFilePath(), ilSkinStyleXML\getId(), and getSystemStylesConf().

Referenced by createLessStructure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyVariablesFromDefault()

ilSystemStyleSkinContainer::copyVariablesFromDefault ( ilSkinStyleXML  $style)

Copies (resets) the variables file from delos.

Parameters
ilSkinStyleXML$style
Returns
ilSystemStyleLessFile

Definition at line 382 of file class.ilSystemStyleSkinContainer.php.

383 {
384 $less_file = new ilSystemStyleLessFile($this->getSystemStylesConf()->getDefaultVariablesPath());
385 $less_file->setLessVariablesFile($this->getLessVariablesFilePath($style->getId()));
386 $less_file->write();
387 return $less_file;
388 }

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

Referenced by createLessStructure(), and updateStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilSystemStyleSkinContainer::create ( ilSystemStyleMessageStack  $message_stack)

Creates a new skin.

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

Parameters
ilSystemStyleMessageStack$message_stack
Exceptions
ilSystemStyleException

Definition at line 108 of file class.ilSystemStyleSkinContainer.php.

109 {
110 if (file_exists($this->getSkinDirectory())) {
112 }
113
114
115 mkdir($this->getSkinDirectory(), 0777, true);
116
117 foreach ($this->getSkin()->getStyles() as $style) {
118 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultImagesPath(), $style->getImageDirectory());
119 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultSoundsPath(), $style->getSoundDirectory());
120 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultFontsPath(), $style->getFontDirectory());
121 try {
122 $this->createLessStructure($style);
123 } catch (Exception $e) {
124 $message_stack->addMessage(new ilSystemStyleMessage($this->lng->txt("less_compile_failed") . " " . $e->getMessage(), ilSystemStyleMessage::TYPE_ERROR));
125 }
126 }
127 $this->writeSkinToXML();
128 }
createResourceDirectory($source, $target)
Creates a resource directory (sound, images or fonts) by copying from the source (mostly delos)
createLessStructure(ilSkinStyleXML $style)
Creates the less/css structure of a style.

References Vendor\Package\$e, $message_stack, createLessStructure(), createResourceDirectory(), getSkin(), getSkinDirectory(), getSystemStylesConf(), ilSystemStyleException\SKIN_ALREADY_EXISTS, ilSystemStyleMessage\TYPE_ERROR, and writeSkinToXML().

+ Here is the call graph for this function:

◆ createLessStructure()

ilSystemStyleSkinContainer::createLessStructure ( ilSkinStyleXML  $style)
protected

Creates the less/css structure of a style.

Parameters
ilSkinStyleXML$style
Exceptions
ilSystemStyleException

Definition at line 351 of file class.ilSystemStyleSkinContainer.php.

352 {
353 $this->createMainLessFile($style);
354 $this->copyVariablesFromDefault($style);
355 $this->copyCSSFromDefault($style);
356 $this->compileLess($style->getId());
357 }
copyCSSFromDefault(ilSkinStyleXML $style)
Copies (resets) the images from delos.
copyVariablesFromDefault(ilSkinStyleXML $style)
Copies (resets) the variables file from delos.
createMainLessFile(ilSkinStyleXML $style)
Creates the main less file.

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

Referenced by create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createMainLessFile()

ilSystemStyleSkinContainer::createMainLessFile ( ilSkinStyleXML  $style)

Creates the main less file.

Parameters
ilSkinStyleXML$style

Definition at line 364 of file class.ilSystemStyleSkinContainer.php.

365 {
366 $path = $this->getLessFilePath($style->getId());
367 file_put_contents($path, $this->getLessMainFileDefautContent($style));
368 $this->getMessageStack()->addMessage(
370 $this->lng->txt("main_less_created") . " " . $path,
372 )
373 );
374 }
getLessMainFileDefautContent(ilSkinStyleXML $style)
Returns the main less default content if a new style is created.

References ilSkinStyleXML\getId(), getLessFilePath(), getLessMainFileDefautContent(), getMessageStack(), and ilSystemStyleMessage\TYPE_SUCCESS.

Referenced by createLessStructure(), and updateStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createResourceDirectory()

ilSystemStyleSkinContainer::createResourceDirectory (   $source,
  $target 
)
protected

Creates a resource directory (sound, images or fonts) by copying from the source (mostly delos)

Parameters
$source
$target
Exceptions
ilSystemStyleException

Definition at line 246 of file class.ilSystemStyleSkinContainer.php.

247 {
248 $path = $this->getSkinDirectory() . $target;
249
250 mkdir($path, 0777, true);
251
252 if ($source != "") {
253 self::xCopy($source, $path);
254 $this->getMessageStack()->addMessage(
256 $this->lng->txt("dir_created") . $path,
258 )
259 );
260 }
261 }
$source
Definition: metadata.php:76

References $source, getMessageStack(), getSkinDirectory(), ilSystemStyleMessage\TYPE_SUCCESS, and xCopy().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createTempZip()

ilSystemStyleSkinContainer::createTempZip ( )

Creates a temp zip file.

Returns
string $temp_path

Definition at line 606 of file class.ilSystemStyleSkinContainer.php.

607 {
608 $rel_tmp_zip = "../" . $this->getSkin()->getId() . ".zip";
609 ilUtil::zip($this->getSkinDirectory(), $rel_tmp_zip, true);
610 return rtrim($this->getSkinDirectory(), "/") . ".zip";
611 }
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file

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

Referenced by export().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilSystemStyleSkinContainer::delete ( )

Deletes the container of a skin completely.

Definition at line 500 of file class.ilSystemStyleSkinContainer.php.

501 {
502 self::recursiveRemoveDir(self::getSkinDirectory());
503 $this->getMessageStack()->addMessage(
505 $this->lng->txt("skin_deleted") . $this->getSkinDirectory(),
507 )
508 );
509 }

References getMessageStack(), recursiveRemoveDir(), and ilSystemStyleMessage\TYPE_SUCCESS.

+ Here is the call graph for this function:

◆ deleteFile()

ilSystemStyleSkinContainer::deleteFile (   $path)
protected

Deletes a given file in the container.

Parameters
$path

Definition at line 516 of file class.ilSystemStyleSkinContainer.php.

517 {
518 if (file_exists($path)) {
519 unlink($path);
520 $this->getMessageStack()->addMessage(
522 $this->lng->txt("file_deleted") . " " . $path,
524 )
525 );
526 }
527 }

References getMessageStack(), and ilSystemStyleMessage\TYPE_SUCCESS.

Referenced by deleteStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteStyle()

ilSystemStyleSkinContainer::deleteStyle ( ilSkinStyleXML  $style)

Deletes a style completely.

Parameters
ilSkinStyleXML$style

Definition at line 534 of file class.ilSystemStyleSkinContainer.php.

535 {
536 if ($style->isSubstyle()) {
538 $this->getMessageStack()->prependMessage(
540 $this->lng->txt("style_assignments_deleted") . " " . $style->getName(),
542 )
543 );
544 }
545
546 $this->deleteFile($this->getLessFilePath($style->getId()));
547 $this->deleteFile($this->getCSSFilePath($style->getId()));
548 $this->deleteFile($this->getLessVariablesFilePath($style->getId()));
549
550 $this->getSkin()->removeStyle($style->getId());
551
555
556 $this->writeSkinToXML();
557 $this->getMessageStack()->prependMessage(
559 $this->lng->txt("style_deleted") . " " . $style->getName(),
561 )
562 );
563 }
getSubstyleOf()
Returns the parent style of this style if set.
isSubstyle()
Return wheter this style is a substyle of another.
static deleteSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_substyle)
Delets a sub styles category assignment.
deleteFile($path)
Deletes a given file in the container.
removeResourceDirectory($dir)
Deletes a resource directory.

References deleteFile(), ilSystemStyleSettings\deleteSubStyleCategoryAssignments(), getCSSFilePath(), ilSkinStyleXML\getFontDirectory(), ilSkinStyleXML\getId(), ilSkinStyleXML\getImageDirectory(), getLessFilePath(), getLessVariablesFilePath(), getMessageStack(), ilSkinStyleXML\getName(), getSkin(), ilSkinStyleXML\getSoundDirectory(), ilSkinStyleXML\getSubstyleOf(), ilSkinStyleXML\isSubstyle(), removeResourceDirectory(), ilSystemStyleMessage\TYPE_SUCCESS, and writeSkinToXML().

+ Here is the call graph for this function:

◆ export()

ilSystemStyleSkinContainer::export ( )

Exports the complete skin to an zip file.

Definition at line 596 of file class.ilSystemStyleSkinContainer.php.

597 {
598 ilFileDelivery::deliverFileAttached($this->createTempZip(), $this->getSkin()->getId() . ".zip", '', true);
599 }
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void

References createTempZip(), ilFileDelivery\deliverFileAttached(), and getSkin().

+ Here is the call graph for this function:

◆ generateFromId()

static ilSystemStyleSkinContainer::generateFromId (   $skin_id,
ilSystemStyleMessageStack  $message_stack = null,
ilSystemStyleConfig  $system_styles_conf = null 
)
static

Generate the container class by parsing the corresponding XML.

Parameters
$skin_id
ilSystemStyleMessageStack | null$message_stack
ilSystemStyleConfig$system_styles_conf
Returns
ilSystemStyleSkinContainer
Exceptions
ilSystemStyleException

Definition at line 85 of file class.ilSystemStyleSkinContainer.php.

86 {
87 if (!$skin_id) {
89 }
90
93 }
94
95 if ($skin_id != "default") {
96 return new self(ilSkinXML::parseFromXML($system_styles_conf->getCustomizingSkinPath() . $skin_id . "/template.xml"), $message_stack, $system_styles_conf);
97 } else {
98 return new self(ilSkinXML::parseFromXML($system_styles_conf->getDefaultTemplatePath()), $message_stack, $system_styles_conf);
99 }
100 }

References $message_stack, $system_styles_conf, and ilSystemStyleException\NO_SKIN_ID.

Referenced by ilSystemStyleIconsGUI\__construct(), ilSystemStyleLessGUI\__construct(), ilSystemStyleOverviewGUI\checkDeletable(), ilSystemStyleOverviewGUI\confirmDelete(), copy(), ilSystemStyleOverviewGUI\copyStyle(), ilSystemStyleOverviewGUI\deleteStyle(), ilSystemStyleOverviewGUI\deleteStyles(), ilSystemStyleOverviewGUI\export(), import(), ilSystemStyleOverviewGUI\saveNewSubStyle(), ilSystemStyleSettingsGUI\saveStyle(), ilSystemStyleSettingsGUI\saveSubStyle(), ilSystemStyleMainGUI\setUnderworldTitle(), ilSkinStyleLessFileTest\setUp(), ilSystemStyleIconFolderTest\setUp(), ilSystemStyleIconTest\setUp(), ilSystemStyleStyleLessFileTest\setUp(), ilStyleDefinition\styleExistsForSkinId(), ilSystemStyleSkinContainerTest\testAddStyle(), ilSystemStyleSkinContainerTest\testCopySkin(), ilSystemStyleSkinContainerTest\testCopySkinWithInjectedName(), ilSystemStyleSkinContainerTest\testCreateDelete(), ilSystemStyleSkinContainerTest\testDeleteSkin(), ilSystemStyleSkinContainerTest\testDeleteStyle(), ilSystemStyleSkinContainerTest\testGenerateFromId(), ilSystemStyleSkinContainerTest\testImportSkin(), ilSystemStyleSkinContainerTest\testUpdateSkinNoIdChange(), ilSystemStyleSkinContainerTest\testUpdateSkinWithChangedID(), and ilSystemStyleSkinContainerTest\testUpdateStyle().

+ Here is the caller graph for this function:

◆ getCSSFilePath()

ilSystemStyleSkinContainer::getCSSFilePath (   $style_id)
Parameters
$style_id
Returns
string

Definition at line 716 of file class.ilSystemStyleSkinContainer.php.

717 {
718 return $this->getSkinDirectory() . $this->getSkin()->getStyle($style_id)->getCssFile() . ".css";
719 }

References getSkin(), and getSkinDirectory().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImagesSkinPath()

ilSystemStyleSkinContainer::getImagesSkinPath (   $style_id)
Parameters
$style_id
Returns
string

Definition at line 752 of file class.ilSystemStyleSkinContainer.php.

753 {
754 return $this->getSkinDirectory() . $this->getSkin()->getStyle($style_id)->getImageDirectory();
755 }

References getSkin(), and getSkinDirectory().

+ Here is the call graph for this function:

◆ getLessFilePath()

ilSystemStyleSkinContainer::getLessFilePath (   $style_id)
Parameters
$style_id
Returns
string

Definition at line 725 of file class.ilSystemStyleSkinContainer.php.

726 {
727 return $this->getSkinDirectory() . $this->getSkin()->getStyle($style_id)->getCssFile() . ".less";
728 }

References getSkin(), and getSkinDirectory().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLessMainFileDefautContent()

ilSystemStyleSkinContainer::getLessMainFileDefautContent ( ilSkinStyleXML  $style)
protected

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

Parameters
ilSkinStyleXML$style
Returns
string

Definition at line 476 of file class.ilSystemStyleSkinContainer.php.

477 {
478 $content = "@import \"" . $this->getSystemStylesConf()->getRelDelosPath() . "\";\n";
479 $content .= "// Import Custom Less Files here\n";
480
481 $content .= "@import \"" . $this->getLessVariablesName($style->getId()) . "\";\n";
482 return $content;
483 }

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

Referenced by createMainLessFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLessVariablesFilePath()

ilSystemStyleSkinContainer::getLessVariablesFilePath (   $style_id)
Parameters
$style_id
Returns
string

Definition at line 734 of file class.ilSystemStyleSkinContainer.php.

735 {
736 return $this->getSkinDirectory() . $this->getLessVariablesName($style_id);
737 }

References getLessVariablesName(), and getSkinDirectory().

Referenced by copyVariablesFromDefault(), and deleteStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLessVariablesName()

ilSystemStyleSkinContainer::getLessVariablesName (   $style_id)
Parameters
$style_id
Returns
string

Definition at line 743 of file class.ilSystemStyleSkinContainer.php.

744 {
745 return $this->getSkin()->getStyle($style_id)->getCssFile() . "-variables.less";
746 }

References getSkin().

Referenced by getLessMainFileDefautContent(), and getLessVariablesFilePath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMessageStack()

static ilSystemStyleSkinContainer::getMessageStack ( )
static

◆ getSkin()

ilSystemStyleSkinContainer::getSkin ( )

◆ getSkinDirectory()

ilSystemStyleSkinContainer::getSkinDirectory ( )
Returns
mixed

Definition at line 706 of file class.ilSystemStyleSkinContainer.php.

707 {
708 return $this->getSystemStylesConf()->getCustomizingSkinPath() . $this->getSkin()->getId() . "/";
709 }

References getSkin(), and getSystemStylesConf().

Referenced by changeResourceDirectory(), copy(), create(), createResourceDirectory(), createTempZip(), getCSSFilePath(), getImagesSkinPath(), getLessFilePath(), getLessVariablesFilePath(), removeResourceDirectory(), resetImages(), updateSkin(), updateStyle(), and writeSkinToXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSystemStylesConf()

ilSystemStyleSkinContainer::getSystemStylesConf ( )

◆ import()

static ilSystemStyleSkinContainer::import (   $import_zip_path,
  $name,
ilSystemStyleMessageStack  $message_stack = null,
  $system_styles_conf = null,
  $uploaded = true 
)
static

Imports a skin from zip.

Parameters
$import_zip_path
$name
ilSystemStyleMessageStack | null$message_stack
null$system_styles_conf
bool | true$uploaded
Returns
ilSystemStyleSkinContainer
Exceptions
ilSystemStyleException

Definition at line 624 of file class.ilSystemStyleSkinContainer.php.

625 {
626 if (!$system_styles_conf) {
628 }
629
630 $skin_id = preg_replace('/[^A-Za-z0-9\-_]/', '', rtrim($name, ".zip"));
631
633 $skin_id .= "Copy";
634 }
635
636 $skin_path = $system_styles_conf->getCustomizingSkinPath() . $skin_id;
637 mkdir($skin_path, 0777, true);
638
639 $temp_zip_path = $skin_path . "/" . $name;
640 if ($uploaded) {
641 move_uploaded_file($import_zip_path, $temp_zip_path);
642 } else {
643 rename($import_zip_path, $temp_zip_path);
644 }
645 ilUtil::unzip($temp_zip_path);
646 unlink($temp_zip_path);
647
649 }
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
if($format !==null) $name
Definition: metadata.php:230

References $message_stack, $name, $system_styles_conf, generateFromId(), ilStyleDefinition\skinExists(), and ilUtil\unzip().

Referenced by ilSystemStyleOverviewGUI\importStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ move()

ilSystemStyleSkinContainer::move (   $from,
  $to 
)

Used to move a complete directory of a skin.

Parameters
$from
$to

Definition at line 491 of file class.ilSystemStyleSkinContainer.php.

492 {
493 rename($from, $to);
494 }

Referenced by updateSkin().

+ Here is the caller graph for this function:

◆ recursiveRemoveDir()

static ilSystemStyleSkinContainer::recursiveRemoveDir (   $dir)
static

Recursive delete of a folder.

Parameters
$dir

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

453 {
454 if (is_dir($dir)) {
455 $objects = scandir($dir);
456 foreach ($objects as $object) {
457 if ($object != "." && $object != "..") {
458 if (is_dir($dir . "/" . $object)) {
459 self::recursiveRemoveDir($dir . "/" . $object);
460 } else {
461 unlink($dir . "/" . $object);
462 }
463 }
464 }
465 rmdir($dir);
466 }
467 }

References recursiveRemoveDir().

Referenced by changeResourceDirectory(), delete(), recursiveRemoveDir(), removeResourceDirectory(), resetImages(), ilSkinStyleLessFileTest\tearDown(), ilSkinXMLTest\tearDown(), ilSystemStyleIconFolderTest\tearDown(), ilSystemStyleIconTest\tearDown(), ilSystemStyleSkinContainerTest\tearDown(), ilSystemStyleSkinXMLTest\tearDown(), and ilSystemStyleStyleLessFileTest\tearDown().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeResourceDirectory()

ilSystemStyleSkinContainer::removeResourceDirectory (   $dir)
protected

Deletes a resource directory.

Parameters
$dir

Definition at line 321 of file class.ilSystemStyleSkinContainer.php.

322 {
323 $absolut_dir = $this->getSkinDirectory() . $dir;
324
325 if (file_exists($absolut_dir)) {
326 if (count($this->resourcesStyleReferences($dir)) == 0) {
328 $this->getMessageStack()->addMessage(
330 $this->lng->txt("dir_deleted") . " " . $dir,
332 )
333 );
334 } else {
335 $this->getMessageStack()->addMessage(
337 $this->lng->txt("dir_preserved_linked") . " " . $dir,
339 )
340 );
341 }
342 }
343 }

References getMessageStack(), getSkinDirectory(), recursiveRemoveDir(), resourcesStyleReferences(), and ilSystemStyleMessage\TYPE_SUCCESS.

Referenced by deleteStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetImages()

ilSystemStyleSkinContainer::resetImages ( ilSkinStyleXML  $style)

Copies (resets) the images from delos.

Parameters
ilSkinStyleXML$style

Definition at line 395 of file class.ilSystemStyleSkinContainer.php.

396 {
398 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultImagesPath(), $style->getImageDirectory());
399 }

References createResourceDirectory(), ilSkinStyleXML\getImageDirectory(), getSkinDirectory(), getSystemStylesConf(), and recursiveRemoveDir().

+ Here is the call graph for this function:

◆ resourcesStyleReferences()

ilSystemStyleSkinContainer::resourcesStyleReferences (   $resource)
protected

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

Parameters
$resource
Returns
array

Definition at line 228 of file class.ilSystemStyleSkinContainer.php.

229 {
230 $references_ids = array();
231 foreach ($this->getSkin()->getStyles() as $style) {
232 if ($style->referencesResource($resource)) {
233 $references_ids[] = $style->getId();
234 }
235 }
236 return $references_ids;
237 }

References getSkin().

Referenced by changeResourceDirectory(), and removeResourceDirectory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMessageStack()

static ilSystemStyleSkinContainer::setMessageStack (   $message_stack)
static
Parameters
ilSystemStyleMessageStack$message_stack

Definition at line 768 of file class.ilSystemStyleSkinContainer.php.

769 {
770 self::$message_stack = $message_stack;
771 }

References $message_stack.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setSkin()

ilSystemStyleSkinContainer::setSkin (   $skin)
Parameters
ilSkinXML$skin

Definition at line 698 of file class.ilSystemStyleSkinContainer.php.

699 {
700 $this->skin = $skin;
701 }

References $skin.

◆ setSystemStylesConf()

ilSystemStyleSkinContainer::setSystemStylesConf (   $system_styles_conf)
Parameters
ilSystemStyleConfig$system_styles_conf

Definition at line 799 of file class.ilSystemStyleSkinContainer.php.

800 {
801 $this->system_styles_conf = $system_styles_conf;
802 }

References $system_styles_conf.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ updateSkin()

ilSystemStyleSkinContainer::updateSkin ( ilSkinXML  $old_skin = null)

Updates the skin.

Style are not updated, use updateStyle for that.

Parameters
ilSkinXML$old_skin
Exceptions
ilSystemStyleException

Definition at line 136 of file class.ilSystemStyleSkinContainer.php.

137 {
138 if (!$old_skin) {
139 $old_skin = $this->getSkin();
140 }
141 $old_customizing_skin_directory = $this->getSystemStylesConf()->getCustomizingSkinPath() . $old_skin->getId() . "/";
142
143 //Move if skin id has been changed
144 if ($old_skin->getId() != $this->getSkin()->getId()) {
145 $this->move($old_customizing_skin_directory, $this->getSkinDirectory());
146 }
147
148 //Delete old template.xml and write a new one
149 unlink($this->getSkinDirectory() . "template.xml");
150 $this->writeSkinToXML();
151 }
move($from, $to)
Used to move a complete directory of a skin.

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

+ Here is the call graph for this function:

◆ updateStyle()

ilSystemStyleSkinContainer::updateStyle (   $style_id,
ilSkinStyleXML  $old_style 
)

Updates one single style.

Parameters
$style_id
ilSkinStyleXML$old_style

Definition at line 159 of file class.ilSystemStyleSkinContainer.php.

160 {
161 $style = $this->getSkin()->getStyle($style_id);
162
163 if ($style->getImageDirectory() != $old_style->getImageDirectory()) {
164 if (file_exists($this->getSkinDirectory() . $old_style->getImageDirectory())) {
165 $this->changeResourceDirectory($style->getImageDirectory(), $old_style->getImageDirectory());
166 } else {
167 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultImagesPath(), $style->getImageDirectory());
168 }
169 }
170
171 if ($style->getFontDirectory() != $old_style->getFontDirectory()) {
172 if (file_exists($this->getSkinDirectory() . $old_style->getFontDirectory())) {
173 $this->changeResourceDirectory($style->getFontDirectory(), $old_style->getFontDirectory());
174 } else {
175 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultFontsPath(), $style->getFontDirectory());
176 }
177 }
178
179 if ($style->getSoundDirectory() != $old_style->getSoundDirectory()) {
180 if (file_exists($this->getSkinDirectory() . $old_style->getSoundDirectory())) {
181 $this->changeResourceDirectory($style->getSoundDirectory(), $old_style->getSoundDirectory());
182 } else {
183 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultSoundsPath(), $style->getSoundDirectory());
184 }
185 }
186
187
188
189 if (file_exists($this->getSkinDirectory() . $old_style->getCssFile() . ".less")) {
190 rename($this->getSkinDirectory() . $old_style->getCssFile() . ".less", $this->getLessFilePath($style->getId()));
191 } else {
192 $this->createMainLessFile($style);
193 }
194
195 if (file_exists($this->getSkinDirectory() . $old_style->getCssFile() . "-variables.less")) {
196 rename($this->getSkinDirectory() . $old_style->getCssFile() . "-variables.less", $this->getLessVariablesFilePath($style->getId()));
197 } else {
198 $this->copyVariablesFromDefault($style);
199 }
200
201 $this->changeVariablesImport($this->getLessFilePath($style->getId()), $old_style->getCssFile() . "-variables.less", $this->getLessVariablesName($style->getId()));
202
203 if (file_exists($this->getSkinDirectory() . $old_style->getCssFile() . ".css")) {
204 rename($this->getSkinDirectory() . $old_style->getCssFile() . ".css", $this->getCSSFilePath($style->getId()));
205 } else {
206 try {
207 $this->compileLess($style->getId());
208 } catch (Exception $e) {
209 $this->getMessageStack()->addMessage(
211 $e->getMessage(),
213 )
214 );
215 copy($this->getSystemStylesConf()->getDelosPath() . ".css", $this->getCSSFilePath($style->getId()));
216 }
217 }
218
219 $this->writeSkinToXML();
220 }
changeResourceDirectory($new_dir, $old_dir)
Alters the name/path of a resource directory.
changeVariablesImport($main_path, $old_style_import, $new_style_import)

References Vendor\Package\$e, changeResourceDirectory(), changeVariablesImport(), compileLess(), copy(), copyVariablesFromDefault(), createMainLessFile(), createResourceDirectory(), ilSkinStyleXML\getCssFile(), getCSSFilePath(), ilSkinStyleXML\getFontDirectory(), ilSkinStyleXML\getImageDirectory(), getLessFilePath(), getMessageStack(), getSkin(), getSkinDirectory(), ilSkinStyleXML\getSoundDirectory(), getSystemStylesConf(), ilSystemStyleMessage\TYPE_ERROR, and writeSkinToXML().

Referenced by addStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeSkinToXML()

ilSystemStyleSkinContainer::writeSkinToXML ( )
protected

Definition at line 783 of file class.ilSystemStyleSkinContainer.php.

784 {
785 $this->getSkin()->writeToXMLFile($this->getSkinDirectory() . "template.xml");
786 }

References getSkin(), and getSkinDirectory().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ xCopy()

static ilSystemStyleSkinContainer::xCopy (   $src,
  $dest 
)
static

Recursive copy of a folder.

Parameters
$src
$dest
Exceptions
ilSystemStyleException

Definition at line 418 of file class.ilSystemStyleSkinContainer.php.

419 {
420 foreach (scandir($src) as $file) {
421 $src_file = rtrim($src, '/') . '/' . $file;
422 $dest_file = rtrim($dest, '/') . '/' . $file;
423 if (!is_readable($src_file)) {
425 }
426 if (substr($file, 0, 1) != ".") {
427 if (is_dir($src_file)) {
428 if (!file_exists($dest_file)) {
429 try {
430 mkdir($dest_file);
431 } catch (Exception $e) {
432 throw new ilSystemStyleException(ilSystemStyleException::FOLDER_CREATION_FAILED, "Copy " . $src_file . " to " . $dest_file . " Error: " . $e);
433 }
434 }
435 self::xCopy($src_file, $dest_file);
436 } else {
437 try {
438 copy($src_file, $dest_file);
439 } catch (Exception $e) {
440 throw new ilSystemStyleException(ilSystemStyleException::FILE_CREATION_FAILED, "Copy " . $src_file . " to " . $dest_file . " Error: " . $e);
441 }
442 }
443 }
444 }
445 }

References Vendor\Package\$e, copy(), ilSystemStyleException\FILE_CREATION_FAILED, ilSystemStyleException\FILE_OPENING_FAILED, ilSystemStyleException\FOLDER_CREATION_FAILED, and xCopy().

Referenced by changeResourceDirectory(), copy(), createResourceDirectory(), ilSkinStyleLessFileTest\setUp(), ilSkinXMLTest\setUp(), ilSystemStyleIconFolderTest\setUp(), ilSystemStyleIconTest\setUp(), ilSystemStyleSkinContainerTest\setUp(), ilSystemStyleSkinXMLTest\setUp(), ilSystemStyleStyleLessFileTest\setUp(), and xCopy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $lng

ilSystemStyleSkinContainer::$lng
protected

Definition at line 25 of file class.ilSystemStyleSkinContainer.php.

◆ $message_stack

ilSystemStyleSkinContainer::$message_stack = null
staticprotected

◆ $skin

ilSystemStyleSkinContainer::$skin
protected

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

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

◆ $system_styles_conf

ilSystemStyleSkinContainer::$system_styles_conf
protected

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