ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
◀ ilDoc Overview
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
79
80
protected
function
readFromDB()
81
{
82
global
$ilDB
;
86
$q =
'SELECT module, lang_array FROM lng_modules WHERE lang_key = %s'
;
87
$res
= $ilDB->queryF($q,
array
(
'text'
),
array
( $this->
getLanguageKey
() ));
88
$translations
=
array
();
89
while
($set = $ilDB->fetchObject(
$res
)) {
90
$lang_array = unserialize($set->lang_array);
91
if
(is_array($lang_array)) {
92
$translations
[$set->module] = $lang_array;
93
}
94
}
95
$this->
setTranslations
(
$translations
);
96
}
97
98
104
public
static
function
getInstance
(
$key
)
105
{
106
if
(!isset(self::$instances[
$key
])) {
107
self::$instances[
$key
] =
new
self
(
$key
);
108
}
109
110
return
self::$instances[
$key
];
111
}
112
113
114
public
function
flush
()
115
{
116
if
($this->global_cache->isActive()) {
117
$this->global_cache->flush();
118
}
119
$this->readFromDB();
120
$this->
writeToCache
();
121
}
122
123
127
public
function
setLanguageKey
(
$language_key
)
128
{
129
$this->language_key =
$language_key
;
130
}
131
132
136
public
function
getLanguageKey
()
137
{
138
return
$this->language_key
;
139
}
140
141
145
public
function
setLoaded
(
$loaded
)
146
{
147
$this->loaded =
$loaded
;
148
}
149
150
154
public
function
getLoaded
()
155
{
156
return
$this->loaded
;
157
}
158
159
163
public
function
setTranslations
(
$translations
)
164
{
165
$this->translations =
$translations
;
166
}
167
168
172
public
function
getTranslations
()
173
{
174
return
$this->translations
;
175
}
176
}
ilCachedLanguage\$language_key
$language_key
Definition:
class.ilCachedLanguage.php:20
ilCachedLanguage\getTranslations
getTranslations()
Definition:
class.ilCachedLanguage.php:172
ilGlobalCache\getInstance
static getInstance($component)
Definition:
class.ilGlobalCache.php:117
ilCachedLanguage\$loaded
$loaded
Definition:
class.ilCachedLanguage.php:16
ilCachedLanguage\setLoaded
setLoaded($loaded)
Definition:
class.ilCachedLanguage.php:145
ilCachedLanguage\writeToCache
writeToCache()
Definition:
class.ilCachedLanguage.php:72
ilCachedLanguage\flush
flush()
Definition:
class.ilCachedLanguage.php:114
ilCachedLanguage\isActive
isActive()
Definition:
class.ilCachedLanguage.php:54
ilGlobalCache\COMP_CLNG
const COMP_CLNG
Definition:
class.ilGlobalCache.php:23
ilCachedLanguage\setTranslations
setTranslations($translations)
Definition:
class.ilCachedLanguage.php:163
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:104
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
array
Create styles array
The data for the language used.
Definition:
40duplicateStyle.php:19
ilCachedLanguage\$translations
$translations
Definition:
class.ilCachedLanguage.php:24
ilCachedLanguage\setLanguageKey
setLanguageKey($language_key)
Definition:
class.ilCachedLanguage.php:127
$ilDB
global $ilDB
Definition:
storeScorm2004.php:16
ilCachedLanguage\readFromCache
readFromCache()
Definition:
class.ilCachedLanguage.php:60
ilCachedLanguage\getLanguageKey
getLanguageKey()
Definition:
class.ilCachedLanguage.php:136
ilCachedLanguage
Class ilCachedLanguage.
Definition:
class.ilCachedLanguage.php:10
$key
$key
Definition:
croninfo.php:18
ilCachedLanguage\getLoaded
getLoaded()
Definition:
class.ilCachedLanguage.php:154
Services
Language
classes
class.ilCachedLanguage.php
Generated on Sat Jan 18 2025 19:01:33 for ILIAS by
1.8.13 (using
Doxyfile
)