19declare(strict_types=1);
61 $this->db =
$DIC->database();
62 $this->
lng = $DIC->language();
63 $this->
lng->loadLanguageModule(
'meta');
96 foreach ($this->
getTranslations($field_id) as $language => $translation) {
97 if ($language == self::getDefaultLanguage() && !$with_default) {
100 $activated[] = $language;
107 if (!$this->record_translations->isConfigured($lang_key)) {
110 return isset($this->translations[$field_id][$lang_key]);
118 return $this->translations[$field_id][$lang_key];
126 if (isset($this->translations[$field_id])) {
127 return $this->translations[$field_id];
138 if ($translation->getLangKey() == $this->default_language) {
147 $query =
'select fi.field_id tfield, de.field_id ofield, fi.title, fi.description, ri.lang_code ' .
148 'from adv_md_record_int ri join adv_mdf_definition de on ri.record_id = de.record_id ' .
149 'left join adv_md_field_int fi on (ri.lang_code = fi.lang_code and de.field_id = fi.field_id) ' .
151 $res = $this->db->query($query);
154 $this->default_language = $this->record->getDefaultLanguage();
156 $this->translations = [];
161 (
string) $row->title,
162 (
string) $row->description,
163 (
string) $row->lang_code
165 if ((
string) $row->lang_code == $this->default_language && $row->tfield ==
null) {
166 $this->translations[(
int) $row->ofield][(
string) $row->lang_code]->setTitle($this->definitions[(
int) $row->ofield]->getTitle());
167 $this->translations[(
int) $row->ofield][(
string) $row->lang_code]->setDescription(
168 $this->definitions[(
int) $row->ofield]->getDescription()
181 $txt = $this->
lng->txt(
'md_adv_int_current') .
' ' . $this->
lng->txt(
'meta_l_' . $active_language);
184 if ($translation->getLangKey() == $this->getDefaultLanguage()) {
185 $txt .= ($this->
lng->txt(
'md_adv_int_default') .
' ' . $this->
lng->txt(
'meta_l_' . $translation->getLangKey()));
196 string $active_language
198 if (!strlen($active_language)) {
204 $title->setInfo($default->getLangKey() .
': ' . $default->getTitle());
215 string $active_language
217 if (!strlen($active_language)) {
220 $show_info = ($active_language !== $this->getDefaultLanguage() && $this->getDefaultLanguage());
221 $default = $this->getDefaultTranslation($field_id);
223 $description->setInfo($default->getLangKey() .
': ' . $default->getDescription());
226 $description->setValue($this->getTranslation($field_id, $active_language)->getDescription());
232 $translation = $this->getTranslation($field_id, $active_language);
236 $translation->setTitle($form->
getInput(
'title'));
237 $translation->setDescription($form->
getInput(
'description'));
238 $translation->update();
243 if ($this->getTranslation($field_id, $language) && strlen($this->getTranslation(
247 return $this->getTranslation($field_id, $language)->getTitle();
250 $this->getTranslation($field_id, $this->getDefaultLanguage()) &&
251 strlen(($this->getTranslation($field_id, $this->getDefaultLanguage())->
getTitle()))
253 return $this->getTranslation($field_id, $this->getDefaultLanguage())->getTitle();
256 return $this->definitions[$field_id]->getTitle();
263 if ($this->getTranslation($field_id, $language) && strlen($this->getTranslation(
266 )->getDescription())) {
267 return $this->getTranslation($field_id, $language)->getDescription();
269 if ($this->getTranslation($field_id, $this->getDefaultLanguage()) &&
270 strlen($this->getTranslation($field_id, $this->getDefaultLanguage())->getDescription())
272 return $this->getTranslation($field_id, $this->getDefaultLanguage())->getDescription();
275 return $this->definitions[$field_id]->getDescription();
AMD field abstract base class.
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
Class ilAdvancedMDFieldTranslation.
Class ilAdvancedMDFieldTranslations.
ilAdvancedMDRecord $record
ilAdvancedMDRecordTranslations $record_translations
getDefaultTranslation(int $field_id)
getTranslation(int $field_id, string $lang_key)
getTranslations(int $field_id)
static getInstanceByRecordId(int $record_id)
getDescriptionForLanguage(int $field_id, string $language)
__construct(int $record_id)
modifyTranslationInfoForDescription(int $field_id, ilPropertyFormGUI $form, ilTextAreaInputGUI $description, string $active_language)
getTitleForLanguage(int $field_id, string $language)
isConfigured(int $field_id, string $lang_key)
getFormTranslationInfo(int $field_id, string $active_language)
modifyTranslationInfoForTitle(int $field_id, ilPropertyFormGUI $form, ilTextInputGUI $title, string $active_language)
updateFromForm(int $field_id, string $active_language, ilPropertyFormGUI $form)
getActivatedLanguages(int $field_id, bool $with_default=true)
Class ilAdvancedMDRecordTranslation.
static getInstanceByRecordId(int $record_id)
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.
if(!file_exists('../ilias.ini.php'))