ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 protected \ILIAS\DI\UIServices $ui;
30 protected array $modals = [];
31
32 public function __construct(object $a_parent_obj, string $a_parent_cmd = '')
33 {
34 global $DIC;
35 parent::__construct($a_parent_obj, $a_parent_cmd);
36 $this->ui = $DIC->ui();
37 $this->getStyles();
38
39 $this->setLimit(9999);
40 $this->setTitle($this->lng->txt('manage_system_styles'));
41 $this->addColumn($this->lng->txt(''));
42 $this->addColumn($this->lng->txt('style_name'), 'style_name');
43 $this->addColumn($this->lng->txt('skin_name'), 'skin_name');
44 $this->addColumn($this->lng->txt('sty_substyle_of'));
45 $this->addColumn($this->lng->txt('scope'));
46 $this->addColumn($this->lng->txt('default'));
47 $this->addColumn($this->lng->txt('active'));
48 $this->addColumn($this->lng->txt('users'), 'users');
49 $this->addColumn($this->lng->txt('version'));
50 $this->setRowTemplate('tpl.sys_styles_row.html', 'components/ILIAS/Style/System');
51 $this->setEnableHeader(true);
52 }
53
58 public function addActions($management_enabled, bool $read_documentation = true)
59 {
60 $this->setManagementEnabled($management_enabled);
61 $this->setReadDocumentation($read_documentation);
62
63 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
64 $this->addCommandButton('saveStyleSettings', $this->lng->txt('save'));
65 $this->setRowTemplate('tpl.sys_styles_row_with_actions.html', 'components/ILIAS/Style/System');
66
67 if ($read_documentation || $management_enabled) {
68 $this->setWithActions(true);
69
70 $this->addColumn($this->lng->txt('actions'));
71 }
72 }
73
77 public function getStyles()
78 {
79 // get all user assigned styles
80 $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
81
82 // output 'other' row for all users, that are not assigned to
83 // any existing style
84 $users_missing_styles = 0;
85 foreach ($all_user_styles as $skin_style_id) {
86 $style_arr = explode(':', $skin_style_id);
87 if (!ilStyleDefinition::styleExists($style_arr[1])) {
88 $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]);
89 }
90 }
92 if ($users_missing_styles > 0) {
93 $all_styles['other'] =
94 [
95 'title' => $this->lng->txt('other'),
96 'id' => 'other',
97 'template_id' => '',
98 'skin_id' => 'other',
99 'style_id' => 'other',
100 'skin_name' => 'other',
101 'style_name' => 'other',
102 'users' => $users_missing_styles,
103 'version' => '-',
104 'substyle_of' => ''
105 ];
106 }
107
108 $this->setData($all_styles);
109 }
110
115 protected function fillRow(array $a_set): void
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 = $this->ui->factory()->listing()->unordered($categories);
181 $this->tpl->setVariable(
182 'CATEGORIES',
183 $this->lng->txt('local') . $this->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()) {
193 $action_items = [];
194
197 if ($this->isManagementEnabled()) {
198 $this->ctrl->setParameterByClass(ilSystemStyleConfigGUI::class, 'skin_id', $a_set['skin_id']);
199 $this->ctrl->setParameterByClass(ilSystemStyleConfigGUI::class, 'style_id', $a_set['style_id']);
200
201 $this->ctrl->setParameterByClass(ilSystemStyleOverviewGUI::class, 'skin_id', $a_set['skin_id']);
202 $this->ctrl->setParameterByClass(ilSystemStyleOverviewGUI::class, 'style_id', $a_set['style_id']);
203
204 if ($is_substyle) {
205 $action_items[] = $this->ui->factory()->link()->standard(
206 $this->lng->txt('sty_cat_assignments'),
207 $this->ctrl->getLinkTargetByClass('ilsystemstyleconfiggui', 'assignStyle')
208 );
209 } else {
210 if ($a_set['skin_id'] != 'default' && $a_set['skin_id'] != 'other') {
211 $action_items[] = $this->ui->factory()->link()->standard(
212 $this->lng->txt('export'),
213 $this->ctrl->getLinkTargetByClass(ilSystemStyleOverviewGUI::class, 'export')
214 );
215 }
216
217 $this->ctrl->setParameterByClass(ilSystemStyleOverviewGUI::class, 'old_skin_id', $a_set['skin_id']);
218 $this->ctrl->setParameterByClass(ilSystemStyleOverviewGUI::class, 'old_style_id', $a_set['style_id']);
219
220 $assignment_modal = $this->parent_obj->getAssignmentCreationModal($a_set['style_name']);
221
222 if ($assignment_modal) {
223 $this->modals[] = $assignment_modal;
224
225 $action_items[] = $this->ui->factory()->button()->shy(
226 $this->lng->txt('sty_change_user_assignment'),
227 "#"
228 )->withOnClick($assignment_modal->getShowSignal());
229 }
230 }
231 }
232
233 $this->tpl->setCurrentBlock('actions');
234 $action_dropdown = $this->ui->factory()->dropdown()->standard($action_items)->withLabel(
235 $this->lng->txt('actions')
236 );
237 $this->tpl->setVariable('ACTIONS', $this->ui->renderer()->render($action_dropdown));
238 $this->tpl->parseCurrentBlock();
239 }
240 }
241
242 public function getModalsHtml(): string
243 {
244 return $this->ui->renderer()->render($this->modals);
245 }
246
247 public function isWithActions(): bool
248 {
249 return $this->with_actions;
250 }
251
252 public function setWithActions(bool $with_actions): void
253 {
255 }
256
257 public function isManagementEnabled(): bool
258 {
260 }
261
263 {
264 $this->management_enabled = $management_enabled;
265 }
266
267 public function isReadDocumentation(): bool
268 {
270 }
271
273 {
274 $this->read_documentation = $read_documentation;
275 }
276}
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)
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)
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="")
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26