ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSystemStyleSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
32 public static function _lookupActivatedStyle(string $a_skin, string $a_style): bool
33 {
34 global $DIC;
35
36 $q = 'SELECT count(*) cnt FROM settings_deactivated_s' .
37 ' WHERE skin = ' . $DIC->database()->quote($a_skin, 'text') .
38 ' AND style = ' . $DIC->database()->quote($a_style, 'text') . ' ';
39
40 $cnt_set = $DIC->database()->query($q);
41 $cnt_rec = $DIC->database()->fetchAssoc($cnt_set);
42
43 if ($cnt_rec['cnt'] > 0) {
44 return false;
45 } else {
46 return true;
47 }
48 }
49
53 public static function _deactivateStyle(string $a_skin, string $a_style): void
54 {
55 global $DIC;
56
58 $q = 'INSERT into settings_deactivated_s' .
59 ' (skin, style) VALUES ' .
60 ' (' . $DIC->database()->quote($a_skin, 'text') . ',' .
61 ' ' . $DIC->database()->quote($a_style, 'text') . ')';
62
63 $DIC->database()->manipulate($q);
64 }
65
69 public static function _activateStyle(string $a_skin, string $a_style): void
70 {
71 global $DIC;
72
73 $q = 'DELETE FROM settings_deactivated_s' .
74 ' WHERE skin = ' . $DIC->database()->quote($a_skin, 'text') .
75 ' AND style = ' . $DIC->database()->quote($a_style, 'text');
76
77 $DIC->database()->manipulate($q);
78 }
79
85 public static function getSystemStyleCategoryAssignments(string $a_skin_id, string $a_style_id): array
86 {
87 global $DIC;
88
89 $assignments = [];
90 $set = $DIC->database()->query(
91 'SELECT substyle, category_ref_id FROM syst_style_cat ' .
92 ' WHERE skin_id = ' . $DIC->database()->quote($a_skin_id, 'text') .
93 ' AND style_id = ' . $DIC->database()->quote($a_style_id, 'text')
94 );
95 while (($rec = $DIC->database()->fetchAssoc($set))) {
96 $assignments[] = [
97 'substyle' => $rec['substyle'],
98 'ref_id' => $rec['category_ref_id']
99 ];
100 }
101 return $assignments;
102 }
103
108 public static function getSubStyleCategoryAssignments(
109 string $a_skin_id,
110 string $a_style_id,
111 string $a_sub_style_id
112 ): array {
113 global $DIC;
114
115 $assignmnts = [];
116
117 $set = $DIC->database()->query(
118 'SELECT substyle, category_ref_id FROM syst_style_cat ' .
119 ' WHERE skin_id = ' . $DIC->database()->quote($a_skin_id, 'text') .
120 ' AND substyle = ' . $DIC->database()->quote($a_sub_style_id, 'text') .
121 ' AND style_id = ' . $DIC->database()->quote($a_style_id, 'text')
122 );
123 while (($rec = $DIC->database()->fetchAssoc($set))) {
124 $assignmnts[] = [
125 'substyle' => $rec['substyle'],
126 'ref_id' => $rec['category_ref_id']
127 ];
128 }
129 return $assignmnts;
130 }
131
137 string $a_skin_id,
138 string $a_style_id,
139 string $a_substyle,
140 string $a_ref_id
141 ): void {
142 global $DIC;
143
144 $assignments = self::getSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_substyle);
145
146 foreach ($assignments as $assignment) {
147 if ($assignment['ref_id'] == $a_ref_id) {
148 throw new ilSystemStyleException(
150 $a_substyle . ': ' . $a_ref_id
151 );
152 }
153 }
154 $DIC->database()->manipulate('INSERT INTO syst_style_cat ' .
155 '(skin_id, style_id, substyle, category_ref_id) VALUES (' .
156 $DIC->database()->quote($a_skin_id, 'text') . ',' .
157 $DIC->database()->quote($a_style_id, 'text') . ',' .
158 $DIC->database()->quote($a_substyle, 'text') . ',' .
159 $DIC->database()->quote($a_ref_id, 'integer') .
160 ')');
161 }
162
168 string $a_skin_id,
169 string $a_style_id,
170 string $a_substyle,
171 string $a_ref_id
172 ): void {
173 global $DIC;
174
175 $DIC->database()->manipulate('DELETE FROM syst_style_cat WHERE ' .
176 ' skin_id = ' . $DIC->database()->quote($a_skin_id, 'text') .
177 ' AND style_id = ' . $DIC->database()->quote($a_style_id, 'text') .
178 ' AND substyle = ' . $DIC->database()->quote($a_substyle, 'text') .
179 ' AND category_ref_id = ' . $DIC->database()->quote($a_ref_id, 'integer'));
180 }
181
185 public static function deleteSubStyleCategoryAssignments(string $a_skin_id, string $a_style_id, string $a_substyle): void
186 {
187 global $DIC;
188
189 $DIC->database()->manipulate('DELETE FROM syst_style_cat WHERE ' .
190 ' skin_id = ' . $DIC->database()->quote($a_skin_id, 'text') .
191 ' AND style_id = ' . $DIC->database()->quote($a_style_id, 'text') .
192 ' AND substyle = ' . $DIC->database()->quote($a_substyle, 'text'));
193 }
194
199 string $old_skin_id,
200 string $old_style_id,
201 string $new_skin_id,
202 string $new_style_id
203 ): void {
204 global $DIC;
205
206 $DIC->database()->manipulate('UPDATE syst_style_cat ' .
207 ' SET skin_id = ' . $DIC->database()->quote($new_skin_id, 'text')
208 . ', style_id = ' . $DIC->database()->quote($new_style_id, 'text') .
209 ' WHERE skin_id = ' . $DIC->database()->quote($old_skin_id, 'text') .
210 ' AND style_id = ' . $DIC->database()->quote($old_style_id, 'text'));
211 }
212
217 string $old_substyle_id,
218 string $new_substyle_id
219 ): void {
220 global $DIC;
221
222 $DIC->database()->manipulate('UPDATE syst_style_cat ' .
223 ' SET substyle = ' . $DIC->database()->quote($new_substyle_id, 'text') .
224 ' WHERE substyle = ' . $DIC->database()->quote($old_substyle_id, 'text'));
225 }
226
230 public static function setCurrentUserPrefStyle(string $skin_id, string $style_id): void
231 {
232 global $DIC;
233
234 $DIC->user()->setPref('skin', $skin_id);
235 $DIC->user()->setPref('style', $style_id);
236 $DIC->user()->update();
237 }
238
242 public static function getCurrentUserPrefSkin(): string
243 {
244 global $DIC;
245
246 return $DIC->user()->getPref('skin');
247 }
248
252 public static function getCurrentUserPrefStyle(): string
253 {
254 global $DIC;
255
256 return $DIC->user()->getPref('style');
257 }
258
262 public static function setCurrentDefaultStyle(string $skin_id, string $style_id): void
263 {
264 global $DIC;
265
266 $DIC->clientIni()->setVariable('layout', 'skin', $skin_id);
267 $DIC->clientIni()->setVariable('layout', 'style', $style_id);
268 $DIC->clientIni()->write();
269 self::_activateStyle($skin_id, $style_id);
270 }
271
272 public static function resetDefaultToDelos(): void
273 {
274 $system_style_conf = new ilSystemStyleConfig();
275
276 self::setCurrentDefaultStyle($system_style_conf->getDefaultSkinId(), $system_style_conf->getDefaultSkinId());
277 }
278
283 public static function getCurrentDefaultSkin(): string
284 {
285 global $DIC;
286
287 $skin_id = $DIC->clientIni()->readVariable('layout', 'skin');
288
289 if (!ilStyleDefinition::skinExists($skin_id)) {
290 self::resetDefaultToDelos();
291 $skin_id = $DIC->clientIni()->readVariable('layout', 'skin');
292 }
293 return $skin_id;
294 }
295
300 public static function getCurrentDefaultStyle(): string
301 {
302 global $DIC;
303 $skin_id = $DIC->clientIni()->readVariable('layout', 'skin');
304 $style_id = $DIC->clientIni()->readVariable('layout', 'style');
305
306 if (!ilStyleDefinition::styleExistsForSkinId($skin_id, $style_id)) {
307 self::resetDefaultToDelos();
308 $style_id = $DIC->clientIni()->readVariable('layout', 'style');
309 }
310 return $style_id;
311 }
312}
static skinExists(string $skin_id, ?ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists.
static styleExistsForSkinId(string $skin_id, string $style_id)
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Class for advanced editing exception handling in ILIAS.
This class acts as Model for all system styles settings related settings such as activated or default...
static _activateStyle(string $a_skin, string $a_style)
activate system style
static getCurrentDefaultStyle()
Gets default style of the system.
static updateSubStyleIdfSubStyleCategoryAssignments(string $old_substyle_id, string $new_substyle_id)
Updates an assignment, e.g.
static getCurrentUserPrefSkin()
Gets a users preferred skin by using the user object.
static _lookupActivatedStyle(string $a_skin, string $a_style)
lookup if a style is activated
static _deactivateStyle(string $a_skin, string $a_style)
deactivate system style
static writeSystemStyleCategoryAssignment(string $a_skin_id, string $a_style_id, string $a_substyle, string $a_ref_id)
Sets a substyle category assignment.
static updateSkinIdAndStyleIDOfSubStyleCategoryAssignments(string $old_skin_id, string $old_style_id, string $new_skin_id, string $new_style_id)
Updates an assignment, e.g.
static deleteSystemStyleCategoryAssignment(string $a_skin_id, string $a_style_id, string $a_substyle, string $a_ref_id)
Deletes all sub style category assignment of a system style.
static getCurrentDefaultSkin()
Gets default Skin of the System.
static setCurrentUserPrefStyle(string $skin_id, string $style_id)
Sets a users preferred system skin/style by using the user object.
static getSystemStyleCategoryAssignments(string $a_skin_id, string $a_style_id)
Get all system sub styles category assignments.
static setCurrentDefaultStyle(string $skin_id, string $style_id)
Sets the default style of the system.
static deleteSubStyleCategoryAssignments(string $a_skin_id, string $a_style_id, string $a_substyle)
Delets a sub styles category assignment.
static getCurrentUserPrefStyle()
Gets a users preferred style by using the user object.
static getSubStyleCategoryAssignments(string $a_skin_id, string $a_style_id, string $a_sub_style_id)
Get all system category assignments of exactly one substyle.
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23