ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSystemStyleLessGUI Class Reference
+ Collaboration diagram for ilSystemStyleLessGUI:

Public Member Functions

 __construct ($skin_id="", $style_id="")
 ilSystemStyleLessGUI constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 initSystemStyleLessForm ($modify=true)
 
 getVariablesValues (ilPropertyFormGUI $form)
 
 reset ()
 
 update ()
 
 getStyleContainer ()
 
 setStyleContainer ($style_container)
 
 getLessFile ()
 
 setLessFile ($less_file)
 
 getMessageStack ()
 
 setMessageStack ($message_stack)
 

Protected Member Functions

 checkRequirements ()
 
 checkLessInstallation ()
 
 edit ()
 

Protected Attributes

 $ctrl
 
 $lng
 
 $tpl
 
 $style_container
 
 $less_file
 
 $message_stack
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleLessGUI::__construct (   $skin_id = "",
  $style_id = "" 
)

ilSystemStyleLessGUI constructor.

Parameters
string$skin_id
string$style_id

Definition at line 51 of file class.ilSystemStyleLessGUI.php.

References $_GET, $DIC, $less_file, ilSystemStyleSkinContainer\generateFromId(), getMessageStack(), getStyleContainer(), setLessFile(), setMessageStack(), setStyleContainer(), and ilSystemStyleMessage\TYPE_ERROR.

52  {
53  global $DIC;
54 
55  $this->ctrl = $DIC->ctrl();
56  $this->lng = $DIC->language();
57  $this->tpl = $DIC["tpl"];
58 
60 
61  if($skin_id == ""){
62  $skin_id = $_GET["skin_id"];
63  }
64  if($style_id == ""){
65  $style_id = $_GET["style_id"];
66  }
67 
68  try{
70  $less_file = new ilSystemStyleLessFile($this->getStyleContainer()->getLessVariablesFilePath($style_id));
71  $this->setLessFile($less_file);
72  }catch(ilSystemStyleException $e){
73  $this->getMessageStack()->addMessage(
75  );
76  }
77 
78 
79  }
$_GET["client_id"]
Class for advanced editing exception handling in ILIAS.
static generateFromId($skin_id, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
Generate the container class by parsing the corresponding XML.
Used to stack messages to be shown to the user.
global $DIC
+ Here is the call graph for this function:

Member Function Documentation

◆ checkLessInstallation()

ilSystemStyleLessGUI::checkLessInstallation ( )
protected
Returns
bool

Definition at line 148 of file class.ilSystemStyleLessGUI.php.

References $pass, getMessageStack(), and ilSystemStyleMessage\TYPE_ERROR.

Referenced by checkRequirements().

148  {
149  $pass = true;
150 
151  if(!PATH_TO_LESSC){
152  $this->getMessageStack()->addMessage(
153  new ilSystemStyleMessage($this->lng->txt("no_less_path_set"),ilSystemStyleMessage::TYPE_ERROR)
154  );
155  $pass = false;
156  }else if(!shell_exec(PATH_TO_LESSC)){
157  $this->getMessageStack()->addMessage(
158  new ilSystemStyleMessage($this->lng->txt("invalid_less_path"),ilSystemStyleMessage::TYPE_ERROR)
159  );
160  $this->getMessageStack()->addMessage(
161  new ilSystemStyleMessage($this->lng->txt("provided_less_path")." ".PATH_TO_LESSC,ilSystemStyleMessage::TYPE_ERROR)
162  );
163  $pass = false;
164  }
165 
166  if(!$pass && shell_exec("which lessc")){
167  $this->getMessageStack()->addMessage(
168  new ilSystemStyleMessage($this->lng->txt("less_less_installation_detected").shell_exec("which lessc"),ilSystemStyleMessage::TYPE_ERROR)
169  );
170  }
171 
172  return $pass;
173  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkRequirements()

ilSystemStyleLessGUI::checkRequirements ( )
protected
Returns
bool

Definition at line 106 of file class.ilSystemStyleLessGUI.php.

References $_GET, $pass, checkLessInstallation(), getMessageStack(), getStyleContainer(), and ilSystemStyleMessage\TYPE_ERROR.

Referenced by edit().

106  {
107  $style_id = $_GET['style_id'];
108  $less_path = $this->getStyleContainer()->getLessFilePath($style_id);
109 
110  $pass = $this->checkLessInstallation();
111 
112  if(file_exists($less_path)){
113  $less_variables_name = $this->getStyleContainer()->getLessVariablesName($style_id);
114  $content = "";
115  try{
116  $content = file_get_contents($less_path);
117  }catch(Exception $e){
118  $this->getMessageStack()->addMessage(
119  new ilSystemStyleMessage($this->lng->txt("can_not_read_less_file")." ".$less_path,ilSystemStyleMessage::TYPE_ERROR)
120  );
121  $pass = false;
122  }
123  if($content){
124  $reg_exp = "/".preg_quote ($less_variables_name,"/")."/";
125 
126  if(!preg_match($reg_exp,$content)){
127  $this->getMessageStack()->addMessage(
128  new ilSystemStyleMessage($this->lng->txt("less_variables_file_not_included")." ".$less_variables_name
129  ." ".$this->lng->txt("in_main_less_file")." ".$less_path,ilSystemStyleMessage::TYPE_ERROR)
130  );
131  $pass = false;
132  }
133  }
134 
135 
136  }else{
137  $this->getMessageStack()->addMessage(
138  new ilSystemStyleMessage($this->lng->txt("less_file_does_not_exist").$less_path,ilSystemStyleMessage::TYPE_ERROR)
139  );
140  $pass = false;
141  }
142  return $pass;
143  }
$_GET["client_id"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ edit()

ilSystemStyleLessGUI::edit ( )
protected

Definition at line 176 of file class.ilSystemStyleLessGUI.php.

References checkRequirements(), getLessFile(), getMessageStack(), getVariablesValues(), initSystemStyleLessForm(), and ilSystemStyleMessage\TYPE_ERROR.

Referenced by executeCommand(), and reset().

176  {
177 
178  $modify = true;
179 
180  if(!$this->checkRequirements()){
181  $this->getMessageStack()->prependMessage(
182  new ilSystemStyleMessage($this->lng->txt("less_can_not_be_modified"), ilSystemStyleMessage::TYPE_ERROR));
183  $modify = false;
184  }
185 
186  if($this->getLessFile()){
187  $form = $this->initSystemStyleLessForm($modify);
188  $this->getVariablesValues($form);
189  $this->tpl->setContent($form->getHTML());
190  }
191 
192  $this->getMessageStack()->sendMessages(true);
193 
194 
195  }
getVariablesValues(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilSystemStyleLessGUI::executeCommand ( )

Execute command.

Definition at line 84 of file class.ilSystemStyleLessGUI.php.

References $cmd, and edit().

85  {
86  $cmd = $this->ctrl->getCmd();
87 
88  switch ($cmd)
89  {
90  case "save":
91  case "edit":
92  case "reset":
93  case "update":
94  $this->$cmd();
95  break;
96  default:
97  $this->edit();
98  break;
99  }
100  }
$cmd
Definition: sahs_server.php:35
+ Here is the call graph for this function:

◆ getLessFile()

ilSystemStyleLessGUI::getLessFile ( )
Returns
ilSystemStyleLessFile

Definition at line 331 of file class.ilSystemStyleLessGUI.php.

References $less_file.

Referenced by edit(), getVariablesValues(), initSystemStyleLessForm(), and update().

332  {
333  return $this->less_file;
334  }
+ Here is the caller graph for this function:

◆ getMessageStack()

ilSystemStyleLessGUI::getMessageStack ( )
Returns
ilSystemStyleMessageStack

Definition at line 347 of file class.ilSystemStyleLessGUI.php.

References $message_stack.

Referenced by __construct(), checkLessInstallation(), checkRequirements(), and edit().

+ Here is the caller graph for this function:

◆ getStyleContainer()

ilSystemStyleLessGUI::getStyleContainer ( )
Returns
ilSystemStyleSkinContainer

Definition at line 315 of file class.ilSystemStyleLessGUI.php.

References $style_container.

Referenced by __construct(), checkRequirements(), reset(), and update().

+ Here is the caller graph for this function:

◆ getVariablesValues()

ilSystemStyleLessGUI::getVariablesValues ( ilPropertyFormGUI  $form)
Parameters
ilPropertyFormGUI$form

Definition at line 257 of file class.ilSystemStyleLessGUI.php.

References getLessFile(), and ilPropertyFormGUI\setValuesByArray().

Referenced by edit().

258  {
259  $values = [];
260  foreach($this->getLessFile()->getCategories() as $category){
261  foreach($this->getLessFile()->getVariablesPerCategory($category->getName()) as $variable){
262  $values[$variable->getName()] = $variable->getValue();
263  }
264  }
265 
266  $form->setValuesByArray($values);
267  }
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSystemStyleLessForm()

ilSystemStyleLessGUI::initSystemStyleLessForm (   $modify = true)
Parameters
bool | true$modify
Returns
ilPropertyFormGUI

Definition at line 201 of file class.ilSystemStyleLessGUI.php.

References $_GET, $info, $section, getLessFile(), and ilFormPropertyGUI\setRequired().

Referenced by edit(), and update().

202  {
203  $form = new ilPropertyFormGUI();
204 
205  $form->setTitle($this->lng->txt("adapt_less"));
206  $form->setDescription($this->lng->txt("adapt_less_description"));
207  $focus_variable = $_GET['id_less_variable'];
208  if($focus_variable){
209  $this->tpl->addOnLoadCode("setTimeout(function() { $('#".$focus_variable."').focus();}, 100);");
210  }
211 
212  foreach($this->getLessFile()->getCategories() as $category){
214  $section->setTitle($category->getName());
215  $section->setInfo($category->getComment());
216  //$section->setSectionAnchor($category->getName());
217  $form->addItem($section);
218  foreach($this->getLessFile()->getVariablesPerCategory($category->getName()) as $variable){
219  $input = new ilTextInputGUI($variable->getName(), $variable->getName());
220  $input->setRequired(true);
221  $input->setDisabled(!$modify);
222 
223  $references = $this->getLessFile()->getReferencesToVariableAsString($variable->getName());
224 
225  if($references != ""){
226  if($variable->getComment()){
227  $info = $variable->getComment()."</br>".$this->lng->txt("usages")." ".$references;
228  }else{
229  $info = $this->lng->txt("usages")." ".$references;
230  }
231  }else{
232  $info = $variable->getComment();
233  }
234  $input->setInfo($info);
235 
236  $form->addItem($input);
237 
238  }
239  }
240 
241  if($modify){
242  $form->addCommandButton("update", $this->lng->txt("update_variables"));
243  $form->addCommandButton("reset", $this->lng->txt("reset_variables"));
244  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
245  }
246 
247 
248  $form->setFormAction($this->ctrl->getFormAction($this));
249 
250  return $form;
251  }
This class represents a property form user interface.
$_GET["client_id"]
This class represents a section header in a property form.
$section
Definition: Utf8Test.php:83
$info
Definition: example_052.php:80
This class represents a text property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

ilSystemStyleLessGUI::reset ( )

Definition at line 272 of file class.ilSystemStyleLessGUI.php.

References $_GET, $style, edit(), getStyleContainer(), ilUtil\sendFailure(), and setLessFile().

273  {
274  $style = $this->getStyleContainer()->getSkin()->getStyle($_GET["style_id"]);
275  $this->setLessFile($this->getStyleContainer()->copyVariablesFromDefault($style));
276  try{
277  $this->getStyleContainer()->compileLess($style->getId());
278  }catch(ilSystemStyleException $e){
279  ilUtil::sendFailure($this->lng->txt($e->getMessage()),true);
280  }
281 
282  $this->edit();
283  }
$style
Definition: example_012.php:70
$_GET["client_id"]
Class for advanced editing exception handling in ILIAS.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ setLessFile()

ilSystemStyleLessGUI::setLessFile (   $less_file)
Parameters
ilSystemStyleLessFile$less_file

Definition at line 339 of file class.ilSystemStyleLessGUI.php.

References $less_file.

Referenced by __construct(), and reset().

340  {
341  $this->less_file = $less_file;
342  }
+ Here is the caller graph for this function:

◆ setMessageStack()

ilSystemStyleLessGUI::setMessageStack (   $message_stack)
Parameters
ilSystemStyleMessageStack$message_stack

Definition at line 355 of file class.ilSystemStyleLessGUI.php.

References $message_stack.

Referenced by __construct().

356  {
357  $this->message_stack = $message_stack;
358  }
+ Here is the caller graph for this function:

◆ setStyleContainer()

ilSystemStyleLessGUI::setStyleContainer (   $style_container)
Parameters
ilSystemStyleSkinContainer$style_container

Definition at line 323 of file class.ilSystemStyleLessGUI.php.

References $style_container.

Referenced by __construct().

324  {
325  $this->style_container = $style_container;
326  }
+ Here is the caller graph for this function:

◆ update()

ilSystemStyleLessGUI::update ( )

Definition at line 285 of file class.ilSystemStyleLessGUI.php.

References $_GET, getLessFile(), getStyleContainer(), initSystemStyleLessForm(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

286  {
287  $form = $this->initSystemStyleLessForm();
288  if ($form->checkInput())
289  {
290  foreach($this->getLessFile()->getCategories() as $category){
291  foreach($this->getLessFile()->getVariablesPerCategory($category->getName()) as $variable){
292  $variable->setValue($form->getInput($variable->getName()));
293  }
294  }
295  try{
296  $this->getLessFile()->write();
297  $this->getStyleContainer()->compileLess($_GET["style_id"]);
298  $skin = $this->getStyleContainer()->getSkin();
299  $skin->getVersionStep($skin->getVersion());
300  $this->getStyleContainer()->updateSkin($skin);
301  ilUtil::sendSuccess($this->lng->txt("less_file_updated"));
302  }catch(Exception $e){
303  ilUtil::sendFailure($this->lng->txt($e->getMessage()),true);
304  }
305  }
306 
307  $form->setValuesByPost();
308  $this->tpl->setContent($form->getHTML());
309 
310  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_GET["client_id"]
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilSystemStyleLessGUI::$ctrl
protected

Definition at line 18 of file class.ilSystemStyleLessGUI.php.

◆ $less_file

ilSystemStyleLessGUI::$less_file
protected

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

Referenced by __construct(), getLessFile(), and setLessFile().

◆ $lng

ilSystemStyleLessGUI::$lng
protected

Definition at line 23 of file class.ilSystemStyleLessGUI.php.

◆ $message_stack

ilSystemStyleLessGUI::$message_stack
protected

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

Referenced by getMessageStack(), and setMessageStack().

◆ $style_container

ilSystemStyleLessGUI::$style_container
protected

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

Referenced by getStyleContainer(), and setStyleContainer().

◆ $tpl

ilSystemStyleLessGUI::$tpl
protected

Definition at line 28 of file class.ilSystemStyleLessGUI.php.


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