ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilSystemStyleMainGUI.php
Go to the documentation of this file.
1<?php
2include_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 public function __construct()
63 {
67 global $DIC;
68
69 $this->ctrl = $DIC->ctrl();
70 $this->lng = $DIC->language();
71 $this->tabs = $DIC->tabs();
72 $this->rbacsystem = $DIC->rbac()->system();
73 $this->tpl = $DIC["tpl"];
74 $this->help =
75
76 $this->ref_id = (int) $_GET["ref_id"];
77 }
78
79
86 public function executeCommand()
87 {
91 global $DIC;
92
93
94 $next_class = $this->ctrl->getNextClass($this);
95
96 $DIC->help()->setScreenIdComponent("sty");
97 $DIC->help()->setScreenId("system_styles");
98
99 if (!$_GET["skin_id"]) {
101 $_GET["skin_id"] = $config->getDefaultSkinId();
102 $_GET["style_id"] = $config->getDefaultStyleId();
103 }
104
105 $this->ctrl->setParameterByClass('ilsystemstylesettingsgui', 'skin_id', $_GET["skin_id"]);
106 $this->ctrl->setParameterByClass('ilsystemstylesettingsgui', 'style_id', $_GET["style_id"]);
107 $this->ctrl->setParameterByClass('ilsystemstylelessgui', 'skin_id', $_GET["skin_id"]);
108 $this->ctrl->setParameterByClass('ilsystemstylelessgui', 'style_id', $_GET["style_id"]);
109 $this->ctrl->setParameterByClass('ilsystemstyleiconsgui', 'skin_id', $_GET["skin_id"]);
110 $this->ctrl->setParameterByClass('ilsystemstyleiconsgui', 'style_id', $_GET["style_id"]);
111 $this->ctrl->setParameterByClass('ilsystemstyledocumentationgui', 'skin_id', $_GET["skin_id"]);
112 $this->ctrl->setParameterByClass('ilsystemstyledocumentationgui', 'style_id', $_GET["style_id"]);
113
114 try {
115 switch ($next_class) {
116
117 case "ilsystemstylesettingsgui":
118 $DIC->help()->setSubScreenId("settings");
119 $this->checkPermission("sty_management");
120 $this->setUnderworldTabs('settings');
121 $this->setUnderworldTitle();
122 include_once("Settings/class.ilSystemStyleSettingsGUI.php");
123 $system_styles_settings = new ilSystemStyleSettingsGUI();
124 $this->ctrl->forwardCommand($system_styles_settings);
125 break;
126 case "ilsystemstylelessgui":
127 $DIC->help()->setSubScreenId("less");
128 $this->checkPermission("sty_management");
129 $this->setUnderworldTabs('less');
130 $this->setUnderworldTitle();
131 include_once("Less/class.ilSystemStyleLessGUI.php");
132 $system_styles_less = new ilSystemStyleLessGUI();
133 $this->ctrl->forwardCommand($system_styles_less);
134 break;
135 case "ilsystemstyleiconsgui":
136 $DIC->help()->setSubScreenId("icons");
137 $this->checkPermission("sty_management");
138 $this->setUnderworldTabs('icons');
139 $this->setUnderworldTitle();
140 include_once("Icons/class.ilSystemStyleIconsGUI.php");
141 $system_styles_icons = new ilSystemStyleIconsGUI();
142 $this->ctrl->forwardCommand($system_styles_icons);
143 break;
144 case "ilsystemstyledocumentationgui":
145 $DIC->help()->setSubScreenId("documentation");
146 $read_only = !$this->checkPermission("sty_management", false);
147 $this->setUnderworldTabs('documentation');
148 $this->setUnderworldTitle();
149 include_once("Documentation/class.ilSystemStyleDocumentationGUI.php");
150 $system_styles_documentation = new ilSystemStyleDocumentationGUI($read_only);
151 $this->ctrl->forwardCommand($system_styles_documentation);
152 break;
153 case "ilsystemstyleoverviewgui":
154 default:
155 $DIC->help()->setSubScreenId("overview");
156 $this->checkPermission("visible,read");
157 include_once("Overview/class.ilSystemStyleOverviewGUI.php");
158 $system_styles_overview = new ilSystemStyleOverviewGUI(!$this->checkPermission("sty_write_system", false), $this->checkPermission("sty_management", false));
159 $this->ctrl->forwardCommand($system_styles_overview);
160 break;
161 }
162 } catch (ilObjectException $e) {
163 ilUtil::sendFailure($e->getMessage());
164 $this->checkPermission("visible,read");
165 include_once("Overview/class.ilSystemStyleOverviewGUI.php");
166 $this->ctrl->setCmd("");
167 $system_styles_overview = new ilSystemStyleOverviewGUI(!$this->checkPermission("sty_write_system", false), $this->checkPermission("sty_management", false));
168 $this->ctrl->forwardCommand($system_styles_overview);
169 }
170 }
171
176 public static function _goto($ref_id, $params)
177 {
178 global $DIC;
179
180 $node_id = $params[2];
181 $skin_id = $params[3];
182 $style_id = $params[4];
183
184 $DIC->ctrl()->setParameterByClass('ilSystemStyleDocumentationGUI', 'skin_id', $skin_id);
185 $DIC->ctrl()->setParameterByClass(
186 'ilSystemStyleDocumentationGUI',
187 'style_id',
188 $style_id
189 );
190 $DIC->ctrl()->setParameterByClass('ilSystemStyleDocumentationGUI', 'node_id', $node_id);
191 $DIC->ctrl()->setParameterByClass('ilSystemStyleDocumentationGUI', 'ref_id', $ref_id);
192
193 $_GET['baseClass'] = 'ilAdministrationGUI';
194
195 $cmd = "entries";
196 $cmd_classes = [
197 "ilAdministrationGUI",
198 "ilObjStyleSettingsGUI",
199 "ilSystemStyleMainGUI",
200 'ilSystemStyleDocumentationGUI'
201 ];
202
203 $DIC->ctrl()->setTargetScript("ilias.php");
204 $DIC->ctrl()->redirectByClass($cmd_classes, $cmd);
205 }
206
216 public function checkPermission($a_perm, $a_throw_exc = true)
217 {
218 global $DIC;
219
220 $has_perm = true;
221
223 if ($a_perm == "sty_management") {
224 $has_perm = $DIC->iliasIni()->readVariable("tools", "enable_system_styles_management") == "1" ? true:false;
225 $a_perm = "sty_write_system";
226 if ($has_perm && !is_writable($config->getCustomizingSkinPath())) {
227 ilUtil::sendFailure($this->lng->txt("enable_system_styles_management_no_write_perm"));
228 $has_perm = false;
229 }
230 }
231
232 if ($has_perm) {
233 $has_perm = $this->rbacsystem->checkAccess($a_perm, $this->ref_id);
234 }
235
236 if (!$has_perm) {
237 if ($a_throw_exc) {
238 include_once "Services/Object/exceptions/class.ilObjectException.php";
239 throw new ilObjectException($this->lng->txt("sty_permission_denied"));
240 }
241 return false;
242 }
243 return $has_perm;
244 }
245
251 protected function setUnderworldTabs($active = "")
252 {
253 global $DIC;
254 $this->tabs->clearTargets();
255
259 $DIC->help()->setScreenIdComponent("sty");
260 $DIC->help()->setScreenId("system_styles");
261 $this->tabs->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this));
263 if ($_GET["skin_id"] != $config->getDefaultSkinId()) {
264 $this->tabs->addTab('settings', $this->lng->txt('settings'), $this->ctrl->getLinkTargetByClass('ilsystemstylesettingsgui'));
265 $this->tabs->addTab('less', $this->lng->txt('less'), $this->ctrl->getLinkTargetByClass('ilsystemstylelessgui'));
266 $this->tabs->addTab('icons', $this->lng->txt('icons'), $this->ctrl->getLinkTargetByClass('ilsystemstyleiconsgui'));
267 }
268
269 $this->tabs->addTab('documentation', $this->lng->txt('documentation'), $this->ctrl->getLinkTargetByClass('ilsystemstyledocumentationgui'));
270
271 $this->tabs->activateTab($active);
272 }
273
274
280 protected function setUnderworldTitle()
281 {
282 $skin_id = $_GET["skin_id"];
283 $style_id = $_GET["style_id"];
284
285 $skin = ilSystemStyleSkinContainer::generateFromId($skin_id)->getSkin();
286 $style = $skin->getStyle($style_id);
287
288 $this->tpl->setTitle($style->getName());
289 if ($style->isSubstyle()) {
290 $this->tpl->setDescription(
291 $this->lng->txt("settings_of_substyle") . " '" . $style->getName() . "' " .
292 $this->lng->txt("of_parent") . " '" . $skin->getStyle($style->getSubstyleOf())->getName() . "' " .
293 $this->lng->txt("from_skin") . " " . $skin->getName()
294 );
295 } else {
296 $this->tpl->setDescription(
297 $this->lng->txt("settings_of_style") . " '" . $style->getName() . "' " .
298 $this->lng->txt("from_skin") . " '" . $skin->getName() . "'"
299 );
300 }
301 }
302}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Base exception class for object service.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Settings UI class for system styles.
checkPermission($a_perm, $a_throw_exc=true)
Checks permission for system styles.
static _goto($ref_id, $params)
setUnderworldTitle()
Sets title correctly if one system style is opened.
setUnderworldTabs($active="")
Sets the tab correctly if one system style is open (navigational underworld opened)
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.
help()
Definition: help.php:2
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc