ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAuthPageEditorSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
26 private static array $instances = [];
27
31 private array $languages = [];
34
35
37 {
38 global $DIC;
39
40 $this->lng = $DIC->language();
41 $this->storage = new ilSetting($context->value);
42
43 $this->read();
44 }
45
46 public static function getInstance(AuthPageEditorContext $context): self
47 {
48 return self::$instances[$context->value] ?? (self::$instances[$context->value] = new self($context));
49 }
50
51 private function getStorage(): ilSetting
52 {
53 return $this->storage;
54 }
55
56 public function getIliasEditorLanguage(string $a_langkey): string
57 {
58 if ($this->isIliasEditorEnabled($a_langkey)) {
59 return $a_langkey;
60 }
61
62 if ($this->isIliasEditorEnabled($this->lng->getDefaultLanguage())) {
63 return $this->lng->getDefaultLanguage();
64 }
65
66 return '';
67 }
68
69 public function enableIliasEditor(string $a_langkey, bool $a_status): void
70 {
71 $this->languages[$a_langkey] = $a_status;
72 }
73
74 public function isIliasEditorEnabled(string $a_langkey): bool
75 {
76 return $this->languages[$a_langkey] ?? false;
77 }
78
79 public function update(): void
80 {
81 foreach ($this->languages as $lngkey => $stat) {
82 $this->storage->set($lngkey, (string) $stat);
83 }
84 }
85
86 public function read(): void
87 {
88 $this->languages = [];
89 foreach ($this->lng->getInstalledLanguages() as $lngkey) {
90 $this->enableIliasEditor($lngkey, (bool) $this->getStorage()->get($lngkey, ''));
91 }
92 }
93}
enableIliasEditor(string $a_langkey, bool $a_status)
__construct(AuthPageEditorContext $context)
static getInstance(AuthPageEditorContext $context)
language handling
ILIAS Setting Class.
global $DIC
Definition: shib_login.php:26
$context
Definition: webdav.php:31