ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI Class Reference
+ Inheritance diagram for ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI:
+ Collaboration diagram for ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI:

Public Member Functions

 __construct (Pons $pons, ?TranslatableItem $translatable_item=null, private ?URI $back_target=null,)
 
 getTokensToKeep ()
 
 executeCommand ()
 
- Public Member Functions inherited from ILIAS\GlobalScreen\GUI\AbstractPonsGUI
 __construct (protected Pons $pons)
 
- Public Member Functions inherited from ILIAS\GlobalScreen\GUI\PonsGUI
 __construct (Pons $pons)
 
 executeCommand ()
 
 getTokensToKeep ()
 

Data Fields

const CMD_DEFAULT = 'index'
 
const CMD_LANGUAGE_SELECTION = 'selectLanguages'
 
const CMD_SAVE_LANGUAGE_SELECTION = 'saveLanguages'
 
const CMD_TRANSLATE_IN_MODAL = 'translateInAsyncModal'
 
const CMD_SAVE_TRANSLATIONS = 'saveTranslations'
 
- Data Fields inherited from ILIAS\GlobalScreen\GUI\PonsGUI
const CMD_DEFAULT = 'index'
 

Private Member Functions

 index ()
 
 selectLanguages ()
 
 translateInAsyncModal ()
 
 saveTranslations ()
 

Private Attributes

Translator $translator
 
TranslationsRepository $repository
 
Factory $ui_factory
 
ServerRequestInterface $request
 
TranslationWorkflowForm $workflow
 
TranslatableItem $translatable_item
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 37 of file MultiLanguageGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::__construct ( Pons  $pons,
?TranslatableItem  $translatable_item = null,
private ?URI  $back_target = null 
)

Definition at line 66 of file MultiLanguageGUI.php.

70 {
72 global $DIC;
73
74 $this->ui_factory = $this->pons->out()->ui()->factory();
75 $this->request = $this->pons->in()->request();
76 $this->translator = $this->pons->i18n();
77
78 $this->repository = $this->pons->i18n()->ml()->repository();
79
80 $this->workflow = new TranslationWorkflowForm(
81 $DIC->learningObjectMetadata(),
82 $this->pons->out()->ui(),
83 $this->repository,
84 $this->translatable_item = $translatable_item ?? $this->repository->retrieveCurrent($this->pons),
85 );
86 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI\$translatable_item, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::executeCommand ( )
Returns
bool true if you handled this command aka you were the CtrlClass, otherwise false

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Definition at line 189 of file MultiLanguageGUI.php.

189 : bool
190 {
191 $cmd = $this->pons->flow()->getCommand(self::CMD_TRANSLATE_IN_MODAL);
192
193 match ($cmd) {
194 default => $this->$cmd(),
195 };
196 }

◆ getTokensToKeep()

ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::getTokensToKeep ( )

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Definition at line 88 of file MultiLanguageGUI.php.

88 : array
89 {
90 return [];
91 }

◆ index()

ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::index ( )
private

Definition at line 93 of file MultiLanguageGUI.php.

93 : void
94 {
95 // LISTING
96 $translations = $this->repository->get($this->translatable_item);
97 if ($translations->get() === []) {
98 $content = $this->ui_factory->messageBox()->info(
99 $this->pons->i18n()->translate('no_translations')
100 );
101 } else {
102 $items = [];
103 foreach ($translations->get() as $t) {
104 $items[$this->pons->i18n()->translate('meta_l_' . $t->getLanguageCode())] = $t->getTranslation();
105 }
106 $content = $this->ui_factory->listing()->descriptive(
107 $items
108 );
109 $content = $this->back_target === null ? $this->ui_factory->panel()->secondary()->legacy(
110 $this->translator->translate('translations'),
111 $this->ui_factory->legacy()->content(
112 $this->pons->out()->render($content)
113 )
114 ) : $content;
115 }
116
117 $prompt = $this->ui_factory->prompt()->standard(
118 $this->pons->flow()->getHereAsURI(self::CMD_LANGUAGE_SELECTION)
119 );
120
121 // Edit Button
122 $edit_button = $this->ui_factory
123 ->button()
124 ->standard(
125 $this->translator->translate('edit_translations'),
126 '#'
127 )
128 ->withOnClick($prompt->getShowSignal());
129
130 global $DIC; // currently not used
131 $DIC->toolbar()->addComponent(
132 $edit_button
133 );
134
135 if ($this->back_target === null) {
136 $this->pons->out()->out(
137 $prompt,
138 $content
139 );
140 return;
141 }
142
143 $this->pons->out()->outAsyncAsModal(
144 'Translations',
145 (string) $this->back_target,
146 $edit_button,
147 $this->ui_factory->divider()->horizontal(),
148 $prompt,
149 $content
150 );
151 }

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

+ Here is the call graph for this function:

◆ saveTranslations()

ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::saveTranslations ( )
private

Definition at line 172 of file MultiLanguageGUI.php.

172 : void
173 {
174 $form = $this->workflow->asTranslationModal(
175 $this->pons->flow()->getHereAsURI(self::CMD_SAVE_TRANSLATIONS)
176 );
177 $form = $form->withRequest($this->request);
178 if (($data = $form->getData()) === null) {
179 $this->pons->out()->outAsync($form);
180 return;
181 }
182 $this->pons->flow()->ctrl()->redirectToURL(
183 (string) ($this->back_target ?? $this->pons->flow()->getHereAsURI(self::CMD_DEFAULT))
184 );
185 }

References $data.

◆ selectLanguages()

ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::selectLanguages ( )
private

Definition at line 153 of file MultiLanguageGUI.php.

153 : void
154 {
155 $this->pons->out()->outAsync(
156 $this->workflow->asTranslationWorkflow(
157 $this->pons->flow()->getHereAsURI(),
158 $this->back_target ?? $this->pons->flow()->getHereAsURI(self::CMD_DEFAULT)
159 )
160 );
161 }

◆ translateInAsyncModal()

ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::translateInAsyncModal ( )
private

Definition at line 163 of file MultiLanguageGUI.php.

163 : void
164 {
165 $this->pons->out()->outAsync(
166 $this->workflow->asTranslationModal(
167 $this->pons->flow()->getHereAsURI(self::CMD_SAVE_TRANSLATIONS)
168 )
169 );
170 }

Field Documentation

◆ $repository

TranslationsRepository ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::$repository
private

Definition at line 60 of file MultiLanguageGUI.php.

◆ $request

ServerRequestInterface ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::$request
private

Definition at line 62 of file MultiLanguageGUI.php.

◆ $translatable_item

TranslatableItem ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::$translatable_item
private

◆ $translator

Translator ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::$translator
private

Definition at line 39 of file MultiLanguageGUI.php.

◆ $ui_factory

Factory ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::$ui_factory
private

Definition at line 61 of file MultiLanguageGUI.php.

◆ $workflow

TranslationWorkflowForm ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::$workflow
private

Definition at line 63 of file MultiLanguageGUI.php.

◆ CMD_DEFAULT

const ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::CMD_DEFAULT = 'index'

Definition at line 43 of file MultiLanguageGUI.php.

◆ CMD_LANGUAGE_SELECTION

const ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::CMD_LANGUAGE_SELECTION = 'selectLanguages'

Definition at line 47 of file MultiLanguageGUI.php.

◆ CMD_SAVE_LANGUAGE_SELECTION

const ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::CMD_SAVE_LANGUAGE_SELECTION = 'saveLanguages'

Definition at line 51 of file MultiLanguageGUI.php.

◆ CMD_SAVE_TRANSLATIONS

const ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::CMD_SAVE_TRANSLATIONS = 'saveTranslations'

Definition at line 59 of file MultiLanguageGUI.php.

◆ CMD_TRANSLATE_IN_MODAL

const ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI::CMD_TRANSLATE_IN_MODAL = 'translateInAsyncModal'

Definition at line 55 of file MultiLanguageGUI.php.


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