ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilSystemStyleScssGUI Class Reference
+ Collaboration diagram for ilSystemStyleScssGUI:

Public Member Functions

 __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)
 
 executeCommand ()
 Execute command. More...
 
 initSystemStyleScssForm (bool $modify=true)
 
 update ()
 

Protected Member Functions

 addResetToolbar ()
 
 reset ()
 
 checkRequirements ()
 
 checkScssInstallation ()
 
 edit ()
 

Protected Attributes

ilCtrl $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilSkinStyleContainer $style_container
 
ilSystemStyleScssSettings $scss_folder
 
ilSystemStyleMessageStack $message_stack
 
Factory $ui_factory
 
Renderer $renderer
 
ServerRequestInterface $request
 
ilToolbarGUI $toolbar
 
Refinery $refinery
 
ilSystemStyleConfig $config
 
string $style_id
 

Detailed Description

Definition at line 27 of file class.ilSystemStyleScssGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleScssGUI::__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 
)

Definition at line 43 of file class.ilSystemStyleScssGUI.php.

References $ctrl, $lng, $refinery, $renderer, $request, $style_id, $toolbar, $tpl, $ui_factory, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ilSkinFactory\skinStyleContainerFromId(), and ILIAS\Repository\toolbar().

55  {
56  $this->ctrl = $ctrl;
57  $this->lng = $lng;
58  $this->tpl = $tpl;
59  $this->ui_factory = $ui_factory;
60  $this->renderer = $renderer;
61  $this->request = $request;
62  $this->toolbar = $toolbar;
63  $this->refinery = $refinery;
64  $this->style_id = $style_id;
65 
66  $this->message_stack = new ilSystemStyleMessageStack($this->tpl);
67 
68  $this->style_container = $factory->skinStyleContainerFromId($skin_id, $this->message_stack);
69  $this->scss_folder = new ilSystemStyleScssSettings($this->style_container->getScssSettingsPath($style_id));
70  }
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...
Used to stack messages to be shown to the user.
ServerRequestInterface $request
+ Here is the call graph for this function:

Member Function Documentation

◆ addResetToolbar()

ilSystemStyleScssGUI::addResetToolbar ( )
protected

Definition at line 103 of file class.ilSystemStyleScssGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by executeCommand().

103  : void
104  {
105  $this->toolbar->addComponent($this->ui_factory->button()->standard(
106  $this->lng->txt('reset_variables'),
107  $this->ctrl->getLinkTarget($this, 'reset')
108  ));
109  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkRequirements()

ilSystemStyleScssGUI::checkRequirements ( )
protected

Definition at line 126 of file class.ilSystemStyleScssGUI.php.

References Vendor\Package\$e, checkScssInstallation(), ILIAS\Repository\lng(), and ilSystemStyleMessage\TYPE_ERROR.

Referenced by edit().

126  : bool
127  {
128  $scss_path = $this->style_container->getScssFilePath($this->style_id);
129 
130  $pass = $this->checkScssInstallation();
131 
132  if (file_exists($scss_path)) {
133  $scss_file_path = $this->style_container->getScssFilePath($this->style_id);
134  $content = '';
135  try {
136  $content = file_get_contents($scss_file_path);
137  } catch (Exception $e) {
138  $this->message_stack->addMessage(
140  $this->lng->txt('can_not_read_scss_folder') . ' ' . $scss_file_path,
142  )
143  );
144  $pass = false;
145  }
146  if ($content) {
147  $reg_exp = '/' . preg_quote($this->style_container->getScssSettingsFolderName(), '/') . '/';
148 
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,
155  )
156  );
157  $pass = false;
158  }
159  }
160  } else {
161  $this->message_stack->addMessage(
163  $this->lng->txt('scss_folder_does_not_exist') . $scss_path,
165  )
166  );
167  $pass = false;
168  }
169  return $pass;
170  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkScssInstallation()

ilSystemStyleScssGUI::checkScssInstallation ( )
protected

Definition at line 172 of file class.ilSystemStyleScssGUI.php.

References ILIAS\Repository\lng(), and ilSystemStyleMessage\TYPE_ERROR.

Referenced by checkRequirements().

172  : bool
173  {
174  $pass = true;
175 
176  if (!PATH_TO_SCSS) {
177  $this->message_stack->addMessage(
178  new ilSystemStyleMessage($this->lng->txt('no_scss_path_set'), ilSystemStyleMessage::TYPE_ERROR)
179  );
180  $pass = false;
181  } elseif (!shell_exec(PATH_TO_SCSS . " -h")) {
182  $this->message_stack->addMessage(
183  new ilSystemStyleMessage($this->lng->txt('invalid_scss_path'), ilSystemStyleMessage::TYPE_ERROR)
184  );
185  $this->message_stack->addMessage(
187  $this->lng->txt('provided_scss_path') . ' ' . PATH_TO_SCSS,
189  )
190  );
191  $pass = false;
192  }
193 
194  if (!$pass && shell_exec('which sass')) {
195  $this->message_stack->addMessage(
197  $this->lng->txt('scss_scss_installation_detected') . shell_exec('which sass'),
199  )
200  );
201  }
202 
203  return $pass;
204  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ edit()

ilSystemStyleScssGUI::edit ( )
protected

Definition at line 206 of file class.ilSystemStyleScssGUI.php.

References checkRequirements(), initSystemStyleScssForm(), ILIAS\Repository\lng(), and ilSystemStyleMessage\TYPE_ERROR.

Referenced by executeCommand().

206  : Form
207  {
208  $modify = true;
209 
210  if (!$this->checkRequirements()) {
211  $this->message_stack->prependMessage(
212  new ilSystemStyleMessage($this->lng->txt('scss_can_not_be_modified'), ilSystemStyleMessage::TYPE_ERROR)
213  );
214  $modify = false;
215  }
216 
217  return $this->initSystemStyleScssForm($modify);
218  }
initSystemStyleScssForm(bool $modify=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilSystemStyleScssGUI::executeCommand ( )

Execute command.

Definition at line 75 of file class.ilSystemStyleScssGUI.php.

References addResetToolbar(), ILIAS\Repository\ctrl(), edit(), reset(), and update().

75  : void
76  {
77  $this->addResetToolbar();
78  $form = null;
79 
80  $cmd = $this->ctrl->getCmd();
81 
82  switch ($cmd) {
83  case 'update':
84  $form = $this->update();
85  break;
86  case 'reset':
87  $this->reset();
88  $form = $this->edit();
89  break;
90  case 'edit':
91  case '':
92  $form = $this->edit();
93  break;
94  }
95  $components = $this->message_stack->getUIComponentsMessages($this->ui_factory);
96  if ($form) {
97  $components[] = $form;
98  }
99 
100  $this->tpl->setContent($this->renderer->render($components));
101  }
+ Here is the call graph for this function:

◆ initSystemStyleScssForm()

ilSystemStyleScssGUI::initSystemStyleScssForm ( bool  $modify = true)

Definition at line 220 of file class.ilSystemStyleScssGUI.php.

References Vendor\Package\$f, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation().

Referenced by edit(), and update().

220  : Form
221  {
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);
230  };
231  $variables_inptus[] = $f->field()->text($variable->getName(), $info)
232  //->withRequired(true)
233  ->withDisabled(!$modify)
234  ->withValue($variable->getValue())
235  ->withAdditionalTransformation($this->refinery->custom()->transformation($save_closure));
236  }
237 
238  if(count($variables_inptus) > 0) {
239  $category_sections[] = $f->field()->section(
240  $variables_inptus,
241  $category->getName(),
242  $category->getComment()
243  );
244  }
245  }
246 
247  $form_section = $f->field()->section(
248  $category_sections,
249  $this->lng->txt('adapt_scss'),
250  $this->lng->txt('adapt_scss_description')
251  );
252 
253  return $f->container()->form()->standard(
254  $this->ctrl->getFormAction($this, 'update'),
255  [$form_section]
256  )->withSubmitLabel($this->lng->txt('update_variables'));
257  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

ilSystemStyleScssGUI::reset ( )
protected

Definition at line 111 of file class.ilSystemStyleScssGUI.php.

References Vendor\Package\$e, ILIAS\Repository\lng(), and ilSystemStyleMessage\TYPE_ERROR.

Referenced by executeCommand().

111  : void
112  {
113  $style = $this->style_container->getSkin()->getStyle($this->style_id);
114  $this->scss_folder = $this->style_container->copySettingsFromDefault($style);
115  try {
116  $this->message_stack->addMessage(new ilSystemStyleMessage($this->lng->txt('scss_folder_reset')));
117  $this->style_container->compileScss($style->getId());
118  } catch (ilSystemStyleException $e) {
119  $this->message_stack->addMessage(new ilSystemStyleMessage(
120  $this->lng->txt($e->getMessage()),
122  ));
123  }
124  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilSystemStyleScssGUI::update ( )

Definition at line 259 of file class.ilSystemStyleScssGUI.php.

References Vendor\Package\$e, initSystemStyleScssForm(), ILIAS\Repository\lng(), and ilSystemStyleMessage\TYPE_ERROR.

Referenced by executeCommand().

259  : Form
260  {
261  $form = $this->initSystemStyleScssForm();
262  $form = $form->withRequest($this->request);
263 
264  if (!$form->getData()) {
265  $this->message_stack->addMessage(new ilSystemStyleMessage(
266  $this->lng->txt('scss_variables_empty_might_have_changed'),
268  ));
269  return $form;
270  }
271 
272  try {
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);
278  $this->message_stack->addMessage(new ilSystemStyleMessage($this->lng->txt('scss_folder_updated')));
279  } catch (Exception $e) {
280  $this->message_stack->addMessage(new ilSystemStyleMessage(
281  $this->lng->txt($e->getMessage()),
283  ));
284  }
285 
286  return $form;
287  }
initSystemStyleScssForm(bool $modify=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $config

ilSystemStyleConfig ilSystemStyleScssGUI::$config
protected

Definition at line 40 of file class.ilSystemStyleScssGUI.php.

◆ $ctrl

ilCtrl ilSystemStyleScssGUI::$ctrl
protected

Definition at line 29 of file class.ilSystemStyleScssGUI.php.

Referenced by __construct().

◆ $lng

ilLanguage ilSystemStyleScssGUI::$lng
protected

Definition at line 30 of file class.ilSystemStyleScssGUI.php.

Referenced by __construct().

◆ $message_stack

ilSystemStyleMessageStack ilSystemStyleScssGUI::$message_stack
protected

Definition at line 34 of file class.ilSystemStyleScssGUI.php.

◆ $refinery

Refinery ilSystemStyleScssGUI::$refinery
protected

Definition at line 39 of file class.ilSystemStyleScssGUI.php.

Referenced by __construct().

◆ $renderer

Renderer ilSystemStyleScssGUI::$renderer
protected

Definition at line 36 of file class.ilSystemStyleScssGUI.php.

Referenced by __construct().

◆ $request

ServerRequestInterface ilSystemStyleScssGUI::$request
protected

Definition at line 37 of file class.ilSystemStyleScssGUI.php.

Referenced by __construct().

◆ $scss_folder

ilSystemStyleScssSettings ilSystemStyleScssGUI::$scss_folder
protected

Definition at line 33 of file class.ilSystemStyleScssGUI.php.

◆ $style_container

ilSkinStyleContainer ilSystemStyleScssGUI::$style_container
protected

Definition at line 32 of file class.ilSystemStyleScssGUI.php.

◆ $style_id

string ilSystemStyleScssGUI::$style_id
protected

Definition at line 41 of file class.ilSystemStyleScssGUI.php.

Referenced by __construct().

◆ $toolbar

ilToolbarGUI ilSystemStyleScssGUI::$toolbar
protected

Definition at line 38 of file class.ilSystemStyleScssGUI.php.

Referenced by __construct().

◆ $tpl

ilGlobalTemplateInterface ilSystemStyleScssGUI::$tpl
protected

Definition at line 31 of file class.ilSystemStyleScssGUI.php.

Referenced by __construct().

◆ $ui_factory

Factory ilSystemStyleScssGUI::$ui_factory
protected

Definition at line 35 of file class.ilSystemStyleScssGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: