ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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

 $facade
 
 $field
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilBiblTranslationGUI constructor.

Parameters
\ilBiblAdminFactoryFacadeInterface$facade
\ilBiblFieldInterface$field

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

References $facade, and $field.

38  {
39  $this->facade = $facade;
40  $this->field = $field;
41  }

Member Function Documentation

◆ addLanguages()

ilBiblTranslationGUI::addLanguages ( )
protected

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

References $form, and getLanguagesForm().

97  {
98  $form = $this->getLanguagesForm();
99 
100  $this->tpl()->setContent($form->getHTML());
101  }
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:

◆ cancel()

ilBiblTranslationGUI::cancel ( )
protected

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

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

157  {
158  $this->ctrl()->redirect($this, self::CMD_DEFAULT);
159  }
+ Here is the caller graph for this function:

◆ deleteTranslations()

ilBiblTranslationGUI::deleteTranslations ( )
protected

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

References $id, cancel(), ILIAS\FileDelivery\http(), and ilUtil\sendInfo().

86  {
87  $to_delete = (array) $this->http()->request()->getParsedBody()[self::P_DELETE];
88  foreach ($to_delete as $id) {
89  $this->facade->translationFactory()->deleteById($id);
90  }
91  ilUtil::sendInfo($this->lng()->txt('bibl_msg_translations_deleted'), true);
92  $this->cancel();
93  }
if(!array_key_exists('StateId', $_REQUEST)) $id
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ executeCommand()

ilBiblTranslationGUI::executeCommand ( )

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

References ilBiblAdminFieldGUI\FIELD_IDENTIFIER.

45  {
46  $this->ctrl()->saveParameter($this, ilBiblAdminFieldGUI::FIELD_IDENTIFIER);
47  switch ($this->ctrl()->getNextClass()) {
48  default:
49  $cmd = $this->ctrl()->getCmd(self::CMD_DEFAULT);
50  $this->{$cmd}();
51  }
52  }

◆ getLanguagesForm()

ilBiblTranslationGUI::getLanguagesForm ( )
protected
Returns

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

References $form, PHPMailer\PHPMailer\$options, $si, and ilMDLanguageItem\_getLanguages().

Referenced by addLanguages(), and saveLanguages().

129  {
130  $form = new ilPropertyFormGUI();
131  $form->setFormAction($this->ctrl()->getFormAction($this));
132 
133  // master language
134  // $options = ilMDLanguageItem::_getLanguages();
135  // $si = new ilSelectInputGUI($this->lng()->txt("obj_master_lang"), "master_lang");
136  // $si->setOptions($options);
137  // $si->setValue($this->user()->getLanguage());
138  // $form->addItem($si);
139 
140  // additional languages
142  $options = array( "" => $this->lng()->txt("please_select") ) + $options;
143  $si = new ilSelectInputGUI($this->lng()->txt("obj_additional_langs"), "additional_langs");
144  $si->setOptions($options);
145  $si->setMulti(true);
146  $form->addItem($si);
147 
148  $form->setTitle($this->lng()->txt("obj_add_languages"));
149  $form->addCommandButton(self::CMD_SAVE_LANGUAGES, $this->lng()->txt("save"));
150  $form->addCommandButton(self::CMD_DEFAULT, $this->lng()->txt("cancel"));
151 
152  return $form;
153  }
This class represents a selection list property in a property form.
This class represents a property form user interface.
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index()

ilBiblTranslationGUI::index ( )
protected

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

References $table, and initToolbar().

56  {
57  $this->initToolbar();
58 
59  $table = new ilBiblTranslationTableGUI($this, $this->field, $this->facade->translationFactory());
60  $this->tpl()->setContent($table->getHTML());
61  }
Class ilBiblTranslationTableGUI.
if(empty($password)) $table
Definition: pwgen.php:24
+ Here is the call graph for this function:

◆ initToolbar()

ilBiblTranslationGUI::initToolbar ( )
protected

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

Referenced by index().

65  {
66  $this->toolbar()->addButton($this->lng()->txt("obj_add_languages"), $this->ctrl()
67  ->getLinkTarget($this, self::CMD_ADD_LANGUAGE));
68  }
+ Here is the caller graph for this function:

◆ saveLanguages()

ilBiblTranslationGUI::saveLanguages ( )
protected

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

References $form, cancel(), getLanguagesForm(), ilUtil\sendFailure(), and ilUtil\sendInfo().

105  {
106  $form = $this->getLanguagesForm();
107  if ($form->checkInput()) {
108  $ad = $form->getInput("additional_langs");
109  if (is_array($ad)) {
110  foreach ($ad as $language_key) {
111  $this->facade->translationFactory()
112  ->findArCreateInstanceForFieldAndlanguage($this->field, $language_key);
113  }
114  }
115  ilUtil::sendInfo($this->lng()->txt("msg_obj_modified"), true);
116  $this->cancel();
117  }
118 
119  ilUtil::sendFailure($this->lng()->txt('err_check_input'));
120  $form->setValuesByPost();
121  $this->tpl()->setContent($form->getHTML());
122  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(isset($_POST['submit'])) $form
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ saveTranslations()

ilBiblTranslationGUI::saveTranslations ( )
protected

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

References $data, $id, cancel(), ILIAS\FileDelivery\http(), and ilUtil\sendInfo().

72  {
73  $to_translate = (array) $this->http()->request()->getParsedBody()[self::P_TRANSLATIONS];
74  foreach ($to_translate as $id => $data) {
75  $translation = $this->facade->translationFactory()->findById($id);
76  $translation->setTranslation($data['translation']);
77  $translation->setDescription($data['description']);
78  $translation->store();
79  }
80  ilUtil::sendInfo($this->lng()->txt('bibl_msg_translations_saved'), true);
81  $this->cancel();
82  }
if(!array_key_exists('StateId', $_REQUEST)) $id
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static http()
Fetches the global http state from ILIAS.
$data
Definition: bench.php:6
+ Here is the call graph for this function:

Field Documentation

◆ $facade

ilBiblTranslationGUI::$facade
protected

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

Referenced by __construct().

◆ $field

ilBiblTranslationGUI::$field
protected

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

Referenced by __construct().

◆ CMD_ADD_LANGUAGE

const ilBiblTranslationGUI::CMD_ADD_LANGUAGE = "addLanguages"

Definition at line 16 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 17 of file class.ilBiblTranslationGUI.php.

◆ CMD_SAVE_TRANSLATIONS

const ilBiblTranslationGUI::CMD_SAVE_TRANSLATIONS = "saveTranslations"

◆ P_DELETE

const ilBiblTranslationGUI::P_DELETE = 'delete'

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

◆ P_TRANSLATIONS

const ilBiblTranslationGUI::P_TRANSLATIONS = 'translations'

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


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