ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilADTLocalizedTextFormBridge.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
10{
14 protected function isValidADT(ilADT $a_adt)
15 {
16 return $a_adt instanceof ilADTLocalizedText;
17 }
18
22 public function addToForm()
23 {
24 $active_languages = $this->getADT()->getCopyOfDefinition()->getActiveLanguages();
25
26 if (!count($active_languages)) {
27 $this->addElementToForm(
28 (string) $this->getTitle(),
29 (string) $this->getElementId(),
30 (string) $this->getADT()->getText(),
31 false,
32 ''
33 );
34 return;
35 }
36 $is_translation = null;
37 foreach ($active_languages as $active_language) {
38 if (strcmp($active_language, $this->getADT()->getCopyOfDefinition()->getDefaultLanguage()) === 0) {
39 $is_translation = false;
40 } else {
41 $is_translation = true;
42 }
43 $this->addElementToForm(
44 (string) $this->getTitle(),
45 (string) $this->getElementId() . '_' . $active_language,
46 (string) $this->getADT()->getTranslations()[$active_language],
47 $is_translation,
48 $active_language
49 );
50 }
51 }
52
56 public function importFromPost()
57 {
58 if (!$this->getADT()->getCopyOfDefinition()->supportsTranslations()) {
59 parent::importFromPost();
60 return;
61 }
62 $active_languages = $this->getADT()->getCopyOfDefinition()->getActiveLanguages();
63 foreach ($active_languages as $language) {
64 $this->getADT()->setTranslation($language, $this->getForm()->getInput($this->getElementId() . '_' . $language));
65 $this->getADT()->setText($this->getForm()->getInput($this->getElementId() . '_' . $language));
66 $input_item = $this->getForm()->getItemByPostVar($this->getElementId() . '_' . $language);
67 $input_item->setValue((string) $this->getADT()->getTranslations()[$language]);
68 }
69 }
70}
An exception for terminatinating execution or to throw for unit testing.
getElementId()
Get element id.
Class ilADTLocalizedText.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addElementToForm(string $title, string $element_id, string $value, bool $is_translation=false, string $language='')
ADT base class.
Definition: class.ilADT.php:12