19 declare(strict_types=1);
48 $this->db = $DIC->database();
49 $this->
lng = $DIC->language();
50 $this->
lng->loadLanguageModule(
'meta');
58 if (!isset(self::$instances[$record_id])) {
76 return isset($this->translations[$lang_key]);
84 return $this->translations[$lang_key];
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) {
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) {
202 if ($default->getLangKey() != $active_language) {
203 $description->
setInfo($default->getLangKey() .
': ' . $default->getDescription());
210 public function updateTranslations(
string $active_language,
string $title,
string $description): void
216 $translation->setTitle($title);
217 $translation->setDescription($description);
218 $translation->update();
226 return $this->record->getTitle();
234 return $this->record->getDescription();
244 'RecordTranslations',
253 'language' => $translation->getLangKey()
256 $writer->
xmlElement(
'RecordTranslationTitle', [], $translation->getTitle());
257 $writer->
xmlElement(
'RecordTranslationDescription', [], $translation->getDescription());
260 $writer->
xmlEndTag(
'RecordTranslations');
toXML(ilXmlWriter $writer)
getTitleForLanguage(string $language)
isConfigured(string $lang_key)
Class ilAdvancedMDRecordTranslation.
modifyTranslationInfoForDescription(ilPropertyFormGUI $form, ilTextAreaInputGUI $description, string $active_language)
getTranslations()
array<string, ilAdvancedMDRecordTranslation>
xmlEndTag(string $tag)
Writes an endtag.
setValue(string $a_value)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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)