ILIAS  release_8 Revision v8.24
class.ilSystemStylesTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected bool $with_actions = false;
27 protected bool $management_enabled = false;
28 protected bool $read_documentation = true;
29
30 public function __construct(object $a_parent_obj, string $a_parent_cmd = '')
31 {
32 parent::__construct($a_parent_obj, $a_parent_cmd);
33 $this->getStyles();
34
35 $this->setLimit(9999);
36 $this->setTitle($this->lng->txt('manage_system_styles'));
37 $this->addColumn($this->lng->txt(''));
38 $this->addColumn($this->lng->txt('style_name'), 'style_name');
39 $this->addColumn($this->lng->txt('skin_name'), 'skin_name');
40 $this->addColumn($this->lng->txt('sty_substyle_of'));
41 $this->addColumn($this->lng->txt('scope'));
42 $this->addColumn($this->lng->txt('default'));
43 $this->addColumn($this->lng->txt('active'));
44 $this->addColumn($this->lng->txt('users'), 'users');
45 $this->addColumn($this->lng->txt('version'));
46 $this->setRowTemplate('tpl.sys_styles_row.html', 'Services/Style/System');
47 $this->setEnableHeader(true);
48 }
49
54 public function addActions($management_enabled, bool $read_documentation = true)
55 {
56 $this->setManagementEnabled($management_enabled);
57 $this->setReadDocumentation($read_documentation);
58
59 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
60 $this->addCommandButton('saveStyleSettings', $this->lng->txt('save'));
61 $this->setRowTemplate('tpl.sys_styles_row_with_actions.html', 'Services/Style/System');
62
63 if ($read_documentation || $management_enabled) {
64 $this->setWithActions(true);
65
66 $this->addColumn($this->lng->txt('actions'));
67 }
68 if ($management_enabled) {
69 $this->addMultiCommand('deleteStyles', $this->lng->txt('delete'));
70 }
71 }
72
76 public function getStyles()
77 {
78 // get all user assigned styles
79 $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
80
81 // output 'other' row for all users, that are not assigned to
82 // any existing style
83 $users_missing_styles = 0;
84 foreach ($all_user_styles as $skin_style_id) {
85 $style_arr = explode(':', $skin_style_id);
86 if (!ilStyleDefinition::styleExists($style_arr[1])) {
87 $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
88 }
89 }
91 if ($users_missing_styles > 0) {
92 $all_styles['other'] =
93 [
94 'title' => $this->lng->txt('other'),
95 'id' => 'other',
96 'template_id' => '',
97 'skin_id' => 'other',
98 'style_id' => '',
99 'skin_name' => 'other',
100 'style_name' => '',
101 'users' => $users_missing_styles,
102 'version' => '-'
103 ];
104 }
105
106 $this->setData($all_styles);
107 }
108
113 protected function fillRow(array $a_set): void
114 {
115 global $DIC;
116
117 $this->tpl->setVariable('STYLE_NAME', $a_set['style_name']);
118 $this->tpl->setVariable('SKIN_NAME', $a_set['skin_name']);
119 $is_substyle = isset($a_set['substyle_of']) && $a_set['substyle_of'] != '';
120
121 if (!$is_substyle) {
122 $this->tpl->setVariable('USERS', $a_set['users']);
123 } else {
124 $this->tpl->setVariable('USERS', '-');
125 }
126
127 if ($a_set['id'] != 'other') {
128 $this->tpl->setCurrentBlock('default_input');
129
130 if (!$is_substyle) {
131 $this->tpl->setVariable('DEFAULT_ID', $a_set['id']);
132 if (ilSystemStyleSettings::getCurrentDefaultSkin() == $a_set['skin_id'] &&
134 ) {
135 $this->tpl->setVariable('CHECKED_DEFAULT', " checked='checked' ");
136 } else {
137 $this->tpl->setVariable('CHECKED_DEFAULT');
138 }
139 $this->tpl->parseCurrentBlock();
140 }
141
142 $this->tpl->setCurrentBlock('active_input');
143 $this->tpl->setVariable('ACTIVE_ID', $a_set['id']);
144
145 if ($is_substyle) {
146 $this->tpl->setVariable('DISABLED_ACTIVE', 'disabled');
147
148 if (ilSystemStyleSettings::_lookupActivatedStyle($a_set['skin_id'], $a_set['substyle_of'])) {
149 $this->tpl->setVariable('CHECKED_ACTIVE', " checked='checked' ");
150 } else {
151 $this->tpl->setVariable('CHECKED_ACTIVE');
152 }
153 } elseif (ilSystemStyleSettings::_lookupActivatedStyle($a_set['skin_id'], $a_set['style_id'])) {
154 $this->tpl->setVariable('CHECKED_ACTIVE', " checked='checked' ");
155 } else {
156 $this->tpl->setVariable('CHECKED_ACTIVE');
157 }
158
159 $this->tpl->parseCurrentBlock();
160 }
161
162 if ($is_substyle) {
163 $this->tpl->setVariable('SUB_STYLE_OF', $a_set['substyle_of_name']);
164
166 $a_set['skin_id'],
167 $a_set['substyle_of'],
168 $a_set['style_id']
169 );
170
171 $categories = [];
172
173 foreach ($assignments as $assignment) {
174 $category_title = ilObject::_lookupTitle(ilObject::_lookupObjId((int) $assignment['ref_id']));
175 if ($category_title) {
176 $categories[] = $category_title;
177 }
178 }
179
180 $listing = $DIC->ui()->factory()->listing()->unordered($categories);
181 $this->tpl->setVariable(
182 'CATEGORIES',
183 $this->lng->txt('local') . $DIC->ui()->renderer()->render($listing)
184 );
185 } else {
186 $this->tpl->setVariable('SUB_STYLE_OF');
187 $this->tpl->setVariable('CATEGORIES', $this->lng->txt('global'));
188 }
189
190 $this->tpl->setVariable('VERSION', $a_set['version']);
191
192 if ($this->isWithActions()) {
194 if ($a_set['skin_id'] == 'other') {
195 $this->tpl->setCurrentBlock('actions');
196 $this->tpl->setVariable('ACTIONS');
197 $this->tpl->parseCurrentBlock();
198 } else {
199 $action_list = new ilAdvancedSelectionListGUI();
200 $action_list->setId('id_action_list_' . $a_set['id']);
201 $action_list->setListTitle($this->lng->txt('actions'));
202
203 if ($this->isReadDocumentation()) {
204 $DIC->ctrl()->setParameterByClass('ilSystemStyleDocumentationGUI', 'skin_id', $a_set['skin_id']);
205 $DIC->ctrl()->setParameterByClass('ilSystemStyleDocumentationGUI', 'style_id', $a_set['style_id']);
206 $action_list->addItem(
207 $this->lng->txt('open_documentation'),
208 'documentation',
209 $this->ctrl->getLinkTargetByClass('ilSystemStyleDocumentationGUI', 'entries')
210 );
211 }
212
213 if ($this->isManagementEnabled()) {
214 $this->ctrl->setParameterByClass('ilSystemStyleSettingsGUI', 'skin_id', $a_set['skin_id']);
215 $this->ctrl->setParameterByClass('ilSystemStyleSettingsGUI', 'style_id', $a_set['style_id']);
216
217 $this->ctrl->setParameterByClass('ilSystemStyleOverviewGUI', 'skin_id', $a_set['skin_id']);
218 $this->ctrl->setParameterByClass('ilSystemStyleOverviewGUI', 'style_id', $a_set['style_id']);
219
221 if ($a_set['skin_id'] != $config->getDefaultSkinId()) {
222 $this->addManagementActionsToList($action_list);
223 $this->addMultiActions($a_set['id']);
224 }
225 if (!$is_substyle && $a_set['skin_id'] != 'default') {
226 $action_list->addItem(
227 $this->lng->txt('export'),
228 'export',
229 $this->ctrl->getLinkTargetByClass('ilSystemStyleOverviewGUI', 'export')
230 );
231 }
232 }
233
234 $this->tpl->setCurrentBlock('actions');
235 $this->tpl->setVariable('ACTIONS', $action_list->getHTML());
236 $this->tpl->parseCurrentBlock();
237 }
238 }
239 }
240
242 {
243 $action_list->addItem(
244 $this->lng->txt('edit'),
245 'edit',
246 $this->ctrl->getLinkTargetByClass('ilSystemStyleSettingsGUI')
247 );
248 $action_list->addItem(
249 $this->lng->txt('delete'),
250 'delete',
251 $this->ctrl->getLinkTargetByClass('ilSystemStyleOverviewGUI', 'deleteStyle')
252 );
253 }
254
255 protected function addMultiActions($id)
256 {
257 $this->tpl->setCurrentBlock('multi_actions');
258 $this->tpl->setVariable('MULTI_ACTIONS_ID', $id);
259 $this->tpl->parseCurrentBlock();
260 }
261
262 public function isWithActions(): bool
263 {
264 return $this->with_actions;
265 }
266
267 public function setWithActions(bool $with_actions): void
268 {
270 }
271
272 public function isManagementEnabled(): bool
273 {
275 }
276
278 {
279 $this->management_enabled = $management_enabled;
280 }
281
282 public function isReadDocumentation(): bool
283 {
285 }
286
288 {
289 $this->read_documentation = $read_documentation;
290 }
291}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addItem(string $a_title, string $a_value="", string $a_link="", string $a_img="", string $a_alt="", string $a_frame="", string $a_html="", bool $a_prevent_background_click=false, string $a_onclick="", string $a_ttip="", string $a_tt_my="right center", string $a_tt_at="left center", bool $a_tt_use_htmlspecialchars=true, array $a_data=array())
static _getNumberOfUsersForStyle(string $a_skin, string $a_style)
static _getAllUserAssignedStyles()
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static getAllSkinStyles()
Get all skins/styles as array (convenient for tables) Attention: tempalte_name/template_id in this ar...
static styleExists(string $style_id)
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
static getCurrentDefaultStyle()
Gets default style of the system.
static _lookupActivatedStyle(string $a_skin, string $a_style)
lookup if a style is activated
static getCurrentDefaultSkin()
Gets default Skin of the System.
static getSubStyleCategoryAssignments(string $a_skin_id, string $a_style_id, string $a_sub_style_id)
Get all system category assignments of exactly one substyle.
TableGUI class for system styles.
addActions($management_enabled, bool $read_documentation=true)
setReadDocumentation(bool $read_documentation)
addManagementActionsToList(ilAdvancedSelectionListGUI $action_list)
setManagementEnabled(bool $management_enabled)
__construct(object $a_parent_obj, string $a_parent_cmd='')
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
global $DIC
Definition: feed.php:28
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc