ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilFooterTranslationGUI Class Reference
+ Collaboration diagram for ilFooterTranslationGUI:

Public Member Functions

 __construct (private Container $dic, private Translator $translator, private ilObjFooterUIHandling $ui_handling, private TranslatableItem $translatable_item, private ?URI $back_target=null)
 
 executeCommand ()
 

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'
 

Private Member Functions

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

Private Attributes

TranslationsRepository $repository
 
Factory $ui_factory
 
ilCtrlInterface $ctrl
 
ServerRequestInterface $request
 
TranslationWorkflowForm $workflow
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFooterTranslationGUI::__construct ( private Container  $dic,
private Translator  $translator,
private ilObjFooterUIHandling  $ui_handling,
private TranslatableItem  $translatable_item,
private ?URI  $back_target = null 
)

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

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

61  {
62  $this->ui_factory = $this->dic->ui()->factory();
63  $this->ctrl = $this->dic->ctrl();
64  $this->request = $this->dic->http()->request();
65 
67  $this->dic->database()
68  );
69 
70  $this->workflow = new TranslationWorkflowForm(
71  $this->dic->learningObjectMetadata(),
72  $this->dic->ui(),
74  $this->translatable_item,
75  );
76  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:17
TranslationsRepository $repository
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilFooterTranslationGUI::executeCommand ( )

Definition at line 173 of file class.ilFooterTranslationGUI.php.

References ILIAS\Repository\ctrl().

173  : void
174  {
175  $this->ui_handling->requireReadable();
176 
177  $next_class = $this->ctrl->getNextClass($this) ?? '';
178  $cmd = $this->ctrl->getCmd(self::CMD_DEFAULT);
179 
180  switch ($cmd) {
181  case self::CMD_DEFAULT:
182  case self::CMD_LANGUAGE_SELECTION:
183  case self::CMD_SAVE_LANGUAGE_SELECTION:
184  case self::CMD_TRANSLATE_IN_MODAL:
185  case self::CMD_SAVE_TRANSLATIONS:
186  default:
187  $this->ui_handling->backToMainTab();
188  $this->ui_handling->requireWritable();
189  $this->$cmd();
190  break;
191  }
192  }
+ Here is the call graph for this function:

◆ index()

ilFooterTranslationGUI::index ( )
private

Definition at line 78 of file class.ilFooterTranslationGUI.php.

References ILIAS\UI\examples\Deck\repository().

78  : void
79  {
80  // LISTING
81  $translations = $this->repository->get($this->translatable_item);
82  if ($translations->get() === []) {
83  $content = $this->ui_factory->messageBox()->info(
84  $this->translator->translate('no_translations')
85  );
86  } else {
87  $items = [];
88  foreach ($translations->get() as $t) {
89  $items[$this->translator->translate('meta_l_' . $t->getLanguageCode())] = $t->getTranslation();
90  }
91  $content = $this->ui_factory->listing()->descriptive(
92  $items
93  );
94  $content = $this->back_target === null ? $this->ui_factory->panel()->secondary()->legacy(
95  $this->translator->translate('translations'),
96  $this->ui_factory->legacy(
97  $this->ui_handling->render($content)
98  )
99  ) : $content;
100  }
101 
102  $prompt = $this->ui_factory->prompt()->standard(
103  $this->ui_handling->getHereAsURI(self::CMD_LANGUAGE_SELECTION)
104  );
105 
106  // Edit Button
107  $edit_button = $this->ui_factory
108  ->button()
109  ->standard(
110  $this->translator->translate('edit_translations'),
111  '#'
112  )
113  ->withOnClick($prompt->getShowSignal());
114 
115  $this->dic->toolbar()->addComponent(
116  $edit_button
117  );
118 
119  if ($this->back_target === null) {
120  $this->ui_handling->out(
121  $prompt,
122  $content
123  );
124  return;
125  }
126 
127  $this->ui_handling->outAsyncAsModal(
128  'Translations',
129  (string) $this->back_target,
130  $edit_button,
131  $this->ui_factory->divider()->horizontal(),
132  $prompt,
133  $content
134  );
135  }
repository()
description: > Example for rendering a repository card
Definition: repository.php:17
+ Here is the call graph for this function:

◆ saveTranslations()

ilFooterTranslationGUI::saveTranslations ( )
private

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

References $data, and ILIAS\Repository\ctrl().

156  : void
157  {
158  $form = $this->workflow->asTranslationModal(
159  $this->ui_handling->getHereAsURI(self::CMD_SAVE_TRANSLATIONS)
160  );
161  $form = $form->withRequest($this->request);
162  if (($data = $form->getData()) === null) {
163  $this->ui_handling->outAsync($form);
164  return;
165  }
166  $this->ctrl->redirectToURL(
167  (string) ($this->back_target ?? $this->ui_handling->getHereAsURI(self::CMD_DEFAULT))
168  );
169  }
+ Here is the call graph for this function:

◆ selectLanguages()

ilFooterTranslationGUI::selectLanguages ( )
private

Definition at line 137 of file class.ilFooterTranslationGUI.php.

137  : void
138  {
139  $this->ui_handling->outAsync(
140  $this->workflow->asTranslationWorkflow(
141  $this->ui_handling->getHereAsURI(),
142  $this->back_target ?? $this->ui_handling->getHereAsURI(self::CMD_DEFAULT)
143  )
144  );
145  }

◆ translateInAsyncModal()

ilFooterTranslationGUI::translateInAsyncModal ( )
private

Definition at line 147 of file class.ilFooterTranslationGUI.php.

147  : void
148  {
149  $this->ui_handling->outAsync(
150  $this->workflow->asTranslationModal(
151  $this->ui_handling->getHereAsURI(self::CMD_SAVE_TRANSLATIONS)
152  )
153  );
154  }

Field Documentation

◆ $ctrl

ilCtrlInterface ilFooterTranslationGUI::$ctrl
private

Definition at line 51 of file class.ilFooterTranslationGUI.php.

◆ $repository

TranslationsRepository ilFooterTranslationGUI::$repository
private

Definition at line 49 of file class.ilFooterTranslationGUI.php.

Referenced by __construct().

◆ $request

ServerRequestInterface ilFooterTranslationGUI::$request
private

Definition at line 52 of file class.ilFooterTranslationGUI.php.

◆ $ui_factory

Factory ilFooterTranslationGUI::$ui_factory
private

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

◆ $workflow

TranslationWorkflowForm ilFooterTranslationGUI::$workflow
private

Definition at line 53 of file class.ilFooterTranslationGUI.php.

◆ CMD_DEFAULT

const ilFooterTranslationGUI::CMD_DEFAULT = 'index'

◆ CMD_LANGUAGE_SELECTION

const ilFooterTranslationGUI::CMD_LANGUAGE_SELECTION = 'selectLanguages'

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

◆ CMD_SAVE_LANGUAGE_SELECTION

const ilFooterTranslationGUI::CMD_SAVE_LANGUAGE_SELECTION = 'saveLanguages'

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

◆ CMD_SAVE_TRANSLATIONS

const ilFooterTranslationGUI::CMD_SAVE_TRANSLATIONS = 'saveTranslations'

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

◆ CMD_TRANSLATE_IN_MODAL

const ilFooterTranslationGUI::CMD_TRANSLATE_IN_MODAL = 'translateInAsyncModal'

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