ILIAS  release_8 Revision v8.24
class.ilAuthLoginPageEditorSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 public const MODE__UNDEFINED = 0;
29 public const MODE_RTE = 1;
30 public const MODE_IPE = 2;
31
32 private array $languages = [];
33
36
37 private int $mode = 0;
38
40
41 public function __construct()
42 {
43 global $DIC;
44 $this->lng = $DIC->language();
45
46 $this->storage = new ilSetting('login_editor');
47 $this->read();
48 }
49
55 {
56 if (self::$instance) {
57 return self::$instance;
58 }
59 return self::$instance = new ilAuthLoginPageEditorSettings();
60 }
61
65 protected function getStorage(): ilSetting
66 {
67 return $this->storage;
68 }
69
70 public function setMode(int $a_mode): void
71 {
72 //TODO check for proper mode
73 $this->mode = $a_mode;
74 }
75
76 public function getMode(): int
77 {
78 return $this->mode;
79 }
80
86 public function getIliasEditorLanguage(string $a_langkey): string
87 {
88 if ($this->mode !== self::MODE_IPE) {
89 return '';
90 }
91 if ($this->isIliasEditorEnabled($a_langkey)) {
92 return $a_langkey;
93 }
94 if ($this->isIliasEditorEnabled($this->lng->getDefaultLanguage())) {
95 return $this->lng->getDefaultLanguage();
96 }
97 return '';
98 }
99
103 public function enableIliasEditor(string $a_langkey, bool $a_status): void
104 {
105 $this->languages[$a_langkey] = $a_status;
106 }
107
111 public function isIliasEditorEnabled(string $a_langkey): bool
112 {
113 return $this->languages[$a_langkey] ?? false;
114 }
115
119 public function update(): void
120 {
121 $this->getStorage()->set('mode', (string) $this->getMode());
122
123 foreach ($this->languages as $lngkey => $stat) {
124 $this->storage->set($lngkey, (string) $stat);
125 }
126 }
127
131 public function read(): void
132 {
133 $this->setMode((int) $this->getStorage()->get('mode', (string) self::MODE_RTE));
134
135 // Language settings
136 $this->languages = [];
137 foreach ($this->lng->getInstalledLanguages() as $lngkey) {
138 $this->enableIliasEditor($lngkey, (bool) $this->getStorage()->get($lngkey, ""));
139 }
140 }
141}
enableIliasEditor(string $a_langkey, bool $a_status)
Enable editor for language.
isIliasEditorEnabled(string $a_langkey)
Check if ilias editor is enabled for a language.
static ilAuthLoginPageEditorSettings $instance
getIliasEditorLanguage(string $a_langkey)
Get ilias editor language.
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28