19 declare(strict_types=1);
49 ServerRequestInterface $request,
80 $cmd = $this->
ctrl->getCmd();
88 $form = $this->
edit();
92 $form = $this->
edit();
95 $components = $this->message_stack->getUIComponentsMessages($this->ui_factory);
97 $components[] = $form;
100 $this->tpl->setContent($this->renderer->render($components));
105 $this->
toolbar->addComponent($this->ui_factory->button()->standard(
106 $this->
lng->txt(
'reset_variables'),
107 $this->
ctrl->getLinkTarget($this,
'reset')
113 $style = $this->style_container->getSkin()->getStyle($this->style_id);
114 $this->scss_folder = $this->style_container->copySettingsFromDefault($style);
117 $this->style_container->compileScss($style->getId());
120 $this->
lng->txt($e->getMessage()),
128 $scss_path = $this->style_container->getScssFilePath($this->style_id);
132 if (file_exists($scss_path)) {
133 $scss_file_path = $this->style_container->getScssFilePath($this->style_id);
136 $content = file_get_contents($scss_file_path);
138 $this->message_stack->addMessage(
140 $this->
lng->txt(
'can_not_read_scss_folder') .
' ' . $scss_file_path,
147 $reg_exp =
'/' . preg_quote($this->style_container->getScssSettingsFolderName(),
'/') .
'/';
149 if (!preg_match($reg_exp, $content)) {
150 $this->message_stack->addMessage(
152 $this->
lng->txt(
'scss_variables_file_not_included') .
' ' . $this->style_container->getScssSettingsFolderName()
153 .
' ' . $this->
lng->txt(
'in_main_scss_folder') .
' ' . $scss_path,
161 $this->message_stack->addMessage(
163 $this->
lng->txt(
'scss_folder_does_not_exist') . $scss_path,
177 $this->message_stack->addMessage(
181 } elseif (!shell_exec(PATH_TO_SCSS .
" -h")) {
182 $this->message_stack->addMessage(
185 $this->message_stack->addMessage(
187 $this->
lng->txt(
'provided_scss_path') .
' ' . PATH_TO_SCSS,
194 if (!$pass && shell_exec(
'which sass')) {
195 $this->message_stack->addMessage(
197 $this->
lng->txt(
'scss_scss_installation_detected') . shell_exec(
'which sass'),
206 protected function edit(): Form
211 $this->message_stack->prependMessage(
222 $f = $this->ui_factory->input();
223 $category_sections = [];
224 foreach ($this->scss_folder->getCategories() as $category) {
225 $variables_inptus = [];
226 foreach ($this->scss_folder->getVariablesPerCategory($category->getName()) as $variable) {
227 $info = $this->scss_folder->getRefAndCommentAsString($variable->getName(), $this->
lng->txt(
'usages'));
228 $save_closure =
function ($v) use ($variable) {
229 $variable->setValue($v);
231 $variables_inptus[] =
$f->field()->text($variable->getName(), $info)
233 ->withDisabled(!$modify)
234 ->withValue($variable->getValue())
238 if(count($variables_inptus) > 0) {
239 $category_sections[] =
$f->field()->section(
241 $category->getName(),
242 $category->getComment()
247 $form_section =
$f->field()->section(
249 $this->
lng->txt(
'adapt_scss'),
250 $this->
lng->txt(
'adapt_scss_description')
253 return $f->container()->form()->standard(
254 $this->
ctrl->getFormAction($this,
'update'),
256 )->withSubmitLabel($this->
lng->txt(
'update_variables'));
262 $form = $form->withRequest($this->request);
264 if (!$form->getData()) {
266 $this->
lng->txt(
'scss_variables_empty_might_have_changed'),
273 $this->scss_folder->write();
274 $this->style_container->compileScss($this->style_id);
275 $skin = $this->style_container->getSkin();
276 $skin->getVersionStep($skin->getVersion());
277 $this->style_container->updateSkin($skin);
281 $this->
lng->txt($e->getMessage()),
ilSystemStyleConfig $config
An entity that renders components to a string output.
executeCommand()
Execute command.
Factory to create Skin classes holds an manages the basic data of a skin as provide by the template o...
initSystemStyleScssForm(bool $modify=true)
This class is responsible for all file system related actions related actions of a skin such as copyi...
ilGlobalTemplateInterface $tpl
skinStyleContainerFromId(string $skin_id, ilSystemStyleMessageStack $message_stack)
Get container class is responsible for all file system related actions related actions of a skin such...
ilSkinStyleContainer $style_container
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Used to stack messages to be shown to the user.
ServerRequestInterface $request
ilSystemStyleScssSettings $scss_folder
__construct(ilCtrl $ctrl, ilLanguage $lng, ilGlobalTemplateInterface $tpl, Factory $ui_factory, Renderer $renderer, ServerRequestInterface $request, ilToolbarGUI $toolbar, Refinery $refinery, ilSkinFactory $factory, string $skin_id, string $style_id)
ilSystemStyleMessageStack $message_stack