ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilBiblTranslationGUI Class Reference

Class ilBiblTranslationGUI. More...

+ Collaboration diagram for ilBiblTranslationGUI:

Public Member Functions

 __construct (protected \ilBiblAdminFactoryFacadeInterface $facade, protected \ilBiblFieldInterface $field)
 ilBiblTranslationGUI constructor. More...
 
 executeCommand ()
 

Data Fields

const P_TRANSLATIONS = 'translations'
 
const P_DELETE = 'delete'
 
const CMD_ADD_LANGUAGE = "addLanguages"
 
const CMD_SAVE_LANGUAGES = "saveLanguages"
 
const CMD_SAVE_TRANSLATIONS = "saveTranslations"
 
const CMD_DELETE_TRANSLATIONS = "deleteTranslations"
 
const CMD_DEFAULT = 'index'
 

Protected Member Functions

 index ()
 
 initToolbar ()
 
 saveTranslations ()
 
 deleteTranslations ()
 
 addLanguages ()
 
 saveLanguages ()
 
 getLanguagesForm ()
 
 cancel ()
 

Private Attributes

ilCtrlInterface $ctrl
 
ilGlobalTemplateInterface $main_tpl
 
LOMServices $lom_services
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBiblTranslationGUI::__construct ( protected \ilBiblAdminFactoryFacadeInterface  $facade,
protected \ilBiblFieldInterface  $field 
)

ilBiblTranslationGUI constructor.

Definition at line 46 of file class.ilBiblTranslationGUI.php.

References $DIC, and ILIAS\Repository\ctrl().

47  {
48  global $DIC;
49  $DIC->language()->loadLanguageModule('obj');
50  $this->main_tpl = $DIC->ui()->mainTemplate();
51  $this->ctrl = $DIC['ilCtrl'];
52  $this->lom_services = $DIC->learningObjectMetadata();
53  }
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ addLanguages()

ilBiblTranslationGUI::addLanguages ( )
protected

Definition at line 104 of file class.ilBiblTranslationGUI.php.

References getLanguagesForm().

104  : void
105  {
106  $form = $this->getLanguagesForm();
107 
108  $this->tpl()->setContent($form->getHTML());
109  }
+ Here is the call graph for this function:

◆ cancel()

ilBiblTranslationGUI::cancel ( )
protected

Definition at line 164 of file class.ilBiblTranslationGUI.php.

References ILIAS\Repository\ctrl().

Referenced by deleteTranslations(), saveLanguages(), and saveTranslations().

164  : void
165  {
166  $this->ctrl->redirect($this, self::CMD_DEFAULT);
167  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteTranslations()

ilBiblTranslationGUI::deleteTranslations ( )
protected

Definition at line 93 of file class.ilBiblTranslationGUI.php.

References $id, cancel(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

93  : void
94  {
95  $to_delete = (array) $this->http()->request()->getParsedBody()[self::P_DELETE];
96  foreach ($to_delete as $id) {
97  $this->facade->translationFactory()->deleteById($id);
98  }
99  $this->main_tpl->setOnScreenMessage('info', $this->lng()->txt('bibl_msg_translations_deleted'), true);
100  $this->cancel();
101  }
static http()
Fetches the global http state from ILIAS.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ executeCommand()

ilBiblTranslationGUI::executeCommand ( )

Definition at line 56 of file class.ilBiblTranslationGUI.php.

References ILIAS\Repository\ctrl().

56  : void
57  {
58  $cmd = $this->ctrl->getCmd(self::CMD_DEFAULT);
59  $this->{$cmd}();
60  }
+ Here is the call graph for this function:

◆ getLanguagesForm()

ilBiblTranslationGUI::getLanguagesForm ( )
protected

Definition at line 133 of file class.ilBiblTranslationGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by addLanguages(), and saveLanguages().

134  {
135  $form = new ilPropertyFormGUI();
136  $form->setFormAction($this->ctrl->getFormAction($this));
137 
138  // master language
139  // $options = ilMDLanguageItem::_getLanguages();
140  // $si = new ilSelectInputGUI($this->lng()->txt("obj_master_lang"), "master_lang");
141  // $si->setOptions($options);
142  // $si->setValue($this->user()->getLanguage());
143  // $form->addItem($si);
144 
145  // additional languages
146  $options = [];
147  foreach ($this->lom_services->dataHelper()->getAllLanguages() as $language) {
148  $options[$language->value()] = $language->presentableLabel();
149  }
150  $options = ["" => $this->lng()->txt("please_select")] + $options;
151  $si = new ilSelectInputGUI($this->lng()->txt("obj_additional_langs"), "additional_langs");
152  $si->setOptions($options);
153  $si->setMulti(true);
154  $form->addItem($si);
155 
156  $form->setTitle($this->lng()->txt("obj_add_languages"));
157  $form->addCommandButton(self::CMD_SAVE_LANGUAGES, $this->lng()->txt("save"));
158  $form->addCommandButton(self::CMD_DEFAULT, $this->lng()->txt("cancel"));
159 
160  return $form;
161  }
This class represents a selection list property in a property form.
This class represents a property form user interface.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index()

ilBiblTranslationGUI::index ( )
protected

Definition at line 63 of file class.ilBiblTranslationGUI.php.

References initToolbar().

63  : void
64  {
65  $this->initToolbar();
66 
67  $table = new ilBiblTranslationTableGUI($this, $this->field, $this->facade->translationFactory());
68  $this->tpl()->setContent($table->getHTML());
69  }
Class ilBiblTranslationTableGUI.
+ Here is the call graph for this function:

◆ initToolbar()

ilBiblTranslationGUI::initToolbar ( )
protected

Definition at line 72 of file class.ilBiblTranslationGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by index().

72  : void
73  {
74  $this->toolbar()->addButton($this->lng()->txt("obj_add_languages"), $this->ctrl
75  ->getLinkTarget($this, self::CMD_ADD_LANGUAGE));
76  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveLanguages()

ilBiblTranslationGUI::saveLanguages ( )
protected

Definition at line 112 of file class.ilBiblTranslationGUI.php.

References cancel(), getLanguagesForm(), and ILIAS\Repository\lng().

112  : void
113  {
114  $form = $this->getLanguagesForm();
115  if ($form->checkInput()) {
116  $ad = $form->getInput("additional_langs");
117  if (is_array($ad)) {
118  foreach ($ad as $language_key) {
119  $this->facade->translationFactory()
120  ->findArCreateInstanceForFieldAndlanguage($this->field, $language_key);
121  }
122  }
123  $this->main_tpl->setOnScreenMessage('info', $this->lng()->txt("msg_obj_modified"), true);
124  $this->cancel();
125  }
126 
127  $this->main_tpl->setOnScreenMessage('failure', $this->lng()->txt('err_check_input'));
128  $form->setValuesByPost();
129  $this->tpl()->setContent($form->getHTML());
130  }
+ Here is the call graph for this function:

◆ saveTranslations()

ilBiblTranslationGUI::saveTranslations ( )
protected

Definition at line 79 of file class.ilBiblTranslationGUI.php.

References $data, $id, cancel(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

79  : void
80  {
81  $to_translate = (array) $this->http()->request()->getParsedBody()[self::P_TRANSLATIONS];
82  foreach ($to_translate as $id => $data) {
83  $translation = $this->facade->translationFactory()->findById($id);
84  $translation->setTranslation($data['translation']);
85  $translation->setDescription($data['description']);
86  $translation->store();
87  }
88  $this->main_tpl->setOnScreenMessage('info', $this->lng()->txt('bibl_msg_translations_saved'), true);
89  $this->cancel();
90  }
static http()
Fetches the global http state from ILIAS.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilBiblTranslationGUI::$ctrl
private

Definition at line 38 of file class.ilBiblTranslationGUI.php.

◆ $lom_services

LOMServices ilBiblTranslationGUI::$lom_services
private

Definition at line 40 of file class.ilBiblTranslationGUI.php.

◆ $main_tpl

ilGlobalTemplateInterface ilBiblTranslationGUI::$main_tpl
private

Definition at line 39 of file class.ilBiblTranslationGUI.php.

◆ CMD_ADD_LANGUAGE

const ilBiblTranslationGUI::CMD_ADD_LANGUAGE = "addLanguages"

Definition at line 33 of file class.ilBiblTranslationGUI.php.

◆ CMD_DEFAULT

const ilBiblTranslationGUI::CMD_DEFAULT = 'index'

◆ CMD_DELETE_TRANSLATIONS

const ilBiblTranslationGUI::CMD_DELETE_TRANSLATIONS = "deleteTranslations"

◆ CMD_SAVE_LANGUAGES

const ilBiblTranslationGUI::CMD_SAVE_LANGUAGES = "saveLanguages"

Definition at line 34 of file class.ilBiblTranslationGUI.php.

◆ CMD_SAVE_TRANSLATIONS

const ilBiblTranslationGUI::CMD_SAVE_TRANSLATIONS = "saveTranslations"

◆ P_DELETE

const ilBiblTranslationGUI::P_DELETE = 'delete'

Definition at line 32 of file class.ilBiblTranslationGUI.php.

◆ P_TRANSLATIONS

const ilBiblTranslationGUI::P_TRANSLATIONS = 'translations'

Definition at line 31 of file class.ilBiblTranslationGUI.php.


The documentation for this class was generated from the following file: