34 private const STEP =
'step';
38 private readonly \ilLanguage
$lng;
43 private readonly \ILIAS\UI\Component\Input\Field\Factory
$fields;
45 private readonly \ILIAS\UI\Component\Prompt\State\Factory
$states;
54 $this->request = $DIC->http()->request();
56 $this->ui_factory = $ui->factory();
57 $this->
lng = $DIC->language();
58 $this->translations = $repository->get($item);
59 $this->fields = $this->ui_factory->input()->field();
60 $this->states = $this->ui_factory->prompt()->state();
67 $step = $this->request->getQueryParams()[self::STEP] ?? null;
70 $here_uri->
withParameter(self::STEP, self::STEP_SELECTED_LNGS)
75 return $this->states->show($language_slection);
76 case self::STEP_SELECTED_LNGS:
78 $data = $language_slection->withRequest($this->request)->getData();
82 $here_uri->
withParameter(self::STEP, self::STEP_SAVE_TRANSLATIONS),
86 case self::STEP_SAVE_TRANSLATIONS:
87 $active_language_keys = [];
88 foreach ($this->translations->getLanguageKeys() as $language_key) {
89 $active_language_keys[$language_key] =
true;
92 $tranlation_form = $this
94 $here_uri->
withParameter(self::STEP, self::STEP_SAVE_TRANSLATIONS),
97 ->withRequest($this->request);
99 $data = $tranlation_form->getData();
100 if (
$data !== null) {
104 return $this->states->show($tranlation_form);
111 return $this->ui_factory->input()->container()->form()->standard(
112 (
string) $form_target,
114 )->withAdditionalTransformation(
115 $this->
refinery->custom()->transformation(
function ($value) {
116 $this->
repository->store($this->translations);
124 $default_value = match (
true) {
125 ($this->item instanceof
GroupDTO) => $this->item->getTitle(),
126 ($this->item instanceof
EntryDTO) => $this->item->getTitle(),
131 foreach ($this->lom_services->dataHelper()->getAllLanguages() as $language) {
132 $languages[$language->value()] = $language->presentableLabel();
136 foreach ($language_keys as $language_key => $active) {
140 $translation = $this->translations->getLanguageCode($language_key)?->getTranslation();
141 $language_title = $languages[$language_key] ?? null;
142 if ($language_title === null) {
145 $inputs[$language_key] = $this->fields
146 ->text($language_title)
147 ->withRequired($required)
149 $translation ?? $default_value
151 ->withAdditionalTransformation(
152 $this->
refinery->custom()->transformation(
function ($value) use ($language_key) {
153 $this->translations->add(
154 $this->
repository->blank($this->item, $language_key, $value)
167 return $this->ui_factory->input()->container()->form()->standard(
168 (
string) $form_target,
170 )->withAdditionalTransformation(
171 $this->
refinery->custom()->transformation(
function ($value) {
172 $this->
repository->store($this->translations);
181 $all_languages = $this->lom_services->dataHelper()->getAllLanguages();
182 $installed_languages = $this->
lng->getInstalledLanguages();
184 foreach ($all_languages as $language) {
185 $language_code = $language->value();
186 if (!$this->all_languages && !in_array($language_code, $installed_languages,
true)) {
189 $inputs[$language_code] = $this->fields
190 ->checkbox($language->presentableLabel())
192 $this->translations->getLanguageCode($language_code) !== null
194 $this->
refinery->custom()->transformation(
function ($value) use ($language_code) {
196 $this->translations->remove($language_code);
198 $this->translations->add(
202 $this->translations->getLanguageCode($language_code)?->getTranslation() ??
'' 218 foreach ($this->
lng->getInstalledLanguages() as $installed_language) {
219 $languages[$installed_language] =
true;
222 return $this->ui_factory->modal()->roundtrip(
223 $this->
lng->txt(
'translations'),
228 $this->
refinery->custom()->transformation(
function ($value) {
229 $this->
repository->store($this->translations);
repository()
description: > Example for rendering a repository card
Provides fluid interface to RBAC services.
This is how the factory for UI elements looks.
The scope of this class is split ilias-conform URI's into components.
withParameter(string $key, $value)
Get URI with modified parameters.