19 declare(strict_types=1);
49 ServerRequestInterface $request,
69 $this->less_file =
new ilSystemStyleLessFile($this->style_container->getLessVariablesFilePath($style_id));
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->less_file = $this->style_container->copyVariablesFromDefault($style);
117 $this->style_container->compileLess($style->getId());
120 $this->
lng->txt($e->getMessage()),
128 $less_path = $this->style_container->getLessFilePath($this->style_id);
132 if (file_exists($less_path)) {
133 $less_variables_name = $this->style_container->getLessVariablesName($this->style_id);
136 $content = file_get_contents($less_path);
138 $this->message_stack->addMessage(
140 $this->
lng->txt(
'can_not_read_less_file') .
' ' . $less_path,
147 $reg_exp =
'/' . preg_quote($less_variables_name,
'/') .
'/';
149 if (!preg_match($reg_exp, $content)) {
150 $this->message_stack->addMessage(
152 $this->
lng->txt(
'less_variables_file_not_included') .
' ' . $less_variables_name
153 .
' ' . $this->
lng->txt(
'in_main_less_file') .
' ' . $less_path,
161 $this->message_stack->addMessage(
163 $this->
lng->txt(
'less_file_does_not_exist') . $less_path,
176 if (!PATH_TO_LESSC) {
177 $this->message_stack->addMessage(
181 } elseif (!shell_exec(PATH_TO_LESSC)) {
182 $this->message_stack->addMessage(
185 $this->message_stack->addMessage(
187 $this->
lng->txt(
'provided_less_path') .
' ' . PATH_TO_LESSC,
194 if (!$pass && shell_exec(
'which lessc')) {
195 $this->message_stack->addMessage(
197 $this->
lng->txt(
'less_less_installation_detected') . shell_exec(
'which lessc'),
211 $this->message_stack->prependMessage(
222 $f = $this->ui_factory->input();
223 $category_section = [];
224 foreach ($this->less_file->getCategories() as $category) {
225 $variables_inptus = [];
226 foreach ($this->less_file->getVariablesPerCategory($category->getName()) as $variable) {
227 $info = $this->less_file->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 $category_section[] =
$f->field()->section(
240 $category->getName(),
241 $category->getComment()
245 $form_section =
$f->field()->section(
247 $this->
lng->txt(
'adapt_less'),
248 $this->
lng->txt(
'adapt_less_description')
251 return $f->container()->form()->standard(
252 $this->
ctrl->getFormAction($this,
'update'),
254 )->withSubmitCaption($this->
lng->txt(
'update_variables'));
260 $form = $form->withRequest($this->request);
262 if (!$form->getData()) {
264 $this->
lng->txt(
'less_variables_empty_might_have_changed'),
271 $this->less_file->write();
272 $this->style_container->compileLess($this->style_id);
273 $skin = $this->style_container->getSkin();
274 $skin->getVersionStep($skin->getVersion());
275 $this->style_container->updateSkin($skin);
279 $this->
lng->txt($e->getMessage()),
executeCommand()
Execute command.
An entity that renders components to a string output.
ilSystemStyleMessageStack $message_stack
ilGlobalTemplateInterface $tpl
Factory to create Skin classes holds an manages the basic data of a skin as provide by the template o...
ilSystemStyleLessFile $less_file
initSystemStyleLessForm(bool $modify=true)
ilSkinStyleContainer $style_container
This class is responsible for all file system related actions related actions of a skin such as copyi...
ilSystemStyleConfig $config
skinStyleContainerFromId(string $skin_id, ilSystemStyleMessageStack $message_stack)
Get container class is responsible for all file system related actions related actions of a skin such...
ServerRequestInterface $request
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
__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)
Used to stack messages to be shown to the user.