ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMMItemTranslationGUI Class Reference

Class ilMMItemTranslationGUI. More...

+ Collaboration diagram for ilMMItemTranslationGUI:

Public Member Functions

 __construct (private ilMMItemFacadeInterface $item_facade, private ilMMItemRepository $repository)
 ilMMItemTranslationGUI 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'
 
const IDENTIFIER = 'identifier'
 

Protected Member Functions

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

Private Attributes

ilGlobalTemplateInterface $main_tpl
 
LOMServices $lom_services
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMMItemTranslationGUI::__construct ( private ilMMItemFacadeInterface  $item_facade,
private ilMMItemRepository  $repository 
)

ilMMItemTranslationGUI constructor.

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

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

47  {
48  global $DIC;
49  $this->main_tpl = $DIC->ui()->mainTemplate();
50  $this->lom_services = $DIC->learningObjectMetadata();
51  $this->lng()->loadLanguageModule("mme");
52  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ addLanguages()

ilMMItemTranslationGUI::addLanguages ( )
protected

Definition at line 105 of file class.ilMMItemTranslationGUI.php.

References getLanguagesForm().

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

◆ cancel()

ilMMItemTranslationGUI::cancel ( )
protected

Definition at line 158 of file class.ilMMItemTranslationGUI.php.

References ILIAS\Repository\ctrl().

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

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

◆ deleteTranslations()

ilMMItemTranslationGUI::deleteTranslations ( )
protected

Definition at line 94 of file class.ilMMItemTranslationGUI.php.

References $id, cancel(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

94  : void
95  {
96  $to_delete = (array) ($this->http()->request()->getParsedBody()[self::P_DELETE] ?? []);
97  foreach ($to_delete as $id) {
98  ilMMItemTranslationStorage::find($id)->delete();
99  }
100  $this->repository->updateItem($this->item_facade);
101  $this->main_tpl->setOnScreenMessage('info', $this->lng()->txt('msg_translations_deleted'), true);
102  $this->cancel();
103  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:33
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()

ilMMItemTranslationGUI::executeCommand ( )

Definition at line 54 of file class.ilMMItemTranslationGUI.php.

References ILIAS\Repository\ctrl().

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

◆ getLanguagesForm()

ilMMItemTranslationGUI::getLanguagesForm ( )
protected
Exceptions
ilFormException

Definition at line 135 of file class.ilMMItemTranslationGUI.php.

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

Referenced by addLanguages(), and saveLanguages().

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

◆ index()

ilMMItemTranslationGUI::index ( )
protected

Definition at line 61 of file class.ilMMItemTranslationGUI.php.

References initToolbar().

61  : void
62  {
63  $this->initToolbar();
64 
65  $table = new ilMMItemTranslationTableGUI($this, $this->item_facade);
66  $this->tpl()->setContent($table->getHTML());
67  }
Class ilMMItemTranslationTableGUI.
+ Here is the call graph for this function:

◆ initToolbar()

ilMMItemTranslationGUI::initToolbar ( )
protected

Definition at line 69 of file class.ilMMItemTranslationGUI.php.

References $data, $id, cancel(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\UI\examples\Deck\repository(), and ILIAS\Repository\toolbar().

Referenced by index().

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

◆ saveLanguages()

ilMMItemTranslationGUI::saveLanguages ( )
protected

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

References cancel(), getLanguagesForm(), ILIAS\Repository\lng(), ILIAS\UI\examples\Deck\repository(), and ilMMItemTranslationStorage\storeTranslation().

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  ilMMItemTranslationStorage::storeTranslation($this->item_facade->identification(), $language_key, "");
120  }
121  }
122  $this->repository->updateItem($this->item_facade);
123  $this->main_tpl->setOnScreenMessage('info', $this->lng()->txt("msg_languages_added"), 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  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:33
static storeTranslation(IdentificationInterface $identification, string $language_key, string $translation)
+ Here is the call graph for this function:

Field Documentation

◆ $lom_services

LOMServices ilMMItemTranslationGUI::$lom_services
private

Definition at line 41 of file class.ilMMItemTranslationGUI.php.

◆ $main_tpl

ilGlobalTemplateInterface ilMMItemTranslationGUI::$main_tpl
private

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

◆ CMD_ADD_LANGUAGE

const ilMMItemTranslationGUI::CMD_ADD_LANGUAGE = "addLanguages"

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

◆ CMD_DEFAULT

const ilMMItemTranslationGUI::CMD_DEFAULT = 'index'

◆ CMD_DELETE_TRANSLATIONS

const ilMMItemTranslationGUI::CMD_DELETE_TRANSLATIONS = "deleteTranslations"

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

◆ CMD_SAVE_LANGUAGES

const ilMMItemTranslationGUI::CMD_SAVE_LANGUAGES = "saveLanguages"

Definition at line 35 of file class.ilMMItemTranslationGUI.php.

◆ CMD_SAVE_TRANSLATIONS

const ilMMItemTranslationGUI::CMD_SAVE_TRANSLATIONS = "saveTranslations"

◆ IDENTIFIER

const ilMMItemTranslationGUI::IDENTIFIER = 'identifier'

◆ P_DELETE

const ilMMItemTranslationGUI::P_DELETE = 'delete'

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

◆ P_TRANSLATIONS

const ilMMItemTranslationGUI::P_TRANSLATIONS = 'translations'

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


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