2include_once(
"Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php");
3include_once(
"Services/Style/System/classes/class.ilStyleDefinition.php");
4include_once(
"Services/Style/System/classes/Exceptions/class.ilSystemStyleException.php");
5include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleMessageStack.php");
6include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleMessage.php");
7include_once(
"Services/Style/System/classes/Less/class.ilSystemStyleLessFile.php");
8include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleConfig.php");
59 $this->lng =
$DIC->language();
95 if ($skin_id !=
"default") {
123 }
catch (Exception $e) {
138 $old_customizing_skin_directory = $this->
getSystemStylesConf()->getCustomizingSkinPath() . $old_skin->
getId() .
"/";
141 if ($old_skin->
getId() != $this->getSkin()->getId()) {
205 }
catch (Exception $e) {
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);
290 $this->lng->txt(
"dir_copied_from") .
" " . $absolut_old_dir .
" " . $this->lng->txt(
"to") .
" " . $absolut_new_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)) {
428 }
catch (Exception $e) {
435 copy($src_file, $dest_file);
436 }
catch (Exception $e) {
452 $objects = scandir($dir);
453 foreach ($objects as $object) {
454 if ($object !=
"." && $object !=
"..") {
455 if (is_dir($dir .
"/" . $object)) {
458 unlink($dir .
"/" . $object);
476 $content .=
"// Import Custom Less Files here\n";
497 public function delete()
502 $this->lng->txt(
"skin_deleted") . $this->getSkinDirectory(),
515 if (file_exists(
$path)) {
519 $this->lng->txt(
"file_deleted") .
" " .
$path,
533 if (
$style->isSubstyle()) {
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";
621 $skin_id = preg_replace(
'/[^A-Za-z0-9\-_]/',
'', rtrim(
$name,
".zip"));
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);
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";
769 $this->
getSkin()->addStyle($style);
An exception for terminatinating execution or to throw for unit testing.
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
ilSkinXml holds an manages the basic data of a skin as provide by the template of the skin.
static skinExists($skin_id, ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Class for advanced editing exception handling in ILIAS.
const FILE_OPENING_FAILED
const LESSC_NOT_INSTALLED
const SKIN_ALREADY_EXISTS
const FILE_CREATION_FAILED
const FOLDER_CREATION_FAILED
const LESS_COMPILE_FAILED
Used to stack messages to be shown to the user.
static deleteSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_substyle)
Delets a sub styles category assignment.
This class is responsible for all file system related actions related actions of a skin such as copyi...
addStyle(ilSkinStyleXML $style)
static setMessageStack($message_stack)
static recursiveRemoveDir($dir)
Recursive delete of a folder.
getLessMainFileDefautContent(ilSkinStyleXML $style)
Returns the main less default content if a new style is created.
getLessFilePath($style_id)
getLessVariablesFilePath($style_id)
deleteFile($path)
Deletes a given file in the container.
getImagesSkinPath($style_id)
changeResourceDirectory($new_dir, $old_dir)
Alters the name/path of a resource directory.
createResourceDirectory($source, $target)
Creates a resource directory (sound, images or fonts) by copying from the source (mostly delos)
copyCSSFromDefault(ilSkinStyleXML $style)
Copies (resets) the images from delos.
updateSkin(ilSkinXML $old_skin)
Updates the skin.
removeResourceDirectory($dir)
Deletes a resource directory.
static generateFromId($skin_id, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
Generate the container class by parsing the corresponding XML.
static xCopy($src, $dest)
Recursive copy of a folder.
changeVariablesImport($main_path, $old_style_import, $new_style_import)
copyVariablesFromDefault(ilSkinStyleXML $style)
Copies (resets) the variables file from delos.
resourcesStyleReferences($resource)
Checks if a given resource (folder) is still referenced by a style of the containers skin.
export()
Exports the complete skin to an zip file.
copy()
Copies a complete Skin.
getLessVariablesName($style_id)
deleteStyle(ilSkinStyleXML $style)
Deletes a style completely.
getCSSFilePath($style_id)
createTempZip()
Creates a temp zip file.
move($from, $to)
Used to move a complete directory of a skin.
__construct(ilSkinXML $skin, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
ilSystemStyleSkinContainer constructor.
updateStyle($style_id, ilSkinStyleXML $old_style)
Updates one single style.
resetImages(ilSkinStyleXML $style)
Copies (resets) the images from delos.
createMainLessFile(ilSkinStyleXML $style)
Creates the main less file.
create(ilSystemStyleMessageStack $message_stack)
Creates a new skin.
setSystemStylesConf($system_styles_conf)
createLessStructure(ilSkinStyleXML $style)
Creates the less/css structure of a style.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file