ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSystemStyleSettings.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4
20{
28 static function _lookupActivatedStyle($a_skin, $a_style)
29 {
30 global $ilDB;
31
32 $q = "SELECT count(*) cnt FROM settings_deactivated_s".
33 " WHERE skin = ".$ilDB->quote($a_skin, "text").
34 " AND style = ".$ilDB->quote($a_style, "text")." ";
35
36 $cnt_set = $ilDB->query($q);
37 $cnt_rec = $ilDB->fetchAssoc($cnt_set);
38
39 if ($cnt_rec["cnt"] > 0)
40 {
41 return false;
42 }
43 else
44 {
45 return true;
46 }
47 }
48
55 static function _deactivateStyle($a_skin, $a_style)
56 {
57 global $ilDB;
58
60 $q = "INSERT into settings_deactivated_s".
61 " (skin, style) VALUES ".
62 " (".$ilDB->quote($a_skin, "text").",".
63 " ".$ilDB->quote($a_style, "text").")";
64
65 $ilDB->manipulate($q);
66 }
67
74 static function _activateStyle($a_skin, $a_style)
75 {
76 global $ilDB;
77
78 $q = "DELETE FROM settings_deactivated_s".
79 " WHERE skin = ".$ilDB->quote($a_skin, "text").
80 " AND style = ".$ilDB->quote($a_style, "text");
81
82 $ilDB->manipulate($q);
83 }
84
93 static function getSystemStyleCategoryAssignments($a_skin_id, $a_style_id)
94 {
95 global $ilDB;
96
97 $assignments = [];
98 $set = $ilDB->query("SELECT substyle, category_ref_id FROM syst_style_cat ".
99 " WHERE skin_id = ".$ilDB->quote($a_skin_id, "text").
100 " AND style_id = ".$ilDB->quote($a_style_id, "text")
101 );
102 while (($rec = $ilDB->fetchAssoc($set)))
103 {
104 $assignments[] = [
105 "substyle" => $rec["substyle"],
106 "ref_id" => $rec["category_ref_id"]
107 ];
108 }
109 return $assignments;
110 }
111
121 static function getSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_sub_style_id)
122 {
123 global $ilDB;
124
125 $assignmnts = [];
126
127 $set = $ilDB->query("SELECT substyle, category_ref_id FROM syst_style_cat ".
128 " WHERE skin_id = ".$ilDB->quote($a_skin_id, "text").
129 " AND substyle = ".$ilDB->quote($a_sub_style_id, "text").
130 " AND style_id = ".$ilDB->quote($a_style_id, "text")
131 );
132 while (($rec = $ilDB->fetchAssoc($set)))
133 {
134 $assignmnts[] = [
135 "substyle" => $rec["substyle"],
136 "ref_id" => $rec["category_ref_id"]
137 ];
138 }
139 return $assignmnts;
140 }
141
151 static function writeSystemStyleCategoryAssignment($a_skin_id, $a_style_id,
152 $a_substyle, $a_ref_id)
153 {
154 global $ilDB;
155
156 $assignments = self::getSubStyleCategoryAssignments($a_skin_id, $a_style_id,$a_substyle);
157
158 foreach($assignments as $assignment){
159 if($assignment["ref_id"] == $a_ref_id){
161 }
162 }
163 $ilDB->manipulate("INSERT INTO syst_style_cat ".
164 "(skin_id, style_id, substyle, category_ref_id) VALUES (".
165 $ilDB->quote($a_skin_id, "text").",".
166 $ilDB->quote($a_style_id, "text").",".
167 $ilDB->quote($a_substyle, "text").",".
168 $ilDB->quote($a_ref_id, "integer").
169 ")");
170 }
171
181 static function deleteSystemStyleCategoryAssignment($a_skin_id, $a_style_id,
182 $a_substyle, $a_ref_id)
183 {
184 global $ilDB;
185
186 $ilDB->manipulate("DELETE FROM syst_style_cat WHERE ".
187 " skin_id = ".$ilDB->quote($a_skin_id, "text").
188 " AND style_id = ".$ilDB->quote($a_style_id, "text").
189 " AND substyle = ".$ilDB->quote($a_substyle, "text").
190 " AND category_ref_id = ".$ilDB->quote($a_ref_id, "integer"));
191 }
192
200 static function deleteSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_substyle)
201 {
202 global $ilDB;
203
204 $ilDB->manipulate("DELETE FROM syst_style_cat WHERE ".
205 " skin_id = ".$ilDB->quote($a_skin_id, "text").
206 " AND style_id = ".$ilDB->quote($a_style_id, "text").
207 " AND substyle = ".$ilDB->quote($a_substyle, "text"));
208 }
209
216 static function setCurrentUserPrefStyle($skin_id, $style_id){
217 global $DIC;
218
219 $DIC->user()->setPref("skin",$skin_id);
220 $DIC->user()->setPref("style",$style_id);
221 $DIC->user()->update();
222 }
223
229 static function getCurrentUserPrefSkin(){
230 global $DIC;
231
232 return $DIC->user()->getPref("skin");
233 }
234
240 static function getCurrentUserPrefStyle(){
241 global $DIC;
242
243 return $DIC->user()->getPref("style");
244 }
245
252 static function setCurrentDefaultStyle($skin_id, $style_id){
253 global $DIC;
254
255 $DIC['ilias']->ini->setVariable("layout","skin", $skin_id);
256 $DIC['ilias']->ini->setVariable("layout","style",$style_id);
257 $DIC['ilias']->ini->write();
258 self::_activateStyle($skin_id, $style_id);
259
260 }
261
262 static function resetDefaultToDelos(){
263 $system_style_conf = new ilSystemStyleConfig();
264
265 self::setCurrentDefaultStyle($system_style_conf->getDefaultSkinId(),$system_style_conf->getDefaultSkinId());
266 }
267
273 static function getCurrentDefaultSkin(){
274 global $DIC;
275 $skin_id = $DIC['ilias']->ini->readVariable("layout","skin");
276
277 if(!ilStyleDefinition::skinExists($skin_id)){
279 $skin_id = $DIC['ilias']->ini->readVariable("layout","skin");
280 }
281 return $skin_id;
282 }
283
288 static function getCurrentDefaultStyle(){
289 global $DIC;
290 $skin_id = $DIC['ilias']->ini->readVariable("layout","skin");
291 $style_id = $DIC['ilias']->ini->readVariable("layout","style");
292
293 if(!ilStyleDefinition::styleExistsForSkinId($skin_id,$style_id)){
295 $style_id = $DIC['ilias']->ini->readVariable("layout","style");
296 }
297 return $style_id;
298 }
299}
An exception for terminatinating execution or to throw for unit testing.
static skinExists($skin_id, ilSystemStyleConfig $system_style_config=null)
Check whether a skin exists.
static styleExistsForSkinId($skin_id, $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 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 getCurrentUserPrefSkin()
Gets a users preferred skin by using the user object.
static setCurrentDefaultStyle($skin_id, $style_id)
Sets the default style of the system.
static _activateStyle($a_skin, $a_style)
activate system style
static writeSystemStyleCategoryAssignment($a_skin_id, $a_style_id, $a_substyle, $a_ref_id)
Sets a substyle category assignment.
static _deactivateStyle($a_skin, $a_style)
deactivate system style
static _lookupActivatedStyle($a_skin, $a_style)
lookup if a style is activated
static getCurrentDefaultSkin()
Gets default Skin of the System.
static setCurrentUserPrefStyle($skin_id, $style_id)
Sets a users preferred system skin/style by using the user object.
static deleteSystemStyleCategoryAssignment($a_skin_id, $a_style_id, $a_substyle, $a_ref_id)
Deletes all sub style category assignment of a system style.
static getSystemStyleCategoryAssignments($a_skin_id, $a_style_id)
Get all system sub styles category assignments.
static deleteSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_substyle)
Delets a sub styles category assignment.
static getCurrentUserPrefStyle()
Gets a users preferred style by using the user object.
global $ilDB
global $DIC