19declare(strict_types=1);
48 $this->db =
$DIC->database();
49 $this->
lng = $DIC->language();
50 $this->
lng->loadLanguageModule(
'meta');
76 return isset($this->translations[$lang_key]);
84 return $this->translations[$lang_key];
98 if ($translation->getLangKey() == $this->default_language) {
108 $recordTranslation->setRecordId($new_record_id);
109 $recordTranslation->insert();
117 $res = $this->db->query($query);
119 $this->translations = [];
122 (
int) $row->record_id,
123 (string) $row->title,
124 (
string) $row->description,
125 (string) $row->lang_code
130 $this->default_language = $this->record->getDefaultLanguage();
142 $this->translations[$language_code]->insert();
148 if ($translation->getLangKey() != $default) {
149 $translation->setLangDefault(
false);
150 $translation->update();
152 if ($translation->getLangKey() == $default) {
153 $translation->setLangDefault(
true);
154 $translation->update();
161 if (count($this->translations) <= 1) {
165 $txt = $this->
lng->txt(
'md_adv_int_current') .
' ' . $this->
lng->txt(
'meta_l_' . $active_language);
167 foreach ($this->translations as $translation) {
168 if ($translation->getLangKey() == $this->default_language) {
169 $txt .= ($this->
lng->txt(
'md_adv_int_default') .
' ' . $this->
lng->txt(
'meta_l_' . $translation->getLangKey()));
179 string $active_language
181 if (count($this->translations) <= 1) {
185 if ($default->getLangKey() != $active_language) {
186 $title->setInfo($default->getLangKey() .
': ' . $default->getTitle());
196 string $active_language
198 if (count($this->translations) <= 1) {
201 $default = $this->getDefaultTranslation();
202 if ($default->getLangKey() != $active_language) {
203 $description->setInfo($default->getLangKey() .
': ' . $default->getDescription());
206 $description->setValue($this->getTranslation($active_language)->getDescription());
210 public function updateTranslations(
string $active_language,
string $title,
string $description): void
212 $translation = $this->getTranslation($active_language);
216 $translation->setTitle($title);
217 $translation->setDescription($description);
218 $translation->update();
223 if ($this->getTranslation($language) && strlen($this->getTranslation($language)->
getTitle())) {
224 return $this->getTranslation($language)->getTitle();
226 return $this->record->getTitle();
231 if ($this->getTranslation($language) && strlen($this->getTranslation($language)->getDescription())) {
232 return $this->getTranslation($language)->getDescription();
234 return $this->record->getDescription();
239 if (!count($this->getTranslations())) {
244 'RecordTranslations',
246 'defaultLanguage' => $this->getDefaultLanguage()
249 foreach ($this->getTranslations() as $translation) {
253 'language' => $translation->getLangKey()
256 $writer->
xmlElement(
'RecordTranslationTitle', [], $translation->getTitle());
257 $writer->
xmlElement(
'RecordTranslationDescription', [], $translation->getDescription());
260 $writer->
xmlEndTag(
'RecordTranslations');
Class ilAdvancedMDRecordTranslation.
Class ilAdvancedMDRecordTranslation.
addTranslationEntry(string $language_code, bool $default=false)
getTranslation(string $lang_key)
getTitleForLanguage(string $language)
updateTranslations(string $active_language, string $title, string $description)
__construct(int $record_id)
ilAdvancedMDRecord $record
modifyTranslationInfoForDescription(ilPropertyFormGUI $form, ilTextAreaInputGUI $description, string $active_language)
getTranslations()
array<string, ilAdvancedMDRecordTranslation>
static getInstanceByRecordId(int $record_id)
getFormTranslationInfo(string $active_language)
isConfigured(string $lang_key)
cloneRecord(int $new_record_id)
getDescriptionForLanguage(string $language)
toXML(ilXmlWriter $writer)
modifyTranslationInfoForTitle(ilPropertyFormGUI $form, ilTextInputGUI $title, string $active_language)
updateDefault(string $default)
static _getInstanceByRecordId(int $a_record_id)
This class represents a text area property in a property form.
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
if(!file_exists('../ilias.ini.php'))