ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilAuthLoginPageEditorSettings.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
12 const MODE__UNDEFINED = 0;
13 const MODE_RTE = 1;
14 const MODE_IPE = 2;
15
16 private $languages = array();
17
18
19 private static $instance = null;
20 private $storage = null;
21
22 private $mode = 0;
23
24
25 public function __construct()
26 {
27 include_once './Services/Administration/classes/class.ilSetting.php';
28 $this->storage = new ilSetting('login_editor');
29 $this->read();
30 }
31
36 public static function getInstance()
37 {
38 if (self::$instance) {
39 return self::$instance;
40 }
41 return self::$instance = new ilAuthLoginPageEditorSettings();
42 }
43
47 protected function getStorage()
48 {
49 return $this->storage;
50 }
51
52 public function setMode($a_mode)
53 {
54 $this->mode = $a_mode;
55 }
56
57 public function getMode()
58 {
59 return $this->mode;
60 }
61
68 public function getIliasEditorLanguage($a_langkey)
69 {
70 global $lng;
71
72 if ($this->getMode() != self::MODE_IPE) {
73 return '';
74 }
75 if ($this->isIliasEditorEnabled($a_langkey)) {
76 return $a_langkey;
77 }
78 if ($this->isIliasEditorEnabled($lng->getDefaultLanguage())) {
79 return $lng->getDefaultLanguage();
80 }
81 return '';
82 }
83
87 public function enableIliasEditor($a_langkey, $a_status)
88 {
89 $this->languages[$a_langkey] = (bool) $a_status;
90 }
91
96 public function isIliasEditorEnabled($a_langkey)
97 {
98 if (isset($this->languages[$a_langkey])) {
99 return (bool) $this->languages[$a_langkey];
100 }
101 return false;
102 }
103
107 public function update()
108 {
109 $this->getStorage()->set('mode', $this->getMode());
110
111 foreach ((array) $this->languages as $lngkey => $stat) {
112 $this->storage->set($lngkey, (int) $stat);
113 }
114 }
115
119 public function read()
120 {
121 global $lng;
122
123 $this->setMode($this->getStorage()->get('mode', self::MODE_RTE));
124
125 // Language settings
126 $this->languages = array();
127 foreach ($lng->getInstalledLanguages() as $num => $lngkey) {
128 $this->enableIliasEditor($lngkey, $this->getStorage()->get($lngkey, 0));
129 }
130 }
131}
An exception for terminatinating execution or to throw for unit testing.
getIliasEditorLanguage($a_langkey)
Get ilias editor language @global ilLanguage $lng.
enableIliasEditor($a_langkey, $a_status)
Enable editor for language.
isIliasEditorEnabled($a_langkey)
Check if ilias editor is enabled for a language.
ILIAS Setting Class.
global $lng
Definition: privfeed.php:17