ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 54 of file class.ilSystemStyleSkinContainer.php.

55 {
56 global $DIC;
57
58 $this->lng = $DIC->language();
59
60 $this->skin = $skin;
61
62 if(!$message_stack){
64 }else{
65 $this->setMessageStack($message_stack);
66 }
67
70 }else{
71 $this->setSystemStylesConf($system_styles_conf);
72 }
73 }
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

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

720 {
721 $this->getSkin()->addStyle($style);
722 $old_style = new ilSkinStyleXML("","");
723 $this->updateStyle($style->getId(), $old_style);
724 }
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 266 of file class.ilSystemStyleSkinContainer.php.

266 {
267 $absolut_new_dir = $this->getSkinDirectory().$new_dir;
268 $absolut_old_dir = $this->getSkinDirectory().$old_dir;
269
270 if(file_exists($absolut_new_dir)){
271 $this->getMessageStack()->addMessage(
272 new ilSystemStyleMessage($this->lng->txt("dir_changed_to")." ".$absolut_new_dir,
274 ));
275 $this->getMessageStack()->addMessage(
276 new ilSystemStyleMessage($this->lng->txt("dir_preserved_backup")." ".$absolut_old_dir,
278 ));
279 }else{
280 mkdir($absolut_new_dir,0777,true);
281 self::xCopy($absolut_old_dir, $absolut_new_dir);
282 $this->getMessageStack()->addMessage(
283 new ilSystemStyleMessage($this->lng->txt("dir_copied_from")." ".$absolut_old_dir." ".$this->lng->txt("to")." ".$absolut_new_dir,
285 ));
286 if(count($this->resourcesStyleReferences($old_dir))==0){
287 self::recursiveRemoveDir(self::getSkinDirectory().$old_dir);
288 $this->getMessageStack()->addMessage(
289 new ilSystemStyleMessage($this->lng->txt("dir_deleted")." ".$absolut_old_dir,
291 ));
292 }else{
293 $this->getMessageStack()->addMessage(
294 new ilSystemStyleMessage($this->lng->txt("dir_preserved_linked")." ".$absolut_old_dir,
296 ));
297 }
298 }
299 }
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 608 of file class.ilSystemStyleSkinContainer.php.

608 {
609 $main_less_content = file_get_contents($main_path);
610 $main_less_content = str_replace("@import \"".$old_style_import,
611 "@import \"".$new_style_import,
612 $main_less_content);
613 file_put_contents($main_path,$main_less_content);
614 }

Referenced by updateStyle().

+ Here is the caller graph for this function:

◆ compileLess()

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

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

620 {
621
622 if(!PATH_TO_LESSC){
624 }
625
626 $output = shell_exec(PATH_TO_LESSC." ".$this->getLessFilePath($style_id));
627 if(!$output){
628 $less_error = shell_exec(PATH_TO_LESSC." ".$this->getLessFilePath($style_id)." 2>&1");
629 if(!$less_error){
630 throw new ilSystemStyleException(ilSystemStyleException::LESS_COMPILE_FAILED, "Empty css output, unknown error.");
631 }
633 }
634 file_put_contents($this->getCSSFilePath($style_id),$output);
635 }
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(), 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 532 of file class.ilSystemStyleSkinContainer.php.

532 {
533 $new_skin_id_addon = "";
534
535 while(ilStyleDefinition::skinExists($this->getSkin()->getId().$new_skin_id_addon, $this->getSystemStylesConf())){
536 $new_skin_id_addon .= "Copy";
537 }
538
539 $new_skin_path = rtrim($this->getSkinDirectory(),"/").$new_skin_id_addon;
540
541 mkdir($new_skin_path,0777,true);
542 $this->xCopy($this->getSkinDirectory(),$new_skin_path);
543 $this->getMessageStack()->addMessage(new ilSystemStyleMessage($this->lng->txt("directory_created")." ".$new_skin_path,ilSystemStyleMessage::TYPE_SUCCESS));
544 return self::generateFromId($this->getSkin()->getId().$new_skin_id_addon,null,$this->getSystemStylesConf());
545
546 }
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 380 of file class.ilSystemStyleSkinContainer.php.

380 {
381 copy ($this->getSystemStylesConf()->getDelosPath().".css",$this->getCSSFilePath($style->getId()));
382 }

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

358 {
359 $less_file = new ilSystemStyleLessFile($this->getSystemStylesConf()->getDefaultVariablesPath());
360 $less_file->setLessVariablesFile($this->getLessVariablesFilePath($style->getId()));
361 $less_file->write();
362 return $less_file;
363 }

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.

108 {
109 if(file_exists($this->getSkinDirectory())){
111 }
112
113
114 mkdir($this->getSkinDirectory(),0777,true);
115
116 foreach($this->getSkin()->getStyles() as $style){
117 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultImagesPath(),$style->getImageDirectory());
118 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultSoundsPath(),$style->getSoundDirectory());
119 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultFontsPath(),$style->getFontDirectory());
120 try{
121 $this->createLessStructure($style);
122 }catch(Exception $e){
123 $message_stack->addMessage(new ilSystemStyleMessage($this->lng->txt("less_compile_failed")." ".$e->getMessage(),ilSystemStyleMessage::TYPE_ERROR));
124 }
125
126 }
127 $this->writeSkinToXML();
128
129
130 }
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 331 of file class.ilSystemStyleSkinContainer.php.

331 {
332 $this->createMainLessFile($style);
333 $this->copyVariablesFromDefault($style);
334 $this->copyCSSFromDefault($style);
335 $this->compileLess($style->getId());
336 }
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 343 of file class.ilSystemStyleSkinContainer.php.

343 {
344 $path = $this->getLessFilePath($style->getId());
345 file_put_contents($path,$this->getLessMainFileDefautContent($style));
346 $this->getMessageStack()->addMessage(
347 new ilSystemStyleMessage($this->lng->txt("main_less_created")." ".$path,
349 ));
350 }
$path
Definition: aliased.php:25
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 245 of file class.ilSystemStyleSkinContainer.php.

245 {
246 $path = $this->getSkinDirectory().$target;
247
248 mkdir($path,0777,true);
249
250 if($source != ""){
251 self::xCopy($source,$path);
252 $this->getMessageStack()->addMessage(
253 new ilSystemStyleMessage($this->lng->txt("dir_created").$path,
255 ));
256 }
257 }

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

560 {
561 $rel_tmp_zip = "../".$this->getSkin()->getId().".zip";
562 ilUtil::zip($this->getSkinDirectory(),$rel_tmp_zip,true);
563 return rtrim($this->getSkinDirectory(),"/").".zip";
564 }
static zip($a_dir, $a_file, $compress_content=false)

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

472 {
473 self::recursiveRemoveDir(self::getSkinDirectory());
474 $this->getMessageStack()->addMessage(
475 new ilSystemStyleMessage($this->lng->txt("skin_deleted").$this->getSkinDirectory(),
477 ));
478 }

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

485 {
486 if(file_exists($path)){
487 unlink($path);
488 $this->getMessageStack()->addMessage(
489 new ilSystemStyleMessage($this->lng->txt("file_deleted") . " " . $path,
491 ));
492 }
493 }

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

500 {
501 if($style->isSubstyle()){
502 ilSystemStyleSettings::deleteSubStyleCategoryAssignments($this->getSkin()->getId(),$style->getSubstyleOf(),$style->getId());
503 $this->getMessageStack()->prependMessage(
504 new ilSystemStyleMessage($this->lng->txt("style_assignments_deleted")." ".$style->getName(),
506 ));
507 }
508
509 $this->deleteFile($this->getLessFilePath($style->getId()));
510 $this->deleteFile($this->getCSSFilePath($style->getId()));
511 $this->deleteFile($this->getLessVariablesFilePath($style->getId()));
512
513 $this->getSkin()->removeStyle($style->getId());
514
518
519 $this->writeSkinToXML();
520 $this->getMessageStack()->prependMessage(
521 new ilSystemStyleMessage($this->lng->txt("style_deleted")." ".$style->getName(),
523 ));
524 }
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 551 of file class.ilSystemStyleSkinContainer.php.

551 {
552 ilFileDelivery::deliverFileAttached($this->createTempZip(), $this->getSkin()->getId().".zip",null, true);
553 }
static deliverFileAttached($path_to_file, $download_file_name=null, $mime_type=null, $delete_file=false)

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

84 {
85 if(!$skin_id){
87 }
88
91 }
92
93 if ($skin_id != "default")
94 {
95 return new self(ilSkinXML::parseFromXML($system_styles_conf->getCustomizingSkinPath().$skin_id."/template.xml"), $message_stack, $system_styles_conf);
96 }else{
97 return new self(ilSkinXML::parseFromXML($system_styles_conf->getDefaultTemplatePath()), $message_stack, $system_styles_conf);
98 }
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 665 of file class.ilSystemStyleSkinContainer.php.

665 {
666 return $this->getSkinDirectory().$this->getSkin()->getStyle($style_id)->getCssFile().".css";
667 }

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

697 {
698 return $this->getSkinDirectory().$this->getSkin()->getStyle($style_id)->getImageDirectory();
699 }

References getSkinDirectory().

+ Here is the call graph for this function:

◆ getLessFilePath()

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

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

673 {
674 return $this->getSkinDirectory().$this->getSkin()->getStyle($style_id)->getCssFile().".less";
675 }

References getSkinDirectory().

Referenced by 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 447 of file class.ilSystemStyleSkinContainer.php.

447 {
448 $less_delos_import = $this->getSystemStylesConf()->getDelosPath();
449 $less_delos_import = str_replace("./","../../../../",$less_delos_import);
450 $content = "@import \"".$less_delos_import."\";\n";
451
452 $content .= "// Import Custom Less Files here\n";
453
454 $content .= "@import \"".$this->getLessVariablesName($style->getId())."\";\n";
455 return $content;
456 }

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

681 {
682 return $this->getSkinDirectory().$this->getLessVariablesName($style_id);
683 }

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

689 {
690 return $this->getSkin()->getStyle($style_id)->getCssFile()."-variables.less";
691 }

References getSkin().

+ Here is the call graph for this function:

◆ getMessageStack()

static ilSystemStyleSkinContainer::getMessageStack ( )
static

◆ getSkin()

ilSystemStyleSkinContainer::getSkin ( )
Returns
ilSkinXML

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

640 {
641 return $this->skin;
642 }

References $skin.

Referenced by addStyle(), copy(), create(), deleteStyle(), export(), getLessVariablesName(), resourcesStyleReferences(), updateStyle(), and writeSkinToXML().

+ Here is the caller graph for this function:

◆ getSkinDirectory()

ilSystemStyleSkinContainer::getSkinDirectory ( )
Returns
mixed

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

656 {
657 return $this->getSystemStylesConf()->getCustomizingSkinPath().$this->getSkin()->getId()."/";
658 }

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

577 {
580 }
581
582 $skin_id = preg_replace('/[^A-Za-z0-9\-_]/', '', rtrim($name,".zip"));
583
585 $skin_id .= "Copy";
586 }
587
588 $skin_path = $system_styles_conf->getCustomizingSkinPath().$skin_id;
589 mkdir($skin_path,0777,true);
590
591 $temp_zip_path = $skin_path."/".$name;
592 if($uploaded){
593 move_uploaded_file ( $import_zip_path ,$temp_zip_path );
594 }else{
595 rename( $import_zip_path ,$temp_zip_path );
596 }
597 ilUtil::unzip($temp_zip_path);
598 unlink($temp_zip_path);
599
601 }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file

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

464 {
465 rename($from,$to);
466 }

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

425 {
426 if (is_dir($dir)) {
427 $objects = scandir($dir);
428 foreach ($objects as $object) {
429 if ($object != "." && $object != "..") {
430 if (is_dir($dir."/".$object))
431 self::recursiveRemoveDir($dir."/".$object);
432 else
433 unlink($dir."/".$object);
434 }
435 }
436 rmdir($dir);
437 }
438 }

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

306 {
307 $absolut_dir = $this->getSkinDirectory().$dir;
308
309 if(file_exists($absolut_dir)) {
310 if (count($this->resourcesStyleReferences($dir)) == 0) {
312 $this->getMessageStack()->addMessage(
313 new ilSystemStyleMessage($this->lng->txt("dir_deleted")." ". $dir,
315 ));
316 } else {
317 $this->getMessageStack()->addMessage(
318 new ilSystemStyleMessage($this->lng->txt("dir_preserved_linked")." ". $dir,
320 ));
321 }
322 }
323 }

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

370 {
372 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultImagesPath(),$style->getImageDirectory());
373 }

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

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

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

713 {
714 self::$message_stack = $message_stack;
715 }

References $message_stack.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setSkin()

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

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

648 {
649 $this->skin = $skin;
650 }

References $skin.

◆ setSystemStylesConf()

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

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

742 {
743 $this->system_styles_conf = $system_styles_conf;
744 }

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

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

157 {
158 $style = $this->getSkin()->getStyle($style_id);
159
160 if($style->getImageDirectory()!=$old_style->getImageDirectory())
161 {
162 if(file_exists($this->getSkinDirectory().$old_style->getImageDirectory())){
163 $this->changeResourceDirectory($style->getImageDirectory(),$old_style->getImageDirectory());
164 }else{
165 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultImagesPath(),$style->getImageDirectory());
166 }
167 }
168
169 if($style->getFontDirectory()!=$old_style->getFontDirectory())
170 {
171 if(file_exists($this->getSkinDirectory().$old_style->getFontDirectory())){
172 $this->changeResourceDirectory($style->getFontDirectory(),$old_style->getFontDirectory());
173 }else{
174 $this->createResourceDirectory($this->getSystemStylesConf()->getDefaultFontsPath(),$style->getFontDirectory());
175 }
176 }
177
178 if($style->getSoundDirectory()!=$old_style->getSoundDirectory())
179 {
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{
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{
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(
210 new ilSystemStyleMessage($e->getMessage(),
212 ));
213 copy ($this->getSystemStylesConf()->getDelosPath().".css",$this->getCSSFilePath($style->getId()));
214 }
215 }
216
217 $this->writeSkinToXML();
218
219 }
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 726 of file class.ilSystemStyleSkinContainer.php.

726 {
727 $this->getSkin()->writeToXMLFile($this->getSkinDirectory()."template.xml");
728 }

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

392 {
393 foreach (scandir($src) as $file) {
394 $src_file = rtrim($src, '/') . '/' . $file;
395 $dest_file = rtrim($dest, '/') . '/' . $file;
396 if (!is_readable($src_file)) {
398 }
399 if (substr($file, 0, 1) != ".") {
400 if (is_dir($src_file)) {
401 if (!file_exists($dest_file)) {
402 try {
403 mkdir($dest_file);
404 } catch (Exception $e) {
405 throw new ilSystemStyleException(ilSystemStyleException::FOLDER_CREATION_FAILED, "Copy " . $src_file . " to " . $dest_file . " Error: " . $e);
406 }
407 }
408 self::xCopy($src_file, $dest_file);
409 } else {
410 try {
411 copy($src_file,$dest_file);
412 } catch (Exception $e) {
413 throw new ilSystemStyleException(ilSystemStyleException::FILE_CREATION_FAILED, "Copy " . $src_file . " to " . $dest_file . " Error: " . $e);
414 }
415 }
416 }
417 }
418 }
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 24 of file class.ilSystemStyleSkinContainer.php.

◆ $message_stack

ilSystemStyleSkinContainer::$message_stack = null
staticprotected

◆ $skin

ilSystemStyleSkinContainer::$skin
protected

Definition at line 31 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: