ILIAS
release_7 Revision v7.30-3-g800a261c036
◀ ilDoc Overview
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
$
_
a
b
c
d
e
f
g
h
i
j
l
m
p
r
s
t
w
+
Functions
_
a
b
c
f
g
h
i
r
s
t
w
+
Variables
$
c
d
e
f
g
h
j
l
m
p
s
t
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Files
File List
+
Globals
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
+
Variables
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Modules
Pages
class.ilCachedLanguage.php
Go to the documentation of this file.
1
<?php
2
require_once(
'./Services/GlobalCache/classes/class.ilGlobalCache.php'
);
3
10
class
ilCachedLanguage
11
{
12
protected
$global_cache
;
16
protected
$loaded
=
false
;
20
protected
$language_key
=
'en'
;
24
protected
$translations
= array();
28
protected
static
$instances
= array();
29
30
34
protected
function
__construct
(
$language_key
)
35
{
36
$this->
setLanguageKey
(
$language_key
);
41
$this->global_cache =
ilGlobalCache::getInstance
(
ilGlobalCache::COMP_CLNG
);
42
$this->
readFromCache
();
43
if
(!$this->
getLoaded
()) {
44
$this->
readFromDB
();
45
$this->
writeToCache
();
46
$this->
setLoaded
(
true
);
47
}
48
}
49
50
54
public
function
isActive
()
55
{
56
return
$this->global_cache->isActive();
57
}
58
59
60
protected
function
readFromCache
()
61
{
62
if
($this->global_cache->isActive()) {
63
$translations
= $this->global_cache->get(
'translations_'
. $this->
getLanguageKey
());
64
if
(is_array(
$translations
)) {
65
$this->
setTranslations
(
$translations
);
66
$this->
setLoaded
(
true
);
67
}
68
}
69
}
70
71
72
public
function
writeToCache
()
73
{
74
if
($this->global_cache->isActive()) {
75
$this->global_cache->set(
'translations_'
. $this->
getLanguageKey
(), $this->
getTranslations
());
76
}
77
}
78
85
public
function
deleteInCache
() {
86
if
($this->global_cache->isActive()) {
87
$this->global_cache->delete(
'translations_'
. $this->
getLanguageKey
());
88
$this->
setLoaded
(
false
);
89
}
90
}
91
92
protected
function
readFromDB
()
93
{
94
global
$DIC
;
95
$ilDB
= $DIC->database();
96
97
$q =
'SELECT module, lang_array FROM lng_modules WHERE lang_key = %s'
;
98
$res
=
$ilDB
->queryF($q, array(
'text'
), array( $this->
getLanguageKey
() ));
99
$translations
= array();
100
while
($set =
$ilDB
->fetchObject(
$res
)) {
101
$lang_array = unserialize($set->lang_array);
102
if
(is_array($lang_array)) {
103
$translations
[$set->module] = $lang_array;
104
}
105
}
106
$this->
setTranslations
(
$translations
);
107
}
108
109
115
public
static
function
getInstance
($key)
116
{
117
if
(!isset(self::$instances[$key])) {
118
self::$instances[$key] =
new
self
($key);
119
}
120
121
return
self::$instances[$key];
122
}
123
124
125
public
function
flush
()
126
{
127
if
($this->global_cache->isActive()) {
128
$this->global_cache->flush();
129
}
130
$this->
readFromDB
();
131
$this->
writeToCache
();
132
}
133
134
138
public
function
setLanguageKey
(
$language_key
)
139
{
140
$this->language_key =
$language_key
;
141
}
142
143
147
public
function
getLanguageKey
()
148
{
149
return
$this->language_key
;
150
}
151
152
156
public
function
setLoaded
(
$loaded
)
157
{
158
$this->loaded =
$loaded
;
159
}
160
161
165
public
function
getLoaded
()
166
{
167
return
$this->loaded
;
168
}
169
170
174
public
function
setTranslations
(
$translations
)
175
{
176
$this->translations =
$translations
;
177
}
178
179
183
public
function
getTranslations
()
184
{
185
return
$this->translations
;
186
}
187
}
ilCachedLanguage\$language_key
$language_key
Definition:
class.ilCachedLanguage.php:20
ilCachedLanguage\getTranslations
getTranslations()
Definition:
class.ilCachedLanguage.php:183
ilGlobalCache\getInstance
static getInstance($component)
Definition:
class.ilGlobalCache.php:115
ilCachedLanguage\$loaded
$loaded
Definition:
class.ilCachedLanguage.php:16
ilCachedLanguage\setLoaded
setLoaded($loaded)
Definition:
class.ilCachedLanguage.php:156
ilCachedLanguage\writeToCache
writeToCache()
Definition:
class.ilCachedLanguage.php:72
ilCachedLanguage\flush
flush()
Definition:
class.ilCachedLanguage.php:125
ilCachedLanguage\isActive
isActive()
Definition:
class.ilCachedLanguage.php:54
ilGlobalCache\COMP_CLNG
const COMP_CLNG
Definition:
class.ilGlobalCache.php:22
ilCachedLanguage\setTranslations
setTranslations($translations)
Definition:
class.ilCachedLanguage.php:174
ilCachedLanguage\$global_cache
$global_cache
Definition:
class.ilCachedLanguage.php:12
ilCachedLanguage\$instances
static $instances
Definition:
class.ilCachedLanguage.php:28
ilCachedLanguage\getInstance
static getInstance($key)
Definition:
class.ilCachedLanguage.php:115
ilCachedLanguage\deleteInCache
deleteInCache()
Delete the cache entry for this language without flushing the whole global cache Using this function ...
Definition:
class.ilCachedLanguage.php:85
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
$DIC
global $DIC
Definition:
goto.php:24
ilCachedLanguage\$translations
$translations
Definition:
class.ilCachedLanguage.php:24
ilCachedLanguage\readFromDB
readFromDB()
Definition:
class.ilCachedLanguage.php:92
ilCachedLanguage\setLanguageKey
setLanguageKey($language_key)
Definition:
class.ilCachedLanguage.php:138
ILIAS\GlobalScreen\Provider\__construct
__construct(Container $dic, ilPlugin $plugin)
Definition:
PluginProviderHelper.php:40
$ilDB
global $ilDB
Definition:
storeScorm2004.php:16
ilCachedLanguage\readFromCache
readFromCache()
Definition:
class.ilCachedLanguage.php:60
ilCachedLanguage\getLanguageKey
getLanguageKey()
Definition:
class.ilCachedLanguage.php:147
ilCachedLanguage
Class ilCachedLanguage.
Definition:
class.ilCachedLanguage.php:10
ilCachedLanguage\getLoaded
getLoaded()
Definition:
class.ilCachedLanguage.php:165
Services
Language
classes
class.ilCachedLanguage.php
Generated on Sun Apr 6 2025 21:01:32 for ILIAS by
1.8.13 (using
Doxyfile
)