ILIAS  release_8 Revision v8.24
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
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilMMItemTranslationGUI constructor.

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

49 {
50 global $DIC;
51 $this->main_tpl = $DIC->ui()->mainTemplate();
52 $this->item_facade = $item_facade;
53 $this->repository = $repository;
54 $this->lng()->loadLanguageModule("mme");
55 }
ilMMItemFacadeInterface $item_facade
global $DIC
Definition: feed.php:28

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addLanguages()

ilMMItemTranslationGUI::addLanguages ( )
protected

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

111 : void
112 {
113 $form = $this->getLanguagesForm();
114
115 $this->tpl()->setContent($form->getHTML());
116 }

References getLanguagesForm().

+ Here is the call graph for this function:

◆ cancel()

ilMMItemTranslationGUI::cancel ( )
protected

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

161 : void
162 {
163 $this->ctrl()->redirect($this, self::CMD_DEFAULT);
164 }

References ILIAS\Repository\ctrl().

Referenced by deleteTranslations(), and saveLanguages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteTranslations()

ilMMItemTranslationGUI::deleteTranslations ( )
protected

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

100 : void
101 {
102 $to_delete = (array) ($this->http()->request()->getParsedBody()[self::P_DELETE] ?? []);
103 foreach ($to_delete as $id) {
104 ilMMItemTranslationStorage::find($id)->delete();
105 }
106 $this->repository->updateItem($this->item_facade);
107 $this->main_tpl->setOnScreenMessage('info', $this->lng()->txt('msg_translations_deleted'), true);
108 $this->cancel();
109 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static http()
Fetches the global http state from ILIAS.

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

+ Here is the call graph for this function:

◆ executeCommand()

ilMMItemTranslationGUI::executeCommand ( )

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

57 : void
58 {
59 $this->ctrl()->saveParameter($this, self::IDENTIFIER);
60 switch ($this->ctrl()->getNextClass()) {
61 default:
62 $cmd = $this->ctrl()->getCmd(self::CMD_DEFAULT);
63 $this->{$cmd}();
64 }
65 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getLanguagesForm()

ilMMItemTranslationGUI::getLanguagesForm ( )
protected
Exceptions
ilFormException

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

142 {
143 $form = new ilPropertyFormGUI();
144 $form->setFormAction($this->ctrl()->getFormAction($this));
145
146 // additional languages
148 $options = array("" => $this->lng()->txt("please_select")) + $options;
149 $si = new ilSelectInputGUI($this->lng()->txt("additional_langs"), "additional_langs");
150 $si->setOptions($options);
151 $si->setMulti(true);
152 $form->addItem($si);
153
154 $form->setTitle($this->lng()->txt("add_languages"));
155 $form->addCommandButton(self::CMD_SAVE_LANGUAGES, $this->lng()->txt("save"));
156 $form->addCommandButton(self::CMD_DEFAULT, $this->lng()->txt("cancel"));
157
158 return $form;
159 }
This class represents a property form user interface.
This class represents a selection list property in a property form.

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

Referenced by addLanguages(), and saveLanguages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index()

ilMMItemTranslationGUI::index ( )
protected

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

67 : void
68 {
69 $this->initToolbar();
70
71 $table = new ilMMItemTranslationTableGUI($this, $this->item_facade);
72 $this->tpl()->setContent($table->getHTML());
73 }
Class ilMMItemTranslationTableGUI.

References initToolbar().

+ Here is the call graph for this function:

◆ initToolbar()

ilMMItemTranslationGUI::initToolbar ( )
protected

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

75 : void
76 {
77 $this->toolbar()->addButton(
78 $this->lng()->txt("add_languages"),
79 $this->ctrl()
80 ->getLinkTarget($this, self::CMD_ADD_LANGUAGE)
81 );
82 }

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

Referenced by index().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveLanguages()

ilMMItemTranslationGUI::saveLanguages ( )
protected

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

118 : void
119 {
120 $form = $this->getLanguagesForm();
121 if ($form->checkInput()) {
122 $ad = $form->getInput("additional_langs");
123 if (is_array($ad)) {
124 foreach ($ad as $language_key) {
125 ilMMItemTranslationStorage::storeTranslation($this->item_facade->identification(), $language_key, "");
126 }
127 }
128 $this->repository->updateItem($this->item_facade);
129 $this->main_tpl->setOnScreenMessage('info', $this->lng()->txt("msg_languages_added"), true);
130 $this->cancel();
131 }
132
133 $this->main_tpl->setOnScreenMessage('failure', $this->lng()->txt('err_check_input'));
134 $form->setValuesByPost();
135 $this->tpl()->setContent($form->getHTML());
136 }
static storeTranslation(IdentificationInterface $identification, string $language_key, string $translation)

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

+ Here is the call graph for this function:

Field Documentation

◆ $item_facade

ilMMItemFacadeInterface ilMMItemTranslationGUI::$item_facade
private

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

Referenced by __construct().

◆ $main_tpl

ilGlobalTemplateInterface ilMMItemTranslationGUI::$main_tpl
private

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

◆ $repository

ilMMItemRepository ilMMItemTranslationGUI::$repository
private

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

Referenced by __construct().

◆ CMD_ADD_LANGUAGE

const ilMMItemTranslationGUI::CMD_ADD_LANGUAGE = "addLanguages"

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

◆ CMD_DEFAULT

const ilMMItemTranslationGUI::CMD_DEFAULT = 'index'

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

Referenced by ilMMTopItemTableGUI\fillRow().

◆ CMD_DELETE_TRANSLATIONS

const ilMMItemTranslationGUI::CMD_DELETE_TRANSLATIONS = "deleteTranslations"

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

◆ CMD_SAVE_LANGUAGES

const ilMMItemTranslationGUI::CMD_SAVE_LANGUAGES = "saveLanguages"

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

◆ CMD_SAVE_TRANSLATIONS

const ilMMItemTranslationGUI::CMD_SAVE_TRANSLATIONS = "saveTranslations"

◆ IDENTIFIER

const ilMMItemTranslationGUI::IDENTIFIER = 'identifier'

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

Referenced by ilMMTopItemTableGUI\fillRow().

◆ P_DELETE

const ilMMItemTranslationGUI::P_DELETE = 'delete'

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

Referenced by deleteTranslations().

◆ P_TRANSLATIONS

const ilMMItemTranslationGUI::P_TRANSLATIONS = 'translations'

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


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