ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
71 
72  $lng = $DIC['lng'];
73 
74  if ($this->getMode() != self::MODE_IPE) {
75  return '';
76  }
77  if ($this->isIliasEditorEnabled($a_langkey)) {
78  return $a_langkey;
79  }
80  if ($this->isIliasEditorEnabled($lng->getDefaultLanguage())) {
81  return $lng->getDefaultLanguage();
82  }
83  return '';
84  }
85 
89  public function enableIliasEditor($a_langkey, $a_status)
90  {
91  $this->languages[$a_langkey] = (bool) $a_status;
92  }
93 
98  public function isIliasEditorEnabled($a_langkey)
99  {
100  if (isset($this->languages[$a_langkey])) {
101  return (bool) $this->languages[$a_langkey];
102  }
103  return false;
104  }
105 
109  public function update()
110  {
111  $this->getStorage()->set('mode', $this->getMode());
112 
113  foreach ((array) $this->languages as $lngkey => $stat) {
114  $this->storage->set($lngkey, (int) $stat);
115  }
116  }
117 
121  public function read()
122  {
123  global $DIC;
124 
125  $lng = $DIC['lng'];
126 
127  $this->setMode($this->getStorage()->get('mode', self::MODE_RTE));
128 
129  // Language settings
130  $this->languages = array();
131  foreach ($lng->getInstalledLanguages() as $num => $lngkey) {
132  $this->enableIliasEditor($lngkey, $this->getStorage()->get($lngkey, 0));
133  }
134  }
135 }
isIliasEditorEnabled($a_langkey)
Check if ilias editor is enabled for a language.
global $DIC
Definition: saml.php:7
$lng
getIliasEditorLanguage($a_langkey)
Get ilias editor language ilLanguage $lng.
enableIliasEditor($a_langkey, $a_status)
Enable editor for language.
static getInstance()
Get singelton instance.