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

Class ilMMItemTranslationGUI. More...

+ Collaboration diagram for ilMMItemTranslationGUI:

Public Member Functions

 __construct (ilMMItemFacadeInterface $item_facade, 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

ilMMItemRepository $repository
 
ilMMItemFacadeInterface $item_facade
 
ilGlobalTemplateInterface $main_tpl
 
LOMServices $lom_services
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilMMItemTranslationGUI constructor.

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

References $DIC, $item_facade, $repository, ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

51  {
52  global $DIC;
53  $this->main_tpl = $DIC->ui()->mainTemplate();
54  $this->lom_services = $DIC->learningObjectMetadata();
55  $this->item_facade = $item_facade;
56  $this->repository = $repository;
57  $this->lng()->loadLanguageModule("mme");
58  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:17
global $DIC
Definition: shib_login.php:25
ilMMItemFacadeInterface $item_facade
+ Here is the call graph for this function:

Member Function Documentation

◆ addLanguages()

ilMMItemTranslationGUI::addLanguages ( )
protected

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

References getLanguagesForm().

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

◆ cancel()

ilMMItemTranslationGUI::cancel ( )
protected

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

References ILIAS\Repository\ctrl().

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

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

◆ deleteTranslations()

ilMMItemTranslationGUI::deleteTranslations ( )
protected

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

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

103  : void
104  {
105  $to_delete = (array) ($this->http()->request()->getParsedBody()[self::P_DELETE] ?? []);
106  foreach ($to_delete as $id) {
107  ilMMItemTranslationStorage::find($id)->delete();
108  }
109  $this->repository->updateItem($this->item_facade);
110  $this->main_tpl->setOnScreenMessage('info', $this->lng()->txt('msg_translations_deleted'), true);
111  $this->cancel();
112  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:17
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()

ilMMItemTranslationGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

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

◆ getLanguagesForm()

ilMMItemTranslationGUI::getLanguagesForm ( )
protected
Exceptions
ilFormException

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

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

Referenced by addLanguages(), and saveLanguages().

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

References initToolbar().

70  : void
71  {
72  $this->initToolbar();
73 
74  $table = new ilMMItemTranslationTableGUI($this, $this->item_facade);
75  $this->tpl()->setContent($table->getHTML());
76  }
Class ilMMItemTranslationTableGUI.
+ Here is the call graph for this function:

◆ initToolbar()

ilMMItemTranslationGUI::initToolbar ( )
protected

Definition at line 78 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().

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

◆ saveLanguages()

ilMMItemTranslationGUI::saveLanguages ( )
protected

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

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

121  : void
122  {
123  $form = $this->getLanguagesForm();
124  if ($form->checkInput()) {
125  $ad = $form->getInput("additional_langs");
126  if (is_array($ad)) {
127  foreach ($ad as $language_key) {
128  ilMMItemTranslationStorage::storeTranslation($this->item_facade->identification(), $language_key, "");
129  }
130  }
131  $this->repository->updateItem($this->item_facade);
132  $this->main_tpl->setOnScreenMessage('info', $this->lng()->txt("msg_languages_added"), true);
133  $this->cancel();
134  }
135 
136  $this->main_tpl->setOnScreenMessage('failure', $this->lng()->txt('err_check_input'));
137  $form->setValuesByPost();
138  $this->tpl()->setContent($form->getHTML());
139  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:17
static storeTranslation(IdentificationInterface $identification, string $language_key, string $translation)
+ Here is the call graph for this function:

Field Documentation

◆ $item_facade

ilMMItemFacadeInterface ilMMItemTranslationGUI::$item_facade
private

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

Referenced by __construct().

◆ $lom_services

LOMServices ilMMItemTranslationGUI::$lom_services
private

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

◆ $main_tpl

ilGlobalTemplateInterface ilMMItemTranslationGUI::$main_tpl
private

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

◆ $repository

ilMMItemRepository ilMMItemTranslationGUI::$repository
private

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

Referenced by __construct().

◆ 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: