ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilSkinStyleContainer.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 {
30  protected Language $lng;
31 
35  protected ilSkin $skin;
36 
41 
46 
47  public function __construct(
48  Language $lng,
49  ilSkin $skin,
50  ilSystemStyleMessageStack $message_stack,
51  ?ilSystemStyleConfig $system_styles_conf = null,
52  ) {
53  $this->lng = $lng;
54  $this->skin = $skin;
55  $this->setMessageStack($message_stack);
56 
57  if (!$system_styles_conf) {
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  {
146  return $this->message_stack;
147  }
148 
149  public function setMessageStack(ilSystemStyleMessageStack $message_stack): void
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 
164  public function setSystemStylesConf(ilSystemStyleConfig $system_styles_conf): void
165  {
166  $this->system_styles_conf = $system_styles_conf;
167  }
168 }
setSystemStylesConf(ilSystemStyleConfig $system_styles_conf)
setMessageStack(ilSystemStyleMessageStack $message_stack)
ilSystemStyleConfig $system_styles_conf
Used to wire this component up with the correct pathes into the customizing directory.
ilSystemStyleMessageStack $message_stack
Used to stack messages to be displayed to the user (mostly reports for failed actions) ...
ilSkin $skin
Data-scope for the skin this container capsules.
This class is responsible for all file system related actions related actions of a skin such as copyi...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static deliverFileAttached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, bool $delete_file=false)
__construct(Language $lng, ilSkin $skin, ilSystemStyleMessageStack $message_stack, ?ilSystemStyleConfig $system_styles_conf=null,)
createTempZip()
Creates a temp zip file.
ilSystemStyleConfig wraps all &#39;constants&#39; to ensure the testability of all classes using those &#39;const...
static zip(string $a_dir, string $a_file, bool $compress_content=false)
export()
Exports the complete skin to an zip file.
Used to stack messages to be shown to the user.
ilSkin holds an manages the basic data of a skin as provide by the template of the skin...