ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilBiblTranslationGUI Class Reference

Class ilBiblTranslationGUI. More...

+ Collaboration diagram for ilBiblTranslationGUI:

Public Member Functions

 __construct (ilBiblAdminFactoryFacadeInterface $facade, \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 ()
 

Protected Attributes

ilBiblAdminFactoryFacadeInterface $facade
 
ilBiblFieldInterface $field
 

Private Attributes

ilCtrlInterface $ctrl
 
ilGlobalTemplateInterface $main_tpl
 
LOMServices $lom_services
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilBiblTranslationGUI constructor.

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

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

49  {
50  global $DIC;
51  $DIC->language()->loadLanguageModule('obj');
52  $this->main_tpl = $DIC->ui()->mainTemplate();
53  $this->facade = $facade;
54  $this->field = $field;
55  $this->ctrl = $DIC['ilCtrl'];
56  $this->lom_services = $DIC->learningObjectMetadata();
57  }
ilBiblAdminFactoryFacadeInterface $facade
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ addLanguages()

ilBiblTranslationGUI::addLanguages ( )
protected

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

References getLanguagesForm().

111  : void
112  {
113  $form = $this->getLanguagesForm();
114 
115  $this->tpl()->setContent($form->getHTML());
116  }
+ Here is the call graph for this function:

◆ cancel()

ilBiblTranslationGUI::cancel ( )
protected

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

References ILIAS\Repository\ctrl().

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

171  : void
172  {
173  $this->ctrl->redirect($this, self::CMD_DEFAULT);
174  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteTranslations()

ilBiblTranslationGUI::deleteTranslations ( )
protected

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

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

100  : void
101  {
102  $to_delete = (array) $this->http()->request()->getParsedBody()[self::P_DELETE];
103  foreach ($to_delete as $id) {
104  $this->facade->translationFactory()->deleteById($id);
105  }
106  $this->main_tpl->setOnScreenMessage('info', $this->lng()->txt('bibl_msg_translations_deleted'), true);
107  $this->cancel();
108  }
static http()
Fetches the global http state from ILIAS.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ Here is the call graph for this function:

◆ executeCommand()

ilBiblTranslationGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

60  : void
61  {
62  switch ($this->ctrl->getNextClass()) {
63  default:
64  $cmd = $this->ctrl->getCmd(self::CMD_DEFAULT);
65  $this->{$cmd}();
66  }
67  }
+ Here is the call graph for this function:

◆ getLanguagesForm()

ilBiblTranslationGUI::getLanguagesForm ( )
protected

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

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

Referenced by addLanguages(), and saveLanguages().

141  {
142  $form = new ilPropertyFormGUI();
143  $form->setFormAction($this->ctrl->getFormAction($this));
144 
145  // master language
146  // $options = ilMDLanguageItem::_getLanguages();
147  // $si = new ilSelectInputGUI($this->lng()->txt("obj_master_lang"), "master_lang");
148  // $si->setOptions($options);
149  // $si->setValue($this->user()->getLanguage());
150  // $form->addItem($si);
151 
152  // additional languages
153  $options = [];
154  foreach ($this->lom_services->dataHelper()->getAllLanguages() as $language) {
155  $options[$language->value()] = $language->presentableLabel();
156  }
157  $options = array("" => $this->lng()->txt("please_select")) + $options;
158  $si = new ilSelectInputGUI($this->lng()->txt("obj_additional_langs"), "additional_langs");
159  $si->setOptions($options);
160  $si->setMulti(true);
161  $form->addItem($si);
162 
163  $form->setTitle($this->lng()->txt("obj_add_languages"));
164  $form->addCommandButton(self::CMD_SAVE_LANGUAGES, $this->lng()->txt("save"));
165  $form->addCommandButton(self::CMD_DEFAULT, $this->lng()->txt("cancel"));
166 
167  return $form;
168  }
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 70 of file class.ilBiblTranslationGUI.php.

References initToolbar().

70  : void
71  {
72  $this->initToolbar();
73 
74  $table = new ilBiblTranslationTableGUI($this, $this->field, $this->facade->translationFactory());
75  $this->tpl()->setContent($table->getHTML());
76  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ initToolbar()

ilBiblTranslationGUI::initToolbar ( )
protected

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

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

Referenced by index().

79  : void
80  {
81  $this->toolbar()->addButton($this->lng()->txt("obj_add_languages"), $this->ctrl
82  ->getLinkTarget($this, self::CMD_ADD_LANGUAGE));
83  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveLanguages()

ilBiblTranslationGUI::saveLanguages ( )
protected

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

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

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

◆ saveTranslations()

ilBiblTranslationGUI::saveTranslations ( )
protected

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

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

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

Field Documentation

◆ $ctrl

ilCtrlInterface ilBiblTranslationGUI::$ctrl
private

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

◆ $facade

ilBiblAdminFactoryFacadeInterface ilBiblTranslationGUI::$facade
protected

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

Referenced by __construct().

◆ $field

ilBiblFieldInterface ilBiblTranslationGUI::$field
protected

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

Referenced by __construct().

◆ $lom_services

LOMServices ilBiblTranslationGUI::$lom_services
private

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

◆ $main_tpl

ilGlobalTemplateInterface ilBiblTranslationGUI::$main_tpl
private

Definition at line 41 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: