ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSkinStyleContainer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29{
30 protected Language $lng;
31
35 protected ilSkin $skin;
36
41
46
47 public function __construct(
52 ) {
53 $this->lng = $lng;
54 $this->skin = $skin;
55 $this->setMessageStack($message_stack);
56
59 } else {
60 $this->setSystemStylesConf($system_styles_conf);
61 }
62 }
63
67 public function export(): void
68 {
70 $this->createTempZip(),
71 $this->getSkin()->getId() . '.zip',
72 '',
73 true
74 );
75 }
76
80 public function createTempZip(): string
81 {
82 $skin_directory = $this->getSkinDirectory(); // parent of skin directory
83
84 if (strpos($skin_directory, '../') === 0) { // we must resolve relative paths here
85 $skin_directory = realpath(__DIR__ . '/../../../../../../templates/' . $skin_directory);
86 }
87 $output_file = dirname($skin_directory) . '/' . $this->getSkin()->getId() . '.zip';
88
89 ilFileUtils::zip($skin_directory, $output_file, true);
90
91 return $output_file;
92 }
93
94 public function getSkin(): ilSkin
95 {
96 return $this->skin;
97 }
98
99 public function setSkin(ilSkin $skin): void
100 {
101 $this->skin = $skin;
102 }
103
104 public function getSkinDirectory(): string
105 {
106 return $this->getSystemStylesConf()->getCustomizingSkinPath() . $this->getSkin()->getId() . '/';
107 }
108
109 public function getCSSFilePath(string $style_id): string
110 {
111 return $this->getSkinDirectory() . $style_id . "/".$this->getSkin()->getStyle($style_id)->getCssFile() . '.css';
112 }
113
114 public function getScssFilePath(string $style_id): string
115 {
116 return $this->getSkinDirectory() . $style_id . "/".$this->getSkin()->getStyle($style_id)->getCssFile() . '.scss';
117 }
118
119 public function getScssSettingsPath(string $style_id): string
120 {
121 return $this->getSkinDirectory() . $style_id . "/".$this->getScssSettingsFolderName();
122 }
123
124 public function getScssSettingsFolderName(): string
125 {
126 return $this->system_styles_conf->getScssSettingsFolderName();
127 }
128
129 public function getImagesStylePath(string $style_id): string
130 {
131 return $this->getSkinDirectory().$style_id."/".$this->getSkin()->getStyle($style_id)->getImageDirectory();
132 }
133
134 public function getSoundsStylePath(string $style_id): string
135 {
136 return $this->getSkinDirectory().$style_id."/".$this->getSkin()->getStyle($style_id)->getSoundDirectory();
137 }
138
139 public function getFontsStylePath(string $style_id): string
140 {
141 return $this->getSkinDirectory().$style_id."/".$this->getSkin()->getStyle($style_id)->getFontDirectory();
142 }
143
145 {
147 }
148
150 {
151 $this->message_stack = $message_stack;
152 }
153
154 protected function writeSkinToXML(): void
155 {
156 $this->getSkin()->writeToXMLFile($this->getSkinDirectory() . 'template.xml');
157 }
158
160 {
162 }
163
165 {
166 $this->system_styles_conf = $system_styles_conf;
167 }
168}
static deliverFileAttached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, bool $delete_file=false)
static zip(string $a_dir, string $a_file, bool $compress_content=false)
This class is responsible for all file system related actions related actions of a skin such as copyi...
export()
Exports the complete skin to an zip file.
createTempZip()
Creates a temp zip file.
ilSystemStyleConfig $system_styles_conf
Used to wire this component up with the correct pathes into the customizing directory.
ilSkin $skin
Data-scope for the skin this container capsules.
setSystemStylesConf(ilSystemStyleConfig $system_styles_conf)
ilSystemStyleMessageStack $message_stack
Used to stack messages to be displayed to the user (mostly reports for failed actions)
setMessageStack(ilSystemStyleMessageStack $message_stack)
__construct(Language $lng, ilSkin $skin, ilSystemStyleMessageStack $message_stack, ?ilSystemStyleConfig $system_styles_conf=null,)
ilSkin holds an manages the basic data of a skin as provide by the template of the skin.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Used to stack messages to be shown to the user.