ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSystemStylesTableGUI.php
Go to the documentation of this file.
1<?php
2include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php");
3include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
4
5
6include_once("./Services/Table/classes/class.ilTable2GUI.php");
7
19{
23 protected $ctrl;
24
28 protected $lng;
29
33 protected $with_actions = false;
34
38 protected $management_enabled = false;
39
43 protected $read_documentation = true;
44
50 public function __construct($a_parent_obj, $a_parent_cmd)
51 {
52 global $DIC;
53
54 $this->ctrl = $DIC->ctrl();
55 $this->lng = $DIC->language();
56
57 parent::__construct($a_parent_obj, $a_parent_cmd);
58 $this->getStyles();
59
60 $this->setLimit(9999);
61 $this->setTitle($this->lng->txt("manage_system_styles"));
62 $this->addColumn($this->lng->txt(""));
63 $this->addColumn($this->lng->txt("style_name"), "style_name");
64 $this->addColumn($this->lng->txt("skin_name"), "skin_name");
65 $this->addColumn($this->lng->txt("sty_substyle_of"));
66 $this->addColumn($this->lng->txt("scope"));
67 $this->addColumn($this->lng->txt("default"));
68 $this->addColumn($this->lng->txt("active"));
69 $this->addColumn($this->lng->txt("users"), "users");
70 $this->setRowTemplate("tpl.sys_styles_row.html", "Services/Style/System");
71 $this->setEnableHeader(true);
72 }
73
79 {
82
83 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
84 $this->addCommandButton("saveStyleSettings", $this->lng->txt("save"));
85 $this->setRowTemplate("tpl.sys_styles_row_with_actions.html", "Services/Style/System");
86
88 $this->setWithActions(true);
89
90 $this->addColumn($this->lng->txt("actions"));
91 }
93 $this->addMultiCommand("deleteStyles", $this->lng->txt("delete"));
94 }
95 }
96
100 public function getStyles()
101 {
102 // get all user assigned styles
103 $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
104
105 // output "other" row for all users, that are not assigned to
106 // any existing style
107 $users_missing_styles = 0;
108 foreach ($all_user_styles as $skin_style_id) {
109 $style_arr = explode(":", $skin_style_id);
110 if (!ilStyleDefinition::styleExists($style_arr[1])) {
111 $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
112 }
113 }
114 $all_styles = ilStyleDefinition::getAllSkinStyles();
115 if ($users_missing_styles > 0) {
116 $all_styles["other"] =
117 array(
118 "title" => $this->lng->txt("other"),
119 "id" => "other",
120 "template_id" => "",
121 "skin_id" => "other",
122 "style_id" => "",
123 "skin_name" => "other",
124 "style_name" => "",
125 "users" => $users_missing_styles
126 );
127 }
128
129 $this->setData($all_styles);
130 }
131
132
136 protected function fillRow($a_set)
137 {
138 global $DIC;
139
140 $this->tpl->setVariable("STYLE_NAME", $a_set["style_name"]);
141 $this->tpl->setVariable("SKIN_NAME", $a_set["skin_name"]);
142 $is_substyle = $a_set["substyle_of"] != "";
143
144 if (!$is_substyle) {
145 $this->tpl->setVariable("USERS", $a_set["users"]);
146 } else {
147 $this->tpl->setVariable("USERS", "-");
148 }
149
150 if ($a_set["id"] != "other") {
151 $this->tpl->setCurrentBlock("default_input");
152
153 if (!$is_substyle) {
154 $this->tpl->setVariable("DEFAULT_ID", $a_set["id"]);
155 if (ilSystemStyleSettings::getCurrentDefaultSkin() == $a_set["skin_id"] &&
157 ) {
158 $this->tpl->setVariable("CHECKED_DEFAULT", ' checked="checked" ');
159 } else {
160 $this->tpl->setVariable("CHECKED_DEFAULT", '');
161 }
162 $this->tpl->parseCurrentBlock();
163 }
164
165 $this->tpl->setCurrentBlock("active_input");
166 $this->tpl->setVariable("ACTIVE_ID", $a_set["id"]);
167
168 if ($is_substyle) {
169 $this->tpl->setVariable("DISABLED_ACTIVE", 'disabled');
170
171 if (ilSystemStyleSettings::_lookupActivatedStyle($a_set["skin_id"], $a_set["substyle_of"])) {
172 $this->tpl->setVariable("CHECKED_ACTIVE", ' checked="checked" ');
173 } else {
174 $this->tpl->setVariable("CHECKED_ACTIVE", '');
175 }
176 } else {
177 if (ilSystemStyleSettings::_lookupActivatedStyle($a_set["skin_id"], $a_set["style_id"])) {
178 $this->tpl->setVariable("CHECKED_ACTIVE", ' checked="checked" ');
179 } else {
180 $this->tpl->setVariable("CHECKED_ACTIVE", '');
181 }
182 }
183
184 $this->tpl->parseCurrentBlock();
185 }
186
187 if ($is_substyle) {
188 $this->tpl->setVariable("SUB_STYLE_OF", $a_set["substyle_of_name"]);
189
191 $a_set["skin_id"],
192 $a_set["substyle_of"],
193 $a_set["style_id"]
194 );
195
196 $categories = [];
197
198 foreach ($assignments as $assignment) {
199 $categories[] = ilObject::_lookupTitle(ilObject::_lookupObjId($assignment["ref_id"]));
200 }
201
202 $listing = $DIC->ui()->factory()->listing()->unordered($categories);
203 $this->tpl->setVariable("CATEGORIES", $this->lng->txt("local") . $DIC->ui()
204 ->renderer()
205 ->render($listing));
206 } else {
207 $this->tpl->setVariable("SUB_STYLE_OF", "");
208 $this->tpl->setVariable("CATEGORIES", $this->lng->txt("global"));
209 }
210
211 if ($this->isWithActions()) {
212 if ($a_set["skin_id"]=="other") {
213 $this->tpl->setCurrentBlock("actions");
214 $this->tpl->setVariable("ACTIONS", "");
215 $this->tpl->parseCurrentBlock();
216 } else {
217 $action_list = new ilAdvancedSelectionListGUI();
218 $action_list->setId("id_action_list_" . $a_set["id"]);
219 $action_list->setListTitle($this->lng->txt("actions"));
220
221 if ($this->isReadDocumentation()) {
222 $DIC->ctrl()->setParameterByClass('ilSystemStyleDocumentationGUI', 'skin_id', $a_set["skin_id"]);
223 $DIC->ctrl()->setParameterByClass('ilSystemStyleDocumentationGUI', 'style_id', $a_set["style_id"]);
224 $action_list->addItem(
225 $this->lng->txt('open_documentation'),
226 'documentation',
227 $this->ctrl->getLinkTargetByClass('ilSystemStyleDocumentationGUI', 'entries')
228 );
229 }
230
231 if ($this->isManagementEnabled()) {
232 $this->ctrl->setParameterByClass('ilSystemStyleSettingsGUI', 'skin_id', $a_set["skin_id"]);
233 $this->ctrl->setParameterByClass('ilSystemStyleSettingsGUI', 'style_id', $a_set["style_id"]);
234
235 $this->ctrl->setParameterByClass('ilSystemStyleOverviewGUI', 'skin_id', $a_set["skin_id"]);
236 $this->ctrl->setParameterByClass('ilSystemStyleOverviewGUI', 'style_id', $a_set["style_id"]);
237
239 if ($a_set["skin_id"] != $config->getDefaultSkinId()) {
240 $this->addManagementActionsToList($action_list);
241 $this->addMultiActions($a_set["id"]);
242 }
243 if (!$is_substyle && $a_set["skin_id"] != "default") {
244 $action_list->addItem($this->lng->txt('export'), 'export', $this->ctrl->getLinkTargetByClass('ilSystemStyleOverviewGUI', 'export'));
245 }
246 }
247
248
249 $this->tpl->setCurrentBlock("actions");
250 $this->tpl->setVariable("ACTIONS", $action_list->getHTML());
251 $this->tpl->parseCurrentBlock();
252 }
253 }
254 }
255
257 {
258 $action_list->addItem($this->lng->txt('edit'), 'edit', $this->ctrl->getLinkTargetByClass('ilSystemStyleSettingsGUI'));
259 $action_list->addItem($this->lng->txt('delete'), 'delete', $this->ctrl->getLinkTargetByClass('ilSystemStyleOverviewGUI', 'deleteStyle'));
260 }
261
262 protected function addMultiActions($id)
263 {
264 $this->tpl->setCurrentBlock("multi_actions");
265 $this->tpl->setVariable("MULTI_ACTIONS_ID", $id);
266 $this->tpl->parseCurrentBlock();
267 }
268
272 public function isWithActions()
273 {
274 return $this->with_actions;
275 }
276
281 {
283 }
284
288 public function isManagementEnabled()
289 {
291 }
292
297 {
298 $this->management_enabled = $management_enabled;
299 }
300
304 public function isReadDocumentation()
305 {
307 }
308
313 {
314 $this->read_documentation = $read_documentation;
315 }
316}
with_actions()
Base.
Definition: with_actions.php:5
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
addItem( $a_title, $a_value="", $a_link="", $a_img="", $a_alt="", $a_frame="", $a_html="", $a_prevent_background_click=false, $a_onclick="", $a_ttip="", $a_tt_my="right center", $a_tt_at="left center", $a_tt_use_htmlspecialchars=true, $a_data=array())
Add an item.
static _getAllUserAssignedStyles()
skins and styles
static _getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static styleExists($style_id)
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
static getSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_sub_style_id)
Get all system category assignments of exactly one substyle.
static getCurrentDefaultStyle()
Gets default style of the system.
static _lookupActivatedStyle($a_skin, $a_style)
lookup if a style is activated
static getCurrentDefaultSkin()
Gets default Skin of the System.
TableGUI class for system styles.
addActions($management_enabled, $read_documentation=true)
addManagementActionsToList(ilAdvancedSelectionListGUI $action_list)
__construct($a_parent_obj, $a_parent_cmd)
ilSystemStylesTableGUI constructor.
setManagementEnabled($management_enabled)
setReadDocumentation($read_documentation)
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command button.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
if(!array_key_exists('StateId', $_REQUEST)) $id
global $DIC
Definition: saml.php:7