2 include_once(
"Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php");
3 include_once(
"Services/Style/System/classes/class.ilStyleDefinition.php");
4 include_once(
"Services/Style/System/classes/Exceptions/class.ilSystemStyleException.php");
5 include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleMessageStack.php");
6 include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleMessage.php");
7 include_once(
"Services/Style/System/classes/Less/class.ilSystemStyleLessFile.php");
8 include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleConfig.php");
59 $this->lng = $DIC->language();
95 if ($skin_id !=
"default") {
138 $old_customizing_skin_directory = $this->
getSystemStylesConf()->getCustomizingSkinPath() . $old_skin->
getId() .
"/";
227 $references_ids = array();
229 if ($style->referencesResource($resource)) {
230 $references_ids[] = $style->getId();
233 return $references_ids;
247 mkdir(
$path, 0777,
true);
253 $this->lng->txt(
"dir_created") .
$path,
272 if (file_exists($absolut_new_dir)) {
275 $this->lng->txt(
"dir_changed_to") .
" " . $absolut_new_dir,
281 $this->lng->txt(
"dir_preserved_backup") .
" " . $absolut_old_dir,
286 mkdir($absolut_new_dir, 0777,
true);
287 self::xCopy($absolut_old_dir, $absolut_new_dir);
290 $this->lng->txt(
"dir_copied_from") .
" " . $absolut_old_dir .
" " . $this->lng->txt(
"to") .
" " . $absolut_new_dir,
295 self::recursiveRemoveDir(self::getSkinDirectory() . $old_dir);
298 $this->lng->txt(
"dir_deleted") .
" " . $absolut_old_dir,
305 $this->lng->txt(
"dir_preserved_linked") .
" " . $absolut_old_dir,
322 if (file_exists($absolut_dir)) {
327 $this->lng->txt(
"dir_deleted") .
" " . $dir,
334 $this->lng->txt(
"dir_preserved_linked") .
" " . $dir,
367 $this->lng->txt(
"main_less_created") .
" " .
$path,
415 public static function xCopy($src, $dest)
417 foreach (scandir($src) as $file) {
418 $src_file = rtrim($src,
'/') .
'/' . $file;
419 $dest_file = rtrim($dest,
'/') .
'/' . $file;
420 if (!is_readable($src_file)) {
423 if (substr($file, 0, 1) !=
".") {
424 if (is_dir($src_file)) {
425 if (!file_exists($dest_file)) {
432 self::xCopy($src_file, $dest_file);
435 copy($src_file, $dest_file);
452 $objects = scandir($dir);
453 foreach ($objects as $object) {
454 if ($object !=
"." && $object !=
"..") {
455 if (is_dir($dir .
"/" . $object)) {
456 self::recursiveRemoveDir($dir .
"/" . $object);
458 unlink($dir .
"/" . $object);
476 $content .=
"// Import Custom Less Files here\n";
497 public function delete()
499 self::recursiveRemoveDir(self::getSkinDirectory());
515 if (file_exists(
$path)) {
519 $this->lng->txt(
"file_deleted") .
" " .
$path,
537 $this->lng->txt(
"style_assignments_deleted") .
" " . $style->
getName(),
556 $this->lng->txt(
"style_deleted") .
" " . $style->
getName(),
570 $new_skin_id_addon =
"";
573 $new_skin_id_addon .=
"Copy";
576 $new_skin_path = rtrim($this->
getSkinDirectory(),
"/") . $new_skin_id_addon;
578 mkdir($new_skin_path, 0777,
true);
599 $rel_tmp_zip =
"../" . $this->
getSkin()->getId() .
".zip";
617 if (!$system_styles_conf) {
621 $skin_id = preg_replace(
'/[^A-Za-z0-9\-_]/',
'', rtrim($name,
".zip"));
627 $skin_path = $system_styles_conf->getCustomizingSkinPath() . $skin_id;
628 mkdir($skin_path, 0777,
true);
630 $temp_zip_path = $skin_path .
"/" .
$name;
632 move_uploaded_file($import_zip_path, $temp_zip_path);
634 rename($import_zip_path, $temp_zip_path);
637 unlink($temp_zip_path);
639 return self::generateFromId($skin_id, $message_stack, $system_styles_conf);
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,
655 file_put_contents($main_path, $main_less_content);
664 if (!PATH_TO_LESSC) {
670 $less_error = shell_exec(PATH_TO_LESSC .
" " . $this->
getLessFilePath($style_id) .
" 2>&1");
736 return $this->
getSkin()->getStyle($style_id)->getCssFile() .
"-variables.less";
753 return self::$message_stack;
769 $this->
getSkin()->addStyle($style);
move($from, $to)
Used to move a complete directory of a skin.
createLessStructure(ilSkinStyleXML $style)
Creates the less/css structure of a style.
const SKIN_ALREADY_EXISTS
updateSkin(ilSkinXML $old_skin)
Updates the skin.
createTempZip()
Creates a temp zip file.
const LESSC_NOT_INSTALLED
setSystemStylesConf($system_styles_conf)
deleteStyle(ilSkinStyleXML $style)
Deletes a style completely.
getLessFilePath($style_id)
This class is responsible for all file system related actions related actions of a skin such as copyi...
removeResourceDirectory($dir)
Deletes a resource directory.
create(ilSystemStyleMessageStack $message_stack)
Creates a new skin.
getSubstyleOf()
Returns the parent style of this style if set.
getLessVariablesFilePath($style_id)
deleteFile($path)
Deletes a given file in the container.
const FOLDER_CREATION_FAILED
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
ilSkinXml holds an manages the basic data of a skin as provide by the template of the skin...
getLessMainFileDefautContent(ilSkinStyleXML $style)
Returns the main less default content if a new style is created.
getImagesSkinPath($style_id)
createMainLessFile(ilSkinStyleXML $style)
Creates the main less file.
const FILE_CREATION_FAILED
isSubstyle()
Return wheter this style is a substyle of another.
updateStyle($style_id, ilSkinStyleXML $old_style)
Updates one single style.
getLessVariablesName($style_id)
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
addStyle(ilSkinStyleXML $style)
static setMessageStack($message_stack)
createResourceDirectory($source, $target)
Creates a resource directory (sound, images or fonts) by copying from the source (mostly delos) ...
static recursiveRemoveDir($dir)
Recursive delete of a folder.
copyCSSFromDefault(ilSkinStyleXML $style)
Copies (resets) the images from delos.
static deleteSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_substyle)
Delets a sub styles category assignment.
Class for advanced editing exception handling in ILIAS.
const FILE_OPENING_FAILED
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
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.
copyVariablesFromDefault(ilSkinStyleXML $style)
Copies (resets) the variables file from delos.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
__construct(ilSkinXML $skin, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
ilSystemStyleSkinContainer constructor.
changeResourceDirectory($new_dir, $old_dir)
Alters the name/path of a resource directory.
resourcesStyleReferences($resource)
Checks if a given resource (folder) is still referenced by a style of the containers skin...
Used to stack messages to be shown to the user.
changeVariablesImport($main_path, $old_style_import, $new_style_import)
resetImages(ilSkinStyleXML $style)
Copies (resets) the images from delos.
getCSSFilePath($style_id)
const LESS_COMPILE_FAILED
copy()
Copies a complete Skin.
export()
Exports the complete skin to an zip file.
static xCopy($src, $dest)
Recursive copy of a folder.