ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSystemStyleMainGUI.php
Go to the documentation of this file.
1 <?php
2 include_once("Services/Object/exceptions/class.ilObjectException.php");
3 
4 /* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
5 
21 {
25  protected $ctrl;
26 
30  protected $lng;
31 
32 
36  protected $DIC;
37 
41  protected $tabs;
42 
43 
47  protected $rbacsystem;
48 
52  protected $ref_id;
53 
57  protected $tpl;
58 
62  function __construct()
63  {
64  global $DIC;
65 
66  $this->ctrl = $DIC->ctrl();
67  $this->lng = $DIC->language();
68  $this->tabs = $DIC->tabs();
69  $this->rbacsystem = $DIC->rbac()->system();
70  $this->tpl = $DIC["tpl"];
71 
72  $this->ref_id = (int) $_GET["ref_id"];
73  }
74 
75 
82  function executeCommand()
83  {
84  $next_class = $this->ctrl->getNextClass($this);
85 
86  $this->ctrl->setParameterByClass('ilsystemstylesettingsgui','skin_id',$_GET["skin_id"]);
87  $this->ctrl->setParameterByClass('ilsystemstylesettingsgui','style_id',$_GET["style_id"]);
88  $this->ctrl->setParameterByClass('ilsystemstylelessgui','skin_id',$_GET["skin_id"]);
89  $this->ctrl->setParameterByClass('ilsystemstylelessgui','style_id',$_GET["style_id"]);
90  $this->ctrl->setParameterByClass('ilsystemstyleiconsgui','skin_id',$_GET["skin_id"]);
91  $this->ctrl->setParameterByClass('ilsystemstyleiconsgui','style_id',$_GET["style_id"]);
92  $this->ctrl->setParameterByClass('ilsystemstyledocumentationgui','skin_id',$_GET["skin_id"]);
93  $this->ctrl->setParameterByClass('ilsystemstyledocumentationgui','style_id',$_GET["style_id"]);
94 
95  try{
96  switch ($next_class)
97  {
98 
99  case "ilsystemstylesettingsgui":
100  $this->checkPermission("sty_management");
101  $this->setUnderworldTabs('settings');
102  $this->setUnderworldTitle();
103  include_once("Settings/class.ilSystemStyleSettingsGUI.php");
104  $system_styles_settings = new ilSystemStyleSettingsGUI();
105  $this->ctrl->forwardCommand($system_styles_settings);
106  break;
107  case "ilsystemstylelessgui":
108  $this->checkPermission("sty_management");
109  $this->setUnderworldTabs('less');
110  $this->setUnderworldTitle();
111  include_once("Less/class.ilSystemStyleLessGUI.php");
112  $system_styles_less = new ilSystemStyleLessGUI();
113  $this->ctrl->forwardCommand($system_styles_less);
114  break;
115  case "ilsystemstyleiconsgui":
116  $this->checkPermission("sty_management");
117  $this->setUnderworldTabs('icons');
118  $this->setUnderworldTitle();
119  include_once("Icons/class.ilSystemStyleIconsGUI.php");
120  $system_styles_icons = new ilSystemStyleIconsGUI();
121  $this->ctrl->forwardCommand($system_styles_icons);
122  break;
123  case "ilsystemstyledocumentationgui":
124  $this->checkPermission("sty_management");
125  $this->setUnderworldTabs('documentation');
126  $this->setUnderworldTitle();
127  include_once("Documentation/class.ilSystemStyleDocumentationGUI.php");
128  $system_styles_documentation = new ilSystemStyleDocumentationGUI();
129  $this->ctrl->forwardCommand($system_styles_documentation);
130  break;
131  case "ilsystemstyleoverviewgui":
132  default:
133  $this->checkPermission("visible,read");
134  include_once("Overview/class.ilSystemStyleOverviewGUI.php");
135  $system_styles_overview = new ilSystemStyleOverviewGUI(!$this->checkPermission("sty_write_system",false)
136  ,$this->checkPermission("sty_management",false));
137  $this->ctrl->forwardCommand($system_styles_overview);
138  break;
139  }
140  }catch(ilObjectException $e){
141  ilUtil::sendFailure($e->getMessage());
142  $this->checkPermission("visible,read");
143  include_once("Overview/class.ilSystemStyleOverviewGUI.php");
144  $this->ctrl->setCmd("");
145  $system_styles_overview = new ilSystemStyleOverviewGUI(!$this->checkPermission("sty_write_system",false),$this->checkPermission("sty_management",false));
146  $this->ctrl->forwardCommand($system_styles_overview);
147  }
148  }
149 
159  public function checkPermission($a_perm, $a_throw_exc = true)
160  {
161  global $ilIliasIniFile;
162 
163  $has_perm = true;
164 
166  if($a_perm == "sty_management"){
167  $has_perm = $ilIliasIniFile->readVariable("tools","enable_system_styles_management")== "1" ? true:false;
168  $a_perm = "sty_write_system";
169  if($has_perm && ! is_writable($config->getCustomizingSkinPath())){
170  ilUtil::sendFailure($this->lng->txt("enable_system_styles_management_no_write_perm"));
171  $has_perm = false;
172  }
173  }
174 
175  if($has_perm){
176  $has_perm = $this->rbacsystem->checkAccess($a_perm, $this->ref_id);
177  }
178 
179  if (!$has_perm)
180  {
181  if ($a_throw_exc)
182  {
183  include_once "Services/Object/exceptions/class.ilObjectException.php";
184  throw new ilObjectException($this->lng->txt("sty_permission_denied"));
185  }
186  return false;
187  }
188  return $has_perm;
189  }
190 
196  protected function setUnderworldTabs($active = "") {
197  $this->tabs->clearTargets();
198 
199  $this->tabs->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTarget($this));
200  $this->tabs->addTab('settings', $this->lng->txt('settings'), $this->ctrl->getLinkTargetByClass('ilsystemstylesettingsgui'));
201  $this->tabs->addTab('less', $this->lng->txt('less'), $this->ctrl->getLinkTargetByClass('ilsystemstylelessgui'));
202  $this->tabs->addTab('icons', $this->lng->txt('icons'), $this->ctrl->getLinkTargetByClass('ilsystemstyleiconsgui'));
203  $this->tabs->addTab('documentation', $this->lng->txt('documentation'), $this->ctrl->getLinkTargetByClass('ilsystemstyledocumentationgui'));
204 
205  $this->tabs->activateTab($active);
206  }
207 
208 
214  protected function setUnderworldTitle() {
215  $skin_id = $_GET["skin_id"];
216  $style_id = $_GET["style_id"];
217 
218  $skin = ilSystemStyleSkinContainer::generateFromId($skin_id)->getSkin();
219  $style = $skin->getStyle($style_id);
220 
221  $this->tpl->setTitle($style->getName());
222  if($style->isSubstyle()){
223  $this->tpl->setDescription($this->lng->txt("settings_of_substyle")." '".$style->getName()."' ".
224  $this->lng->txt("of_parent")." '".$skin->getStyle($style->getSubstyleOf())->getName()."' ".
225  $this->lng->txt("from_skin")." ".$skin->getName()
226  );
227  }else{
228  $this->tpl->setDescription($this->lng->txt("settings_of_style")." '".$style->getName()."' ".
229  $this->lng->txt("from_skin")." '".$skin->getName()."'"
230  );
231  }
232  }
233 }
setUnderworldTitle()
Sets title correctly if one system style is opened.
$style
Definition: example_012.php:70
$_GET["client_id"]
Base exception class for object service.
checkPermission($a_perm, $a_throw_exc=true)
Checks permission for system styles.
static generateFromId($skin_id, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
Generate the container class by parsing the corresponding XML.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Settings UI class for system styles.
executeCommand()
Main routing of the system styles.
ilSystemStyleConfig wraps all &#39;constants&#39; to ensure the testability of all classes using those &#39;const...
$ilIliasIniFile
setUnderworldTabs($active="")
Sets the tab correctly if one system style is open (navigational underworld opened) ...