ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  {
40  return self::$instance;
41  }
42  return self::$instance = new ilAuthLoginPageEditorSettings();
43  }
44 
48  protected function getStorage()
49  {
50  return $this->storage;
51  }
52 
53  public function setMode($a_mode)
54  {
55  $this->mode = $a_mode;
56  }
57 
58  public function getMode()
59  {
60  return $this->mode;
61  }
62 
69  public function getIliasEditorLanguage($a_langkey)
70  {
71  global $lng;
72 
73  if($this->getMode() != self::MODE_IPE)
74  {
75  return '';
76  }
77  if($this->isIliasEditorEnabled($a_langkey))
78  {
79  return $a_langkey;
80  }
81  if($this->isIliasEditorEnabled($lng->getDefaultLanguage()))
82  {
83  return $lng->getDefaultLanguage();
84  }
85  return '';
86  }
87 
91  public function enableIliasEditor($a_langkey,$a_status)
92  {
93  $this->languages[$a_langkey] = (bool) $a_status;
94  }
95 
100  public function isIliasEditorEnabled($a_langkey)
101  {
102  if(isset($this->languages[$a_langkey]))
103  {
104  return (bool) $this->languages[$a_langkey];
105  }
106  return false;
107  }
108 
112  public function update()
113  {
114  $this->getStorage()->set('mode', $this->getMode());
115 
116  foreach((array) $this->languages as $lngkey => $stat)
117  {
118  $this->storage->set($lngkey,(int) $stat);
119  }
120  }
121 
125  public function read()
126  {
127  global $lng;
128 
129  $this->setMode($this->getStorage()->get('mode', self::MODE_RTE));
130 
131  // Language settings
132  $this->languages = array();
133  foreach($lng->getInstalledLanguages() as $num => $lngkey)
134  {
135  $this->enableIliasEditor($lngkey,$this->getStorage()->get($lngkey,0));
136  }
137  }
138 }
139 ?>