19 declare(strict_types=1);
55 private readonly \
ilCtrl $ctrl,
63 $this->translations = $this->
object->getObjectProperties()->getPropertyTranslations();
68 $this->supports_content_translation = $content_translation;
80 $this->force_content_translation =
true;
86 self::CMD_LIST_TRANSLATIONS,
87 self::CMD_ADD_TRANSLATION,
88 self::CMD_SAVE_CONTENT_TRANSLATION_ACTIVATION,
89 self::CMD_DEACTIVATE_CONTENT_MULTILANG
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)) {
106 $this->
lng->loadLanguageModule($this->
object->getType());
117 $this->
object->getObjectProperties(),
119 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass(
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));
150 ->withRequest($this->
http->request());
151 $data = $modal->getData();
157 $this->translations = $this->translations->withLanguage(
$data[0]);
158 $this->
object->getObjectProperties()->storePropertyTranslations(
161 $this->
ctrl->redirectByClass($this->
ctrl->getCurrentClassPath());
167 ->withRequest($this->
http->request())
174 $this->translations = $this->translations->withLanguage(
177 $this->
object->getTitle(),
178 $this->
object->getDescription(),
184 $this->
object->getObjectProperties()->storePropertyTranslations(
192 $this->translations = $this->translations->withDeactivatedContentTranslation();
193 $this->
object->getObjectProperties()->storePropertyTranslations(
197 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'obj_cont_transl_deactivated'),
true);
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'),
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()) {
258 $this->ui_factory->button()->standard(
259 $this->
lng->txt(
'obj_activate' . $lang_var_postfix),
260 $activate_modal->getShowSignal()
263 return $activate_modal;
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->getLinkTargetByClass(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')),
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'),
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}");
This describes commonalities between the different modals.
addAddLanguagesToolbarActionAndRetrieveModal(?RoundtripModal $modal=null)
const CMD_SAVE_CONTENT_TRANSLATION_ACTIVATION
__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)
addContentTranslationToolbarActionAndRetrieveModal()
GUI class for object translation handling.
getConfirmDeactivateMultilingualityModal(string $text_tag)
Class handles translation mode for an object.
activateContentTranslation()
const CMD_LIST_TRANSLATIONS
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
getArrayWithAddableLanguages()
listTranslations(?RoundtripModal $lang_modal=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
bool $supports_content_translation
const CMD_ADD_TRANSLATION
Translations $translations
getMasterLangSelectionInput()
bool $force_content_translation
deactivateContentTranslation()
forceContentTranslation()
Some objects like learning modules do not support to translate only the title and the description...
supportContentTranslation(bool $content_translation)
const CMD_DEACTIVATE_CONTENT_MULTILANG
buildLangSelectionInput()
getActivateMultilingualityModal()