27use Psr\Http\Message\ServerRequestInterface;
39 private const STEP =
'step';
49 private readonly \ilLanguage
$lng;
50 private readonly ServerRequestInterface
$request;
54 private readonly \ILIAS\UI\Component\Input\Field\Factory
$fields;
56 private readonly \ILIAS\UI\Component\Prompt\State\Factory
$states;
65 $this->request =
$DIC->http()->request();
67 $this->ui_factory = $ui->
factory();
68 $this->
lng = $DIC->language();
69 $this->translations = $repository->get($item);
70 $this->fields = $this->ui_factory->input()->field();
71 $this->states = $this->ui_factory->prompt()->state();
78 $step = $this->request->getQueryParams()[self::
STEP] ?? null;
81 $here_uri->
withParameter(self::STEP, self::STEP_SELECTED_LNGS)
86 return $this->states->show($language_slection);
89 $data = $language_slection->withRequest($this->request)->getData();
93 $here_uri->
withParameter(self::STEP, self::STEP_SAVE_TRANSLATIONS),
98 $active_language_keys = [];
99 foreach ($this->translations->getLanguageKeys() as $language_key) {
100 $active_language_keys[$language_key] =
true;
103 $tranlation_form = $this
104 ->getTranslationForm(
105 $here_uri->
withParameter(self::STEP, self::STEP_SAVE_TRANSLATIONS),
106 $active_language_keys
108 ->withRequest($this->request);
110 $data = $tranlation_form->getData();
111 if (
$data !==
null) {
115 return $this->states->show($tranlation_form);
121 $inputs = $this->getTranslationInputs($language_keys);
122 return $this->ui_factory->input()->container()->form()->standard(
123 (
string) $form_target,
125 )->withAdditionalTransformation(
126 $this->
refinery->custom()->transformation(function ($value) {
127 $this->
repository->store($this->translations);
135 $default_value = $this->item->getTitle();
138 foreach ($this->lom_services->dataHelper()->getAllLanguages() as $language) {
139 $languages[$language->value()] = $language->presentableLabel();
143 foreach ($language_keys as $language_key => $active) {
147 $translation = $this->translations->getLanguageCode($language_key)?->getTranslation();
148 $language_title = $languages[$language_key] ??
null;
149 if ($language_title ===
null) {
152 $inputs[$language_key] = $this->fields
153 ->text($language_title)
154 ->withRequired($required)
156 $translation ?? $default_value
158 ->withAdditionalTransformation(
159 $this->
refinery->custom()->transformation(function ($value) use ($language_key) {
160 $this->translations->add(
161 $this->
repository->blank($this->item, $language_key, $value)
172 $inputs = $this->getLanguageSelectionInputs();
174 return $this->ui_factory->input()->container()->form()->standard(
175 (
string) $form_target,
177 )->withAdditionalTransformation(
178 $this->
refinery->custom()->transformation(function ($value) {
179 $this->
repository->store($this->translations);
188 $all_languages = $this->lom_services->dataHelper()->getAllLanguages();
189 $installed_languages = $this->
lng->getInstalledLanguages();
191 foreach ($all_languages as $language) {
192 $language_code = $language->value();
193 if (!$this->all_languages && !in_array($language_code, $installed_languages,
true)) {
196 $inputs[$language_code] = $this->fields
197 ->checkbox($language->presentableLabel())
199 $this->translations->getLanguageCode($language_code) !==
null
200 )->withAdditionalTransformation(
201 $this->
refinery->custom()->transformation(function ($value) use ($language_code) {
203 $this->translations->remove($language_code);
205 $this->translations->add(
209 $this->translations->getLanguageCode($language_code)?->getTranslation() ??
''
225 foreach ($this->
lng->getInstalledLanguages() as $installed_language) {
226 $languages[$installed_language] =
true;
229 return $this->ui_factory->modal()->roundtrip(
230 $this->
lng->txt(
'translations'),
232 $this->getTranslationInputs($languages,
false),
234 )->withAdditionalTransformation(
235 $this->
refinery->custom()->transformation(function ($value) {
236 $this->
repository->store($this->translations);
Provides fluid interface to RBAC services.
factory()
Get the factory that crafts UI components.
Builds a Color from either hex- or rgb values.
The scope of this class is split ilias-conform URI's into components.
withParameter(string $key, $value)
Get URI with modified parameters.
This is how the factory for UI elements looks.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...