3 declare(strict_types=1);
34 $this->db = $DIC->database();
35 $this->
lng = $DIC->language();
36 $this->
lng->loadLanguageModule(
'meta');
44 if (!isset(self::$instances[$record_id])) {
62 return isset($this->translations[$lang_key]);
70 return $this->translations[$lang_key];
94 $recordTranslation->setRecordId($new_record_id);
95 $recordTranslation->insert();
99 private function read(): void
105 $this->translations = [];
108 (
int) $row->record_id,
109 (string) $row->title,
110 (
string) $row->description,
111 (string) $row->lang_code
116 $this->default_language = $this->record->getDefaultLanguage();
128 $this->translations[$language_code]->insert();
134 if ($translation->getLangKey() != $default) {
135 $translation->setLangDefault(
false);
136 $translation->update();
138 if ($translation->getLangKey() == $default) {
139 $translation->setLangDefault(
true);
140 $translation->update();
147 if (count($this->translations) <= 1) {
151 $txt = $this->
lng->txt(
'md_adv_int_current') .
' ' . $this->
lng->txt(
'meta_l_' . $active_language);
153 foreach ($this->translations as $translation) {
155 $txt .= ($this->
lng->txt(
'md_adv_int_default') .
' ' . $this->
lng->txt(
'meta_l_' . $translation->getLangKey()));
165 string $active_language
167 if (count($this->translations) <= 1) {
171 if ($default->getLangKey() != $active_language) {
172 $title->
setInfo($default->getLangKey() .
': ' . $default->getTitle());
182 string $active_language
184 if (count($this->translations) <= 1) {
188 if ($default->getLangKey() != $active_language) {
189 $description->
setInfo($default->getLangKey() .
': ' . $default->getDescription());
196 public function updateTranslations(
string $active_language,
string $title,
string $description): void
202 $translation->setTitle($title);
203 $translation->setDescription($description);
204 $translation->update();
212 return $this->record->getTitle();
220 return $this->record->getDescription();
230 'RecordTranslations',
239 'language' => $translation->getLangKey()
242 $writer->
xmlElement(
'RecordTranslationTitle', [], $translation->getTitle());
243 $writer->
xmlElement(
'RecordTranslationDescription', [], $translation->getDescription());
246 $writer->
xmlEndTag(
'RecordTranslations');
toXML(ilXmlWriter $writer)
getTitleForLanguage(string $language)
isConfigured(string $lang_key)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilAdvancedMDRecordTranslation.
modifyTranslationInfoForDescription(ilPropertyFormGUI $form, ilTextAreaInputGUI $description, string $active_language)
getTranslations()
array<string, ilAdvancedMDRecordTranslation>
xmlEndTag(string $tag)
Writes an endtag.
setValue(string $a_value)
static _getInstanceByRecordId(int $a_record_id)
modifyTranslationInfoForTitle(ilPropertyFormGUI $form, ilTextInputGUI $title, string $active_language)
getDescriptionForLanguage(string $language)
Class ilAdvancedMDRecordTranslation.
addTranslationEntry(string $language_code, bool $default=false)
ilAdvancedMDRecord $record
updateTranslations(string $active_language, string $title, string $description)
getFormTranslationInfo(string $active_language)
This class represents a text area property in a property form.
__construct(int $record_id)
updateDefault(string $default)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
cloneRecord(int $new_record_id)
getTranslation(string $lang_key)
static getInstanceByRecordId(int $record_id)