ILIAS
trunk Revision v11.0_alpha-3011-gc6b235a2e85
◀ ilDoc Overview
TranslationsRepositoryDB.php
Go to the documentation of this file.
1
<?php
2
19
namespace
ILIAS\GlobalScreen\UI\Footer\Translation
;
20
21
use
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslationsRepository
;
22
use
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslatableItem
;
23
use
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\Translation
;
24
use
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslationDTO
;
25
use
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\Translations
;
26
use
ILIAS\GlobalScreen\GUI\Pons
;
27
28
class
TranslationsRepositoryDB
implements
TranslationsRepository
29
{
33
private
const
TABLE_NAME
=
'gs_item_translation'
;
34
private
string
$default_language
;
35
36
public
function
__construct
(
37
private
readonly \
ilDBInterface
$db
38
) {
39
$this->default_language = $this->db->queryF(
40
'SELECT value FROM settings WHERE keyword = %s AND module = %s'
,
41
[
'text'
,
'text'
],
42
[
'language'
,
'common'
]
43
)->fetchAssoc()[
'value'
] ??
'en'
;
44
}
45
46
public
function
store
(
Translations
$translations):
Translations
47
{
48
$this->db->manipulateF(
49
'UPDATE '
. self::TABLE_NAME .
' SET status = 0 WHERE id = %s'
,
50
[
'text'
],
51
[$translations->
getId
()]
52
);
53
54
foreach
($translations->
get
() as $translation) {
55
$this->db->manipulateF(
56
'REPLACE INTO '
. self::TABLE_NAME .
' (id, language_code, translation, status) VALUES (%s, %s, %s, 1)'
,
57
[
'text'
,
'text'
,
'text'
],
58
[$translation->getId(), $translation->getLanguageCode(), $translation->getTranslation()]
59
);
60
}
61
62
// remove empty translations
63
$this->db->manipulateF(
64
'DELETE FROM '
. self::TABLE_NAME .
' WHERE id = %s AND translation = ""'
,
65
[
'text'
],
66
[$translations->
getId
()]
67
);
68
69
return
$translations;
70
}
71
72
public
function
get
(
TranslatableItem
$item):
Translations
73
{
74
$r = $this->db->queryF(
75
'SELECT * FROM '
. self::TABLE_NAME .
' WHERE id = %s AND status = 1'
,
76
[
'text'
],
77
[$item->getId()]
78
);
79
$translations = [];
80
81
while
($row = $this->db->fetchAssoc($r)) {
82
if
(empty($row[
'translation'
])) {
83
continue
;
84
}
85
86
$translations[] =
new
TranslationDTO
(
87
$row[
'id'
],
88
$row[
'language_code'
],
89
$row[
'translation'
]
90
);
91
}
92
93
return
new
Translations
($this->default_language, $item, ...$translations);
94
}
95
96
public
function
blank
(
TranslatableItem
$item,
string
$language_code,
string
$translation):
Translation
97
{
98
return
new
TranslationDTO
(
99
$item->
getId
(),
100
$language_code,
101
$translation
102
);
103
}
104
105
public
function
reset
(): void
106
{
107
$this->db->manipulate(
'TRUNCATE TABLE '
. self::TABLE_NAME);
108
}
109
110
public
function
retrieveCurrent
(
Pons
$pons):
TranslatableItem
111
{
112
throw
new \RuntimeException(
'Not implemented'
);
113
}
114
115
}
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslationDTO
Definition:
TranslationDTO.php:26
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\Translations
Definition:
Translations.php:26
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\Translations\getId
getId()
Definition:
Translations.php:42
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\Translations\get
get()
Definition:
Translations.php:47
ILIAS\GlobalScreen\GUI\Pons
Definition:
Pons.php:44
ILIAS\GlobalScreen\UI\Footer\Translation\TranslationsRepositoryDB
Definition:
TranslationsRepositoryDB.php:29
ILIAS\GlobalScreen\UI\Footer\Translation\TranslationsRepositoryDB\blank
blank(TranslatableItem $item, string $language_code, string $translation)
Definition:
TranslationsRepositoryDB.php:96
ILIAS\GlobalScreen\UI\Footer\Translation\TranslationsRepositoryDB\retrieveCurrent
retrieveCurrent(Pons $pons)
Definition:
TranslationsRepositoryDB.php:110
ILIAS\GlobalScreen\UI\Footer\Translation\TranslationsRepositoryDB\store
store(Translations $translations)
Definition:
TranslationsRepositoryDB.php:46
ILIAS\GlobalScreen\UI\Footer\Translation\TranslationsRepositoryDB\reset
reset()
Definition:
TranslationsRepositoryDB.php:105
ILIAS\GlobalScreen\UI\Footer\Translation\TranslationsRepositoryDB\$default_language
string $default_language
Definition:
TranslationsRepositoryDB.php:34
ILIAS\GlobalScreen\UI\Footer\Translation\TranslationsRepositoryDB\__construct
__construct(private readonly \ilDBInterface $db)
Definition:
TranslationsRepositoryDB.php:36
ILIAS\GlobalScreen\UI\Footer\Translation\TranslationsRepositoryDB\TABLE_NAME
const TABLE_NAME
Definition:
TranslationsRepositoryDB.php:33
ILIAS\$db
$db
Definition:
class.ilias.php:60
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslatableItem
Definition:
TranslatableItem.php:26
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslatableItem\getId
getId()
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\Translation
Definition:
Translation.php:26
ILIAS\GlobalScreen\GUI\I18n\MultiLanguage\TranslationsRepository
Definition:
TranslationsRepository.php:28
ilDBInterface
Interface ilDBInterface.
Definition:
interface.ilDBInterface.php:30
ILIAS\GlobalScreen\UI\Footer\Translation
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition:
TranslationsRepositoryDB.php:19
components
ILIAS
GlobalScreen
classes
UI
Footer
Translation
TranslationsRepositoryDB.php
Generated on Sat Oct 18 2025 23:03:06 for ILIAS by
1.9.4 (using
Doxyfile
)