ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 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 ()
 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: saml.php:7

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 767 of file class.ilSystemStyleSkinContainer.php.

768 {
769 $this->getSkin()->addStyle($style);
770 $old_style = new ilSkinStyleXML("", "");
771 $this->updateStyle($style->getId(), $old_style);
772 }
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 267 of file class.ilSystemStyleSkinContainer.php.

268 {
269 $absolut_new_dir = $this->getSkinDirectory() . $new_dir;
270 $absolut_old_dir = $this->getSkinDirectory() . $old_dir;
271
272 if (file_exists($absolut_new_dir)) {
273 $this->getMessageStack()->addMessage(
275 $this->lng->txt("dir_changed_to") . " " . $absolut_new_dir,
277 )
278 );
279 $this->getMessageStack()->addMessage(
281 $this->lng->txt("dir_preserved_backup") . " " . $absolut_old_dir,
283 )
284 );
285 } else {
286 mkdir($absolut_new_dir, 0777, true);
287 self::xCopy($absolut_old_dir, $absolut_new_dir);
288 $this->getMessageStack()->addMessage(
290 $this->lng->txt("dir_copied_from") . " " . $absolut_old_dir . " " . $this->lng->txt("to") . " " . $absolut_new_dir,
292 )
293 );
294 if (count($this->resourcesStyleReferences($old_dir))==0) {
295 self::recursiveRemoveDir(self::getSkinDirectory() . $old_dir);
296 $this->getMessageStack()->addMessage(
298 $this->lng->txt("dir_deleted") . " " . $absolut_old_dir,
300 )
301 );
302 } else {
303 $this->getMessageStack()->addMessage(
305 $this->lng->txt("dir_preserved_linked") . " " . $absolut_old_dir,
307 )
308 );
309 }
310 }
311 }
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 647 of file class.ilSystemStyleSkinContainer.php.

648 {
649 $main_less_content = file_get_contents($main_path);
650 $main_less_content = str_replace(
651 "@import \"" . $old_style_import,
652 "@import \"" . $new_style_import,
653 $main_less_content
654 );
655 file_put_contents($main_path, $main_less_content);
656 }

Referenced by updateStyle().

+ Here is the caller graph for this function:

◆ compileLess()

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

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

663 {
664 if (!PATH_TO_LESSC) {
666 }
667
668 $output = shell_exec(PATH_TO_LESSC . " " . $this->getLessFilePath($style_id));
669 if (!$output) {
670 $less_error = shell_exec(PATH_TO_LESSC . " " . $this->getLessFilePath($style_id) . " 2>&1");
671 if (!$less_error) {
672 throw new ilSystemStyleException(ilSystemStyleException::LESS_COMPILE_FAILED, "Empty css output, unknown error.");
673 }
675 }
676 file_put_contents($this->getCSSFilePath($style_id), $output);
677 }
Class for advanced editing exception handling in ILIAS.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output

References $output, 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 ( )

Copies a complete Skin.

Returns
ilSystemStyleSkinContainer
Exceptions
ilSystemStyleException

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

569 {
570 $new_skin_id_addon = "";
571
572 while (ilStyleDefinition::skinExists($this->getSkin()->getId() . $new_skin_id_addon, $this->getSystemStylesConf())) {
573 $new_skin_id_addon .= "Copy";
574 }
575
576 $new_skin_path = rtrim($this->getSkinDirectory(), "/") . $new_skin_id_addon;
577
578 mkdir($new_skin_path, 0777, true);
579 $this->xCopy($this->getSkinDirectory(), $new_skin_path);
580 $this->getMessageStack()->addMessage(new ilSystemStyleMessage($this->lng->txt("directory_created") . " " . $new_skin_path, ilSystemStyleMessage::TYPE_SUCCESS));
581 return self::generateFromId($this->getSkin()->getId() . $new_skin_id_addon, null, $this->getSystemStylesConf());
582 }
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 403 of file class.ilSystemStyleSkinContainer.php.

404 {
405 copy($this->getSystemStylesConf()->getDelosPath() . ".css", $this->getCSSFilePath($style->getId()));
406 }

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 379 of file class.ilSystemStyleSkinContainer.php.

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

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.
$style
Definition: example_012.php:70

References $message_stack, $style, 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 348 of file class.ilSystemStyleSkinContainer.php.

349 {
350 $this->createMainLessFile($style);
351 $this->copyVariablesFromDefault($style);
352 $this->copyCSSFromDefault($style);
353 $this->compileLess($style->getId());
354 }
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 361 of file class.ilSystemStyleSkinContainer.php.

362 {
363 $path = $this->getLessFilePath($style->getId());
364 file_put_contents($path, $this->getLessMainFileDefautContent($style));
365 $this->getMessageStack()->addMessage(
367 $this->lng->txt("main_less_created") . " " . $path,
369 )
370 );
371 }
getLessMainFileDefautContent(ilSkinStyleXML $style)
Returns the main less default content if a new style is created.

References $path, 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 243 of file class.ilSystemStyleSkinContainer.php.

244 {
245 $path = $this->getSkinDirectory() . $target;
246
247 mkdir($path, 0777, true);
248
249 if ($source != "") {
251 $this->getMessageStack()->addMessage(
253 $this->lng->txt("dir_created") . $path,
255 )
256 );
257 }
258 }
$source
Definition: linkback.php:22

References $path, $source, $target, 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 597 of file class.ilSystemStyleSkinContainer.php.

598 {
599 $rel_tmp_zip = "../" . $this->getSkin()->getId() . ".zip";
600 ilUtil::zip($this->getSkinDirectory(), $rel_tmp_zip, true);
601 return rtrim($this->getSkinDirectory(), "/") . ".zip";
602 }
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 497 of file class.ilSystemStyleSkinContainer.php.

498 {
499 self::recursiveRemoveDir(self::getSkinDirectory());
500 $this->getMessageStack()->addMessage(
502 $this->lng->txt("skin_deleted") . $this->getSkinDirectory(),
504 )
505 );
506 }

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 513 of file class.ilSystemStyleSkinContainer.php.

514 {
515 if (file_exists($path)) {
516 unlink($path);
517 $this->getMessageStack()->addMessage(
519 $this->lng->txt("file_deleted") . " " . $path,
521 )
522 );
523 }
524 }

References $path, 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 531 of file class.ilSystemStyleSkinContainer.php.

532 {
533 if ($style->isSubstyle()) {
534 ilSystemStyleSettings::deleteSubStyleCategoryAssignments($this->getSkin()->getId(), $style->getSubstyleOf(), $style->getId());
535 $this->getMessageStack()->prependMessage(
537 $this->lng->txt("style_assignments_deleted") . " " . $style->getName(),
539 )
540 );
541 }
542
543 $this->deleteFile($this->getLessFilePath($style->getId()));
544 $this->deleteFile($this->getCSSFilePath($style->getId()));
545 $this->deleteFile($this->getLessVariablesFilePath($style->getId()));
546
547 $this->getSkin()->removeStyle($style->getId());
548
552
553 $this->writeSkinToXML();
554 $this->getMessageStack()->prependMessage(
556 $this->lng->txt("style_deleted") . " " . $style->getName(),
558 )
559 );
560 }
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 $style, deleteFile(), ilSystemStyleSettings\deleteSubStyleCategoryAssignments(), getCSSFilePath(), ilSkinStyleXML\getFontDirectory(), ilSkinStyleXML\getId(), ilSkinStyleXML\getImageDirectory(), getLessFilePath(), getLessVariablesFilePath(), getMessageStack(), getSkin(), ilSkinStyleXML\getSoundDirectory(), 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 587 of file class.ilSystemStyleSkinContainer.php.

588 {
589 ilFileDelivery::deliverFileAttached($this->createTempZip(), $this->getSkin()->getId() . ".zip", '', true);
590 }
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\testCreateDelete(), ilSystemStyleSkinContainerTest\testDeleteSkin(), ilSystemStyleSkinContainerTest\testDeleteStyle(), ilSystemStyleSkinContainerTest\testGenerateFromId(), ilSystemStyleSkinContainerTest\testImportSkin(), ilSystemStyleSkinContainerTest\testUpdateSkin(), and ilSystemStyleSkinContainerTest\testUpdateStyle().

+ Here is the caller graph for this function:

◆ getCSSFilePath()

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

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

708 {
709 return $this->getSkinDirectory() . $this->getSkin()->getStyle($style_id)->getCssFile() . ".css";
710 }

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 743 of file class.ilSystemStyleSkinContainer.php.

744 {
745 return $this->getSkinDirectory() . $this->getSkin()->getStyle($style_id)->getImageDirectory();
746 }

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 716 of file class.ilSystemStyleSkinContainer.php.

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

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 473 of file class.ilSystemStyleSkinContainer.php.

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

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 725 of file class.ilSystemStyleSkinContainer.php.

726 {
727 return $this->getSkinDirectory() . $this->getLessVariablesName($style_id);
728 }

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 734 of file class.ilSystemStyleSkinContainer.php.

735 {
736 return $this->getSkin()->getStyle($style_id)->getCssFile() . "-variables.less";
737 }

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 697 of file class.ilSystemStyleSkinContainer.php.

698 {
699 return $this->getSystemStylesConf()->getCustomizingSkinPath() . $this->getSkin()->getId() . "/";
700 }

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 615 of file class.ilSystemStyleSkinContainer.php.

616 {
617 if (!$system_styles_conf) {
619 }
620
621 $skin_id = preg_replace('/[^A-Za-z0-9\-_]/', '', rtrim($name, ".zip"));
622
624 $skin_id .= "Copy";
625 }
626
627 $skin_path = $system_styles_conf->getCustomizingSkinPath() . $skin_id;
628 mkdir($skin_path, 0777, true);
629
630 $temp_zip_path = $skin_path . "/" . $name;
631 if ($uploaded) {
632 move_uploaded_file($import_zip_path, $temp_zip_path);
633 } else {
634 rename($import_zip_path, $temp_zip_path);
635 }
636 ilUtil::unzip($temp_zip_path);
637 unlink($temp_zip_path);
638
640 }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
if($format !==null) $name
Definition: metadata.php:146

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 488 of file class.ilSystemStyleSkinContainer.php.

489 {
490 rename($from, $to);
491 }
$from

References $from.

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 449 of file class.ilSystemStyleSkinContainer.php.

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

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 318 of file class.ilSystemStyleSkinContainer.php.

319 {
320 $absolut_dir = $this->getSkinDirectory() . $dir;
321
322 if (file_exists($absolut_dir)) {
323 if (count($this->resourcesStyleReferences($dir)) == 0) {
325 $this->getMessageStack()->addMessage(
327 $this->lng->txt("dir_deleted") . " " . $dir,
329 )
330 );
331 } else {
332 $this->getMessageStack()->addMessage(
334 $this->lng->txt("dir_preserved_linked") . " " . $dir,
336 )
337 );
338 }
339 }
340 }

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 392 of file class.ilSystemStyleSkinContainer.php.

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

References $style, 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 225 of file class.ilSystemStyleSkinContainer.php.

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

References $style, and 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 759 of file class.ilSystemStyleSkinContainer.php.

760 {
761 self::$message_stack = $message_stack;
762 }

References $message_stack.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setSkin()

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

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

690 {
691 $this->skin = $skin;
692 }

References $skin.

◆ setSystemStylesConf()

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

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

791 {
792 $this->system_styles_conf = $system_styles_conf;
793 }

References $system_styles_conf.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ updateSkin()

ilSystemStyleSkinContainer::updateSkin ( ilSkinXML  $old_skin)

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

References ilSkinXML\getId(), 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 156 of file class.ilSystemStyleSkinContainer.php.

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

References $style, 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 774 of file class.ilSystemStyleSkinContainer.php.

775 {
776 $this->getSkin()->writeToXMLFile($this->getSkinDirectory() . "template.xml");
777 }

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 415 of file class.ilSystemStyleSkinContainer.php.

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

References $file, 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: