ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilObjLanguageFolderGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
35{
41
45 public function __construct(?array $a_data, int $a_id, bool $a_call_by_reference)
46 {
47 $this->type = "lngf";
48 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
49 $this->lng->loadLanguageModule("lng");
50 $this->df = new ILIAS\Data\Factory();
51
52 $here_uri = $this->df->uri($this->request->getUri()->__toString());
53 $url_builder = new URLBuilder($here_uri);
54 $query_params_namespace = ['language_folder'];
55 [$url_builder, $action_parameter_token, $row_id_token] =
57 $query_params_namespace,
58 "table_action", //this is the actions's parameter name
59 "obj_ids" //this is the parameter name to be used for row-ids
60 );
61
62 $this->url_builder = $url_builder;
63 $this->action_token = $action_parameter_token;
64 $this->id_token = $row_id_token;
65
67 $folder = $this->object;
68 $this->languageFolderTable = new ilLanguageFolderTable($folder, $url_builder, $action_parameter_token, $row_id_token);
69 }
70
74 public function viewObject(): void
75 {
76 global $DIC;
77
78 $table = $this->languageFolderTable->getTable();
79
80 if ($this->checkPermissionBool("write")) {
81 // refresh
82 $ids = $this->confirmRefreshObject();
83 $modal = $this->buildConfirmModal(
84 $ids,
85 'refresh_languages',
86 'confirmRefresh',
87 'lang_refresh_confirm_selected',
88 "lang_refresh_confirm_info"
89 );
90 $refresh = $this->ui_factory->button()->standard(
91 $this->lng->txt("refresh_languages"),
92 ''
93 )->withOnClick($modal->getShowSignal());
94
95 $this->toolbar->addComponent($modal);
96 $this->toolbar->addComponent($refresh);
97
98 // check languages
99 $check = $this->ui_factory->button()->standard(
100 $this->lng->txt("check_languages"),
101 $this->getUrl("checkLanguage")
102 );
103 $this->toolbar->addComponent($check);
104 }
105
106 $ilClientIniFile = $DIC["ilClientIniFile"];
107 if ($ilClientIniFile->variableExists("system", "LANGUAGE_LOG")) {
108 $download = $this->ui_factory->button()->standard(
109 $this->lng->txt("lng_download_deprecated"),
110 $this->ctrl->getLinkTarget($this, "listDeprecated")
111 );
112 $this->toolbar->addComponent($download);
113 }
114
115 if ($this->checkPermissionBool("write")) {
116 $modal_on = $this->ui_factory->modal()->interruptive(
117 'ON',
118 $this->lng->txt("lng_enable_language_detection"),
119 $this->ctrl->getFormActionByClass(self::class, "enableLanguageDetection")
120 )
121 ->withActionButtonLabel($this->lng->txt('ok'));
122 $modal_off = $this->ui_factory->modal()->interruptive(
123 'OFF',
124 $this->lng->txt("lng_disable_language_detection"),
125 $this->ctrl->getFormActionByClass(self::class, "disableLanguageDetection")
126 )
127 ->withActionButtonLabel($this->lng->txt('ok'));
128 $toggleButton = $this->ui_factory->button()->toggle(
129 $this->lng->txt("language_detection"),
130 $modal_on->getShowSignal(),
131 $modal_off->getShowSignal(),
132 (bool) ($this->settings->get("lang_detection"))
133 )
134 ->withAriaLabel($this->lng->txt("lng_switch_language_detection"));
135 $this->toolbar->addComponent($modal_on);
136 $this->toolbar->addComponent($modal_off);
137 $this->toolbar->addComponent($toggleButton);
138 }
139
140 $this->tpl->setContent($this->ui_renderer->render($table->withRequest($this->request)));
141 }
142
143 protected function buildConfirmModal(array $ids, string $title, string $action, string $text, string $add_text = ''): ILIAS\UI\Implementation\Component\Modal\Interruptive
144 {
146 $title = $this->lng->txt($title);
147 $items = [];
148
149 if (!empty($ids)) {
150 $message = $this->lng->txt($text);
151
152 $some_changed = false;
153 foreach ($ids as $id) {
154 $lang_key = ilObject::_lookupTitle((int) $id);
155 $lang_title = $this->lng->txt("meta_l_" . $lang_key);
156 $last_change = ilObjLanguage::_getLastLocalChange($lang_key);
157 if (!empty($last_change)) {
158 $some_changed = true;
159 $lang_title .= " (" . $this->lng->txt("last_change") . " "
161 $last_change,
163 'UTC'
164 )) . ")";
165 }
166 $items[] = $f->modal()->interruptiveItem()->standard($id, $lang_title);
167 }
168 $form_action = $this->getUrl($action, $ids);
169
170 if ($some_changed) {
171 $message .= "<br />" . $this->lng->txt($add_text);
172 }
173 } else {
174 $message = $this->lng->txt("no_checkbox");
175 $form_action = '';
176 }
177 $modal = $f->modal()->interruptive(
178 $title,
179 $message,
181 );
182 if (!empty($items)) {
183 $modal = $modal->withAffectedItems($items)
184 ->withActionButtonLabel($title);
185 } else {
186 $modal = $modal->withActionButtonLabel($this->lng->txt('ok'));
187 }
188 return $modal;
189 }
190
194 public function installObject(array $ids): void
195 {
196 $this->checkPermission("write");
197 $this->lng->loadLanguageModule("meta");
198
199 foreach ($ids as $obj_id) {
200 $langObj = new ilObjLanguage((int) $obj_id);
201 $key = $langObj->install();
202
203 if ($key !== "") {
204 $lang_installed[] = $key;
205 }
206
207 unset($langObj);
208 }
209
210 if (isset($lang_installed)) {
211 if (count($lang_installed) === 1) {
212 $this->data = $this->lng->txt("meta_l_" . $lang_installed[0]) . " " . strtolower($this->lng->txt("installed")) . ".";
213 } else {
214 $langnames = [];
215 foreach ($lang_installed as $lang_key) {
216 $langnames[] = $this->lng->txt("meta_l_" . $lang_key);
217 }
218 $this->data = implode(", ", $langnames) . " " . strtolower($this->lng->txt("installed")) . ".";
219 }
220 } else {
221 $this->data = $this->lng->txt("languages_already_installed");
222 }
223
224 $this->out();
225 }
226
227
231 public function installLocalObject(array $ids): void
232 {
233 $this->checkPermission("write");
234 $this->lng->loadLanguageModule("meta");
235
236 foreach ($ids as $obj_id) {
237 $langObj = new ilObjLanguage((int) $obj_id);
238 $key = $langObj->install();
239
240 if ($key !== "") {
241 $lang_installed[] = $key;
242 }
243
244 unset($langObj);
245
246 $langObj = new ilObjLanguage((int) $obj_id);
247 $key = $langObj->install("local");
248
249 if ($key !== "") {
250 $local_installed[] = $key;
251 }
252
253 unset($langObj);
254 }
255
256 if (isset($lang_installed)) {
257 if (count($lang_installed) === 1) {
258 $this->data = $this->lng->txt("meta_l_" . $lang_installed[0]) . " " . strtolower($this->lng->txt("installed")) . ".";
259 } else {
260 $langnames = [];
261 foreach ($lang_installed as $lang_key) {
262 $langnames[] = $this->lng->txt("meta_l_" . $lang_key);
263 }
264 $this->data = implode(", ", $langnames) . " " . strtolower($this->lng->txt("installed")) . ".";
265 }
266 }
267
268 if (isset($local_installed)) {
269 if (count($local_installed) === 1) {
270 $this->data .= " " . $this->lng->txt("meta_l_" . $local_installed[0]) . " " . $this->lng->txt("local_language_file") . " " . strtolower($this->lng->txt("installed")) . ".";
271 } else {
272 $langnames = [];
273 foreach ($local_installed as $lang_key) {
274 $langnames[] = $this->lng->txt("meta_l_" . $lang_key);
275 }
276 $this->data .= " " . implode(", ", $langnames) . " " . $this->lng->txt("local_language_files") . " " . strtolower($this->lng->txt("installed")) . ".";
277 }
278 } else {
279 $this->data .= " " . $this->lng->txt("local_languages_already_installed");
280 }
281
282 $this->out();
283 }
284
285
289 public function uninstallObject(array $ids): void
290 {
291 $this->checkPermission('write');
292 $this->lng->loadLanguageModule("meta");
293
294 $sys_lang = false;
295 $usr_lang = false;
296
297 // uninstall all selected languages
298 foreach ($ids as $obj_id) {
299 $langObj = new ilObjLanguage((int) $obj_id);
300 if (!($sys_lang = $langObj->isSystemLanguage()) && !($usr_lang = $langObj->isUserLanguage())) {
301 $key = $langObj->uninstall();
302 if ($key !== "") {
303 $lang_uninstalled[] = $key;
304 }
305 }
306 unset($langObj);
307 }
308
309 // generate output message
310 if (isset($lang_uninstalled)) {
311 if (count($lang_uninstalled) === 1) {
312 $this->data = $this->lng->txt("meta_l_" . $lang_uninstalled[0]) . " " . $this->lng->txt("uninstalled");
313 } else {
314 $langnames = [];
315 foreach ($lang_uninstalled as $lang_key) {
316 $langnames[] = $this->lng->txt("meta_l_" . $lang_key);
317 }
318
319 $this->data = implode(", ", $langnames) . " " . $this->lng->txt("uninstalled");
320 }
321 } elseif ($sys_lang) {
322 $this->data = $this->lng->txt("cannot_uninstall_systemlanguage");
323 } elseif ($usr_lang) {
324 $this->data = $this->lng->txt("cannot_uninstall_language_in_use");
325 } else {
326 $this->data = $this->lng->txt("languages_already_uninstalled");
327 }
328
329 $this->out();
330 }
331
332
336 public function uninstallChangesObject(array $ids): void
337 {
338 $this->checkPermission("write");
339
340 $this->data = $this->lng->txt("selected_languages_updated");
341 $this->lng->loadLanguageModule("meta");
342 $refreshed = [];
343
344 foreach ($ids as $id) {
345 $langObj = new ilObjLanguage((int) $id, false);
346
347 if ($langObj->isInstalled()) {
348 if ($langObj->check()) {
349 $langObj->flush("all");
350 $langObj->insert();
351 $langObj->setTitle($langObj->getKey());
352 $langObj->setDescription("installed");
353 $langObj->update();
354 $refreshed[] = $langObj->getKey();
355 }
356 $this->data .= "<br />" . $this->lng->txt("meta_l_" . $langObj->getKey());
357 }
358
359 unset($langObj);
360 }
362 $this->out();
363 }
364
368 public function refreshObject(): void
369 {
370 $this->checkPermission("write");
371
373 $this->data = $this->lng->txt("languages_updated");
374 $this->out();
375 }
376
380 public function refreshSelectedObject(array $ids): void
381 {
382 $this->checkPermission("write");
383 $this->data = $this->lng->txt("selected_languages_updated");
384 $this->lng->loadLanguageModule("meta");
385
386 $refreshed = [];
387 foreach ($ids as $id) {
388 $langObj = new ilObjLanguage((int) $id, false);
389 if ($langObj->refresh()) {
390 $refreshed[] = $langObj->getKey();
391 $this->data .= "<br />" . $this->lng->txt("meta_l_" . $langObj->getKey());
392 }
393 unset($langObj);
394 }
395
397 $this->out();
398 }
399
403 public function setUserLanguageObject(array $ids): void
404 {
405 global $DIC;
406 $ilUser = $DIC->user();
407
408 $this->checkPermission("write");
409 $this->lng->loadLanguageModule("meta");
410
411 #require_once "./Services/User/classes/class.ilObjUser.php";
412
413
414 if (count($ids) !== 1) {
415 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("choose_only_one_language") . "<br/>" . $this->lng->txt("action_aborted"), true);
416 $this->ctrl->redirect($this, "view");
417 }
418
419 $obj_id = current($ids);
420
421 $newUserLangObj = new ilObjLanguage((int) $obj_id);
422
423 if ($newUserLangObj->isUserLanguage()) {
424 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("meta_l_" . $newUserLangObj->getKey()) . " " . $this->lng->txt("is_already_your") . " " . $this->lng->txt("user_language") . "<br/>" . $this->lng->txt("action_aborted"), true);
425 $this->ctrl->redirect($this, "view");
426 }
427
428 if (!$newUserLangObj->isInstalled()) {
429 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("meta_l_" . $newUserLangObj->getKey()) . " " . $this->lng->txt("language_not_installed") . "<br/>" . $this->lng->txt("action_aborted"), true);
430 $this->ctrl->redirect($this, "view");
431 }
432
433 $curUser = new ilObjUser($ilUser->getId());
434 $curUser->setLanguage($newUserLangObj->getKey());
435 $curUser->update();
436
437 $this->data = $this->lng->txt("user_language") . " " . $this->lng->txt("changed_to") . " " . $this->lng->txt("meta_l_" . $newUserLangObj->getKey()) . ".";
438
439 $this->out();
440 }
441
442
446 public function setSystemLanguageObject(array $ids): void
447 {
448 $this->checkPermission("write");
449 $this->lng->loadLanguageModule("meta");
450
451
452 if (count($ids) !== 1) {
453 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("choose_only_one_language") . "<br/>" . $this->lng->txt("action_aborted"), true);
454 $this->ctrl->redirect($this, "view");
455 }
456
457 $obj_id = current($ids);
458
459 $newSysLangObj = new ilObjLanguage((int) $obj_id);
460
461 if ($newSysLangObj->isSystemLanguage()) {
462 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("meta_l_" . $newSysLangObj->getKey()) . " " . $this->lng->txt("is_already_your") . " " . $this->lng->txt("system_language") . "<br/>" . $this->lng->txt("action_aborted"), true);
463 $this->ctrl->redirect($this, "view");
464 }
465
466 if (!$newSysLangObj->isInstalled()) {
467 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("meta_l_" . $newSysLangObj->getKey()) . " " . $this->lng->txt("language_not_installed") . "<br/>" . $this->lng->txt("action_aborted"), true);
468 $this->ctrl->redirect($this, "view");
469 }
470
471 $this->ilias->setSetting("language", $newSysLangObj->getKey());
472
473 // update ini-file
474 $this->ilias->ini->setVariable("language", "default", $newSysLangObj->getKey());
475 $this->ilias->ini->write();
476
477 $this->data = $this->lng->txt("system_language") . " " . $this->lng->txt("changed_to") . " " . $this->lng->txt("meta_l_" . $newSysLangObj->getKey()) . ".";
478
479 $this->out();
480 }
481
485 public function checkLanguageObject(): void
486 {
487 $this->checkPermission("write");
488 $this->data = $this->object->checkAllLanguages();
489 $this->out();
490 }
491
492 public function out(): void
493 {
494 $this->tpl->setOnScreenMessage('info', $this->data, true);
495 $this->ctrl->redirect($this, "view");
496 }
497
498 public function getAdminTabs(): void
499 {
500 $this->getTabs();
501 }
502
506 protected function getTabs(): void
507 {
508 if ($this->checkPermissionBool("read")) {
509 $this->tabs_gui->addTab("settings", $this->lng->txt("settings"), $this->ctrl->getLinkTarget($this, "view"));
510 }
511
512 if ($this->checkPermissionBool("edit_permission")) {
513 $this->tabs_gui->addTab("perm_settings", $this->lng->txt("perm_settings"), $this->ctrl->getLinkTargetByClass(array(self::class,"ilpermissiongui"), "perm"));
514 }
515 }
516
517 public function executeCommand(): void
518 {
519 // always check read permission, needed write permissions are checked in the *Object functions
520 $this->checkPermission("read", "", $this->type, $this->ref_id);
521
522 $next_class = $this->ctrl->getNextClass($this);
523 $cmd = $this->ctrl->getCmd();
524 $this->prepareOutput();
525
526 switch ($next_class) {
527 case "ilpermissiongui":
528 $perm_gui = new ilPermissionGUI($this);
529 $this->tabs_gui->activateTab("perm_settings");
530 $this->ctrl->forwardCommand($perm_gui);
531 break;
532
533 default:
534 $this->tabs_gui->activateTab("settings");
535
536 if ($action = $this->getCommandFromQueryToken($this->action_token->getName())) {
537 $this->checkPermission("write");
538 $this->lng->loadLanguageModule("meta");
541 switch ($action) {
542 case 'confirmRefresh':
543 $ids = $this->confirmRefreshObject();
544 $this->refreshSelectedObject($ids);
545 break;
546 case 'checkLanguage':
547 $this->checkLanguageObject();
548 break;
549 case 'refresh':
550 $ids = $this->getIdsFromQueryToken();
551 if (current($ids) === 'ALL_OBJECTS') {
552 array_shift($ids);
553 $languages = ilObject::_getObjectsByType("lng");
554 foreach ($languages as $lang) {
555 $langObj = new ilObjLanguage((int) $lang["obj_id"], false);
556 if ($langObj->isInstalled()) {
557 $ids[] = (string) $lang["obj_id"];
558 }
559 }
560 }
561 $modal = $this->buildConfirmModal(
562 $ids,
563 $action,
564 'refreshConfirmed',
565 'lang_refresh_confirm_selected',
566 "lang_refresh_confirm_info"
567 );
568 echo($r->renderAsync([$modal]));
569 exit();
570 case 'refreshConfirmed':
571 $ids = $this->getIdsFromQueryToken();
572 $this->refreshSelectedObject($ids);
573 break;
574 case 'uninstall':
575 $ids = $this->getIdsFromQueryToken();
576 if (current($ids) === 'ALL_OBJECTS') {
577 array_shift($ids);
578 $languages = ilObject::_getObjectsByType("lng");
579 foreach ($languages as $lang) {
580 $langObj = new ilObjLanguage((int) $lang["obj_id"], false);
581 if ($langObj->isInstalled()) {
582 $ids[] = (string) $lang["obj_id"];
583 }
584 }
585 }
586 $modal = $this->buildConfirmModal(
587 $ids,
588 $action,
589 'uninstallConfirmed',
590 'lang_uninstall_confirm'
591 );
592 echo($r->renderAsync([$modal]));
593 exit();
594 case 'uninstallConfirmed':
595 $ids = $this->getIdsFromQueryToken();
596 $this->uninstallObject($ids);
597 break;
598 case 'install':
599 $ids = $this->getIdsFromQueryToken();
600 if (current($ids) === 'ALL_OBJECTS') {
601 array_shift($ids);
602 $languages = ilObject::_getObjectsByType("lng");
603 foreach ($languages as $lang) {
604 $langObj = new ilObjLanguage((int) $lang["obj_id"], false);
605 if (!$langObj->isInstalled()) {
606 $ids[] = (string) $lang["obj_id"];
607 }
608 }
609 }
610 $this->installObject($ids);
611 break;
612 case 'install_local':
613 $ids = $this->getIdsFromQueryToken();
614 if (current($ids) === 'ALL_OBJECTS') {
615 array_shift($ids);
616 $languages = ilObject::_getObjectsByType("lng");
617 foreach ($languages as $lang) {
618 $ids[] = (string) $lang["obj_id"];
619 }
620 }
621 $this->installLocalObject($ids);
622 break;
623 case 'lang_uninstall_changes':
624 $ids = $this->getIdsFromQueryToken();
625 if (current($ids) === 'ALL_OBJECTS') {
626 array_shift($ids);
627 $languages = ilObject::_getObjectsByType("lng");
628 foreach ($languages as $lang) {
629 $langObj = new ilObjLanguage((int) $lang["obj_id"], false);
630 if ($langObj->isInstalled()) {
631 $ids[] = (string) $lang["obj_id"];
632 }
633 }
634 }
635 $modal = $this->buildConfirmModal(
636 $ids,
637 $action,
638 'uninstallChanges',
639 'lang_uninstall_changes_confirm'
640 );
641 echo($r->renderAsync([$modal]));
642 exit();
643 case 'uninstallChanges':
644 $ids = $this->getIdsFromQueryToken();
645 $this->uninstallChangesObject($ids);
646 break;
647 case 'setSystemLanguage':
648 $ids = $this->getIdsFromQueryToken();
649 $this->setSystemLanguageObject($ids);
650 break;
651 case 'setUserLanguage':
652 $ids = $this->getIdsFromQueryToken();
653 $this->setUserLanguageObject($ids);
654 break;
655 case 'edit':
656 $ids = $this->getIdsFromQueryToken();
657 $this->editFolderObject($ids);
658 break;
659 }
660 }
661 if (!$cmd) {
662 $cmd = "view";
663 }
664 $cmd .= "Object";
665 $this->$cmd();
666
667 break;
668 }
669 }
670
671 protected function getCommandFromQueryToken(string $param): ?string
672 {
673 if (!$this->request_wrapper->has($param)) {
674 return null;
675 }
676 $trafo = $this->refinery->byTrying([
677 $this->refinery->kindlyTo()->null(),
678 $this->refinery->kindlyTo()->string()
679 ]);
680 return $this->request_wrapper->retrieve($param, $trafo);
681 }
682
683 public function confirmRefreshObject(): array
684 {
685 $this->checkPermission("write");
686
687 $languages = ilObject::_getObjectsByType("lng");
688
689 $ids = [];
690 foreach ($languages as $lang) {
691 $langObj = new ilObjLanguage((int) $lang["obj_id"], false);
692 if ($langObj->isInstalled()) {
693 $ids[] = (string) $lang["obj_id"];
694 }
695 }
696 return $ids;
697 }
698
699 public function confirmRefreshSelectedObject(array $a_ids = []): void
700 {
701 $this->checkPermission("write");
702 $this->lng->loadLanguageModule("meta");
703
704 $header = '';
705 $ids = [];
706 if (!empty($a_ids)) {
707 $ids = $a_ids;
708 $header = $this->lng->txt("lang_refresh_confirm");
709 } elseif (!empty($post_id = $this->getIdsFromQueryToken())) {
710 $ids = $post_id;
711 $header = $this->lng->txt("lang_refresh_confirm_selected");
712 } else {
713 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
714 $this->ctrl->redirect($this, "view");
715 }
716
717 $conf_screen = new ilConfirmationGUI();
718 $some_changed = false;
719 foreach ($ids as $id) {
720 $lang_key = ilObject::_lookupTitle((int) $id);
721 $lang_title = $this->lng->txt("meta_l_" . $lang_key);
722 $last_change = ilObjLanguage::_getLastLocalChange($lang_key);
723 if (!empty($last_change)) {
724 $some_changed = true;
725 $lang_title .= " (" . $this->lng->txt("last_change") . " "
727 }
728 $conf_screen->addItem("id[]", (string) $id, $lang_title);
729 }
730
731 $conf_screen->setFormAction($this->ctrl->getFormAction($this));
732 if ($some_changed) {
733 $header .= "<br />" . $this->lng->txt("lang_refresh_confirm_info");
734 }
735 $conf_screen->setHeaderText($header);
736 $conf_screen->setCancel($this->lng->txt("cancel"), "view");
737 $conf_screen->setConfirm($this->lng->txt("ok"), "refreshSelected");
738 $this->tpl->setContent($conf_screen->getHTML());
739 }
740
741 public function confirmUninstallObject(): void
742 {
743 $this->checkPermission("write");
744
745 $this->lng->loadLanguageModule("meta");
746 $conf_screen = new ilConfirmationGUI();
747 $conf_screen->setFormAction($this->ctrl->getFormAction($this));
748 $conf_screen->setHeaderText($this->lng->txt("lang_uninstall_confirm"));
749 foreach ($this->getIdsFromQueryToken() as $id) {
750 $lang_title = ilObject::_lookupTitle((int) $id);
751 $conf_screen->addItem("id[]", $id, $this->lng->txt("meta_l_" . $lang_title));
752 }
753 $conf_screen->setCancel($this->lng->txt("cancel"), "view");
754 $conf_screen->setConfirm($this->lng->txt("ok"), "uninstall");
755 $this->tpl->setContent($conf_screen->getHTML());
756 }
757
758 public function confirmUninstallChangesObject(): void
759 {
760 $this->checkPermission('write');
761
762 $this->lng->loadLanguageModule("meta");
763 $conf_screen = new ilConfirmationGUI();
764 $conf_screen->setFormAction($this->ctrl->getFormAction($this));
765 $conf_screen->setHeaderText($this->lng->txt("lang_uninstall_changes_confirm"));
766 foreach ($this->getIdsFromQueryToken() as $id) {
767 $lang_title = ilObject::_lookupTitle($id);
768 $conf_screen->addItem("id[]", (string) $id, $this->lng->txt("meta_l_" . $lang_title));
769 }
770 $conf_screen->setCancel($this->lng->txt("cancel"), "view");
771 $conf_screen->setConfirm($this->lng->txt("ok"), "uninstallChanges");
772 $this->tpl->setContent($conf_screen->getHTML());
773 }
774
778 public function getActions(): array
779 {
781 return [
782 'confirmRefreshSelected' => $f->table()->action()->standard(
783 $this->lng->txt("refresh"),
784 $this->url_builder->withParameter($this->action_token, "confirmRefreshSelected"),
785 $this->id_token
786 )->withAsync(),
787 'install' => $f->table()->action()->standard(
788 $this->lng->txt("install"),
789 $this->url_builder->withParameter($this->action_token, "install"),
790 $this->id_token
791 ),
792 'installLocal' => $f->table()->action()->standard(
793 $this->lng->txt("install_local"),
794 $this->url_builder->withParameter($this->action_token, "installLocal"),
795 $this->id_token
796 ),
797 'confirmUninstall' => $f->table()->action()->standard(
798 $this->lng->txt("uninstall"),
799 $this->url_builder->withParameter($this->action_token, "confirmUninstall"),
800 $this->id_token
801 ),
802 'confirmUninstallChanges' => $f->table()->action()->standard(
803 $this->lng->txt("lang_uninstall_changes"),
804 $this->url_builder->withParameter($this->action_token, "confirmUninstallChanges"),
805 $this->id_token
806 ),
807 'setSystemLanguage' => $f->table()->action()->single(
808 $this->lng->txt("setSystemLanguage"),
809 $this->url_builder->withParameter($this->action_token, "setSystemLanguage"),
810 $this->id_token
811 ),
812 'setUserLanguage' => $f->table()->action()->single(
813 $this->lng->txt("setUserLanguage"),
814 $this->url_builder->withParameter($this->action_token, "setUserLanguage"),
815 $this->id_token
816 ),
817 'editFolder' => $f->table()->action()->single(
818 $this->lng->txt("edit"),
819 $this->url_builder->withParameter($this->action_token, "editFolder"),
820 $this->id_token
821 ),
822 ];
823 }
824
825 protected function editFolderObject(array $ids): void
826 {
827 $this->ctrl->setParameterByClass("ilobjlanguageextgui", "obj_id", current($ids));
828 $this->ctrl->redirectByClass("ilobjlanguageextgui");
829 }
830
834 protected function disableLanguageDetectionObject(): void
835 {
836 $this->settings->set("lang_detection", '0');
837 $this->tpl->setOnScreenMessage('success', $this->lng->txt("saved_successfully"));
838 $this->viewObject();
839 }
840
844 protected function enableLanguageDetectionObject(): void
845 {
846 $this->settings->set("lang_detection", '1');
847 $this->tpl->setOnScreenMessage('success', $this->lng->txt("saved_successfully"));
848 $this->viewObject();
849 }
850
854 public function listDeprecatedObject(): void
855 {
856 $button = $this->ui_factory->button()->standard(
857 $this->lng->txt("download"),
858 $this->ctrl->getLinkTarget($this, "downloadDeprecated")
859 );
860 $this->toolbar->addComponent($button);
861
862 include_once "./Services/Language/classes/class.ilLangDeprecated.php";
863
864 $d = new ilLangDeprecated();
865 $res = "";
866 foreach ($d->getDeprecatedLangVars() as $key => $mod) {
867 $res .= $mod . "," . $key . "\n";
868 }
869
870 $this->tpl->setContent("<pre>" . $res . "</pre>");
871 }
872
876 public function downloadDeprecatedObject(): void
877 {
878 include_once "./Services/Language/classes/class.ilLangDeprecated.php";
879 $d = new ilLangDeprecated();
880 $res = "";
881 foreach ($d->getDeprecatedLangVars() as $key => $mod) {
882 $res .= $mod . "," . $key . "\n";
883 }
884
885 ilUtil::deliverData($res, "lang_deprecated.csv");
886 }
887
888 protected function getUrl(string $action, ?array $lang_ids = null): string
889 {
890 $url_builder = $this->url_builder->withParameter($this->action_token, $action);
891 if ($lang_ids) {
892 $url_builder = $url_builder->withParameter($this->id_token, $lang_ids);
893 }
894 return $url_builder->buildURI()->__toString();
895 }
896
897 private function getIdsFromQueryToken(): array
898 {
899 $ids = [];
900 if ($this->request_wrapper->has($this->id_token->getName())) {
901 $ids = $this->request_wrapper->retrieve(
902 $this->id_token->getName(),
903 $this->refinery->custom()->transformation(fn($v) => $v)
904 );
905 }
906 return $ids;
907 }
908} // END class.ilObjLanguageFolderGUI
$check
Definition: buildRTE.php:81
Builds data types.
Definition: Factory.php:36
acquireParameters(array $namespace, string ... $names)
Definition: URLBuilder.php:138
buildURI()
Get a URI representation of the full URL including query string and fragment/hash.
Definition: URLBuilder.php:214
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
Search for deprecated lang vars.
Class ilObjLanguageFolderGUI.
getUrl(string $action, ?array $lang_ids=null)
uninstallObject(array $ids)
uninstall language
checkLanguageObject()
check all languages
buildConfirmModal(array $ids, string $title, string $action, string $text, string $add_text='')
getTabs()
Retrieves and adds tabs based on user permissions.
disableLanguageDetectionObject()
Disable language detection.
installLocalObject(array $ids)
Install local language modifications.
ilLanguageFolderTable $languageFolderTable
setUserLanguageObject(array $ids)
set user language
enableLanguageDetectionObject()
Enable language detection.
uninstallChangesObject(array $ids)
Uninstall local changes in the database.
viewObject()
show installed languages
setSystemLanguageObject(array $ids)
set the system language
refreshObject()
update all installed languages
downloadDeprecatedObject()
Download deprecated lang entries.
listDeprecatedObject()
Download deprecated lang entries.
refreshSelectedObject(array $ids)
update selected languages
installObject(array $ids)
install languages
getAdminTabs()
administration tabs show only permissions and trash folder
Class ilObjLanguage.
static _getLastLocalChange(string $a_key)
get the date of the last local change $a_key language key Return change_date "yyyy-mm-dd hh:mm:ss"
static refreshAll()
Refresh all installed languages.
static refreshPlugins(?array $a_lang_keys=null)
Refresh languages of activated plugins $a_lang_keys keys of languages to be refreshed (not yet suppor...
User class.
Class ilObjectGUI Basic methods of all Output classes.
UIFactory $ui_factory
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
UIRenderer $ui_renderer
prepareOutput(bool $show_sub_objects=true)
string $title
static _getObjectsByType(string $obj_type="", ?int $owner=null)
static _lookupTitle(int $obj_id)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
exit
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
Class ilObjForumAdministration.
global $DIC
Definition: shib_login.php:26
$text
Definition: xapiexit.php:21
$param
Definition: xapitoken.php:44