19declare(strict_types=1);
55 private readonly \
ilCtrl $ctrl,
57 private readonly UIFactory $ui_factory,
58 private readonly UIRenderer $ui_renderer,
59 private readonly HTTPService
$http,
63 $this->translations = $this->
object->getObjectProperties()->getPropertyTranslations();
68 $this->supports_content_translation = $content_translation;
80 $this->force_content_translation =
true;
92 $this->
ctrl->getNextClass($this);
93 $cmd = $this->
ctrl->getCmd(self::CMD_LIST_TRANSLATIONS);
94 if (!$this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
95 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_permission'));
96 $this->
ctrl->redirectByClass(get_class($this->
object) .
'GUI');
98 if (in_array($cmd, $commands)) {
104 ?RoundtripModal $lang_modal =
null
106 $this->
lng->loadLanguageModule($this->
object->getType());
117 $this->
object->getObjectProperties(),
118 (
new DataFactory())->uri(
119 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getFormActionByClass(
121 self::CMD_LIST_TRANSLATIONS
127 'table' => $table->getTable()
130 if ($this->translations->migrationMissing()) {
131 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'missing_migration'));
132 $this->tpl->setContent($this->ui_renderer->render($content));
140 if ($this->supports_content_translation) {
144 $this->tpl->setContent($this->ui_renderer->render($content));
149 $modal = $this->getAddLanguageModal()
150 ->withRequest($this->
http->request());
151 $data = $modal->getData();
152 if (
$data ===
null) {
153 $this->listTranslations($modal->withOnLoad($modal->getShowSignal()));
157 $this->translations = $this->translations->withLanguage(
$data[0]);
158 $this->
object->getObjectProperties()->storePropertyTranslations(
161 $this->
ctrl->redirectByClass($this->
ctrl->getCurrentClassPath());
166 $data = $this->getActivateMultilingualityModal()
167 ->withRequest($this->
http->request())
170 if (
$data ===
null) {
174 $this->translations = $this->translations->withLanguage(
177 $this->
object->getTitle(),
178 $this->object->getDescription(),
184 $this->
object->getObjectProperties()->storePropertyTranslations(
187 $this->listTranslations();
192 $this->translations = $this->translations->withDeactivatedContentTranslation();
193 $this->
object->getObjectProperties()->storePropertyTranslations(
197 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'obj_cont_transl_deactivated'),
true);
198 $this->listTranslations();
202 ?RoundtripModal $modal =
null
204 $modal ??= $this->getAddLanguageModal();
206 $this->ui_factory->button()->standard(
207 $this->lng->txt(
'obj_add_language'),
208 $modal->getShowSignal()
217 $ff = $this->ui_factory->input()->field();
218 return $this->ui_factory->modal()->roundtrip(
219 $this->
lng->txt(
'obj_add_language'),
223 'language' => $this->buildLangSelectionInput()
224 ->withRequired(
true),
225 'title' => $ff->text($this->lng->txt(
'title'))
226 ->withRequired(
true),
227 'description' => $ff->textarea($this->lng->txt(
'description'))
228 ])->withAdditionalTransformation(
229 $this->refinery->custom()->transformation(
238 $this->
ctrl->getFormActionByClass(self::class, self::CMD_ADD_TRANSLATION)
244 $lang_var_postfix =
'_multilang';
245 $deactivation_modal_text_tag =
'obj_deactivate_multilang_conf';
246 if (!$this->force_content_translation) {
247 $lang_var_postfix =
'_content_lang';
248 $deactivation_modal_text_tag =
'obj_deactivate_content_transl_conf';
251 if (!$this->force_content_translation && !$this->translations->getContentTranslationActivated()) {
252 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'obj_multilang_title_descr_only'));
255 if (!$this->translations->getContentTranslationActivated()) {
256 $activate_modal = $this->getActivateMultilingualityModal();
258 $this->ui_factory->button()->standard(
259 $this->lng->txt(
'obj_activate' . $lang_var_postfix),
260 $activate_modal->getShowSignal()
263 return $activate_modal;
266 $deactivate_modal = $this->getConfirmDeactivateMultilingualityModal($deactivation_modal_text_tag);
268 $this->ui_factory->button()->standard(
269 $this->lng->txt(
'obj_deactivate' . $lang_var_postfix),
270 $deactivate_modal->getShowSignal()
273 return $deactivate_modal;
278 return $this->ui_factory->modal()->interruptive(
279 $this->
lng->txt(
'confirm'),
280 $this->lng->txt($text_tag),
281 $this->ctrl->getFormActionByClass(self::class, self::CMD_DEACTIVATE_CONTENT_MULTILANG)
282 )->withActionButtonLabel($this->
lng->txt(
'confirm'));
287 return $this->ui_factory->modal()->roundtrip(
288 $this->
lng->txt(
'confirm'),
289 $this->ui_factory->legacy()->content($this->lng->txt(
'obj_select_base_lang')),
291 'lang' => $this->getMasterLangSelectionInput()
293 $this->ctrl->getFormActionByClass(self::class, self::CMD_SAVE_CONTENT_TRANSLATION_ACTIVATION)
299 return $this->ui_factory->input()->field()->select(
300 $this->
lng->txt(
'language'),
301 $this->getArrayWithAddableLanguages()
307 $options = array_reduce(
308 $this->
lng->getInstalledLanguages(),
309 function (array
$c,
string $v): array {
310 $c[$v] = $this->
lng->txt(
"meta_l_{$v}");
316 return $this->ui_factory->input()->field()->select(
317 $this->
lng->txt(
'obj_base_lang'),
320 $this->
refinery->custom()->transformation(
321 fn($v) => in_array($v, array_keys($options)) ? $v : $this->
lng->getDefaultLanguage()
323 )->withValue($this->
user->getLanguage());
328 $enabled_langs = $this->translations->getLanguages();
330 $this->
lng->getInstalledLanguages(),
331 function (array
$c,
string $v) use ($enabled_langs): array {
332 if (!array_key_exists($v, $enabled_langs)) {
333 $c[$v] = $this->
lng->txt(
"meta_l_{$v}");
Builds a Color from either hex- or rgb values.
GUI class for object translation handling.
const CMD_SAVE_CONTENT_TRANSLATION_ACTIVATION
forceContentTranslation()
Some objects like learning modules do not support to translate only the title and the description.
getArrayWithAddableLanguages()
addAddLanguagesToolbarActionAndRetrieveModal(?RoundtripModal $modal=null)
getMasterLangSelectionInput()
listTranslations(?RoundtripModal $lang_modal=null)
Translations $translations
supportContentTranslation(bool $content_translation)
bool $supports_content_translation
const CMD_DEACTIVATE_CONTENT_MULTILANG
getConfirmDeactivateMultilingualityModal(string $text_tag)
bool $force_content_translation
addContentTranslationToolbarActionAndRetrieveModal()
const CMD_LIST_TRANSLATIONS
__construct(private readonly \ilObject $object, private readonly \ilLanguage $lng, private readonly \ilAccess $access, private readonly \ilObjUser $user, private readonly \ilCtrl $ctrl, private readonly \ilGlobalTemplateInterface $tpl, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly HTTPService $http, private readonly Refinery $refinery, private readonly \ilToolbarGUI $toolbar)
buildLangSelectionInput()
deactivateContentTranslation()
getActivateMultilingualityModal()
activateContentTranslation()
const CMD_ADD_TRANSLATION
Class handles translation mode for an object.
Class ilAccessHandler Checks access for ILIAS objects.
Class ilCtrl provides processing control methods.
Class ilObject Basic functions for all objects.
This describes commonalities between the different modals.
An entity that renders components to a string output.
static http()
Fetches the global http state from ILIAS.