19declare(strict_types=1);
27use Psr\Http\Message\ServerRequestInterface;
69 private ?
URI $back_target =
null,
74 $this->ui_factory = $this->pons->out()->ui()->factory();
75 $this->request = $this->pons->in()->request();
76 $this->translator = $this->pons->i18n();
78 $this->
repository = $this->pons->i18n()->ml()->repository();
81 $DIC->learningObjectMetadata(),
82 $this->pons->out()->ui(),
84 $this->translatable_item =
$translatable_item ?? $this->repository->retrieveCurrent($this->pons),
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')
103 foreach ($translations->get() as $t) {
104 $items[$this->pons->i18n()->translate(
'meta_l_' . $t->getLanguageCode())] = $t->getTranslation();
106 $content = $this->ui_factory->listing()->descriptive(
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)
117 $prompt = $this->ui_factory->prompt()->standard(
118 $this->pons->flow()->getHereAsURI(self::CMD_LANGUAGE_SELECTION)
122 $edit_button = $this->ui_factory
125 $this->translator->translate(
'edit_translations'),
128 ->withOnClick($prompt->getShowSignal());
131 $DIC->toolbar()->addComponent(
135 if ($this->back_target ===
null) {
136 $this->pons->out()->out(
143 $this->pons->out()->outAsyncAsModal(
145 (
string) $this->back_target,
147 $this->ui_factory->divider()->horizontal(),
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)
165 $this->pons->out()->outAsync(
166 $this->workflow->asTranslationModal(
167 $this->pons->flow()->getHereAsURI(self::CMD_SAVE_TRANSLATIONS)
174 $form = $this->workflow->asTranslationModal(
175 $this->pons->flow()->getHereAsURI(self::CMD_SAVE_TRANSLATIONS)
177 $form = $form->withRequest($this->request);
178 if ((
$data = $form->getData()) ===
null) {
179 $this->pons->out()->outAsync($form);
182 $this->pons->flow()->ctrl()->redirectToURL(
183 (
string) ($this->back_target ?? $this->pons->flow()->getHereAsURI(self::CMD_DEFAULT))
191 $cmd = $this->pons->flow()->getCommand(self::CMD_TRANSLATE_IN_MODAL);
194 default => $this->$cmd(),
Builds a Color from either hex- or rgb values.
The scope of this class is split ilias-conform URI's into components.
const CMD_TRANSLATE_IN_MODAL
const CMD_LANGUAGE_SELECTION
TranslationWorkflowForm $workflow
const CMD_SAVE_TRANSLATIONS
ServerRequestInterface $request
const CMD_SAVE_LANGUAGE_SELECTION
TranslatableItem $translatable_item
TranslationsRepository $repository
__construct(Pons $pons, ?TranslatableItem $translatable_item=null, private ?URI $back_target=null,)
This is how the factory for UI elements looks.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc