19 declare(strict_types=1);
45 public function __construct(?array $a_data,
int $a_id,
bool $a_call_by_reference)
49 $this->
lng->loadLanguageModule(
"lng");
52 $here_uri = $this->df->uri($this->request->getUri()->__toString());
54 $query_params_namespace = [
'language_folder'];
57 $query_params_namespace,
63 $this->action_token = $action_parameter_token;
64 $this->id_token = $row_id_token;
68 $this->languageFolderTable =
new ilLanguageFolderTable($folder, $url_builder, $action_parameter_token, $row_id_token);
78 $table = $this->languageFolderTable->getTable();
87 'lang_refresh_confirm_selected',
88 "lang_refresh_confirm_info" 90 $refresh = $this->ui_factory->button()->standard(
91 $this->
lng->txt(
"refresh_languages"),
93 )->withOnClick($modal->getShowSignal());
95 $this->
toolbar->addComponent($modal);
96 $this->
toolbar->addComponent($refresh);
99 $check = $this->ui_factory->button()->standard(
100 $this->
lng->txt(
"check_languages"),
101 $this->
getUrl(
"checkLanguage")
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")
112 $this->
toolbar->addComponent($download);
116 $modal_on = $this->ui_factory->modal()->interruptive(
118 $this->
lng->txt(
"lng_enable_language_detection"),
119 $this->
ctrl->getFormActionByClass(self::class,
"enableLanguageDetection")
121 ->withActionButtonLabel($this->
lng->txt(
'ok'));
122 $modal_off = $this->ui_factory->modal()->interruptive(
124 $this->
lng->txt(
"lng_disable_language_detection"),
125 $this->
ctrl->getFormActionByClass(self::class,
"disableLanguageDetection")
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"))
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);
140 $this->tpl->setContent($this->ui_renderer->render($table->withRequest($this->request)));
146 $title = $this->
lng->txt($title);
152 $some_changed =
false;
153 foreach ($ids as
$id) {
155 $lang_title = $this->
lng->txt(
"meta_l_" . $lang_key);
157 if (!empty($last_change)) {
158 $some_changed =
true;
159 $lang_title .=
" (" . $this->
lng->txt(
"last_change") .
" " 166 $items[] =
$f->modal()->interruptiveItem()->standard($id, $lang_title);
177 $modal =
$f->modal()->interruptive(
182 if (!empty($items)) {
183 $modal = $modal->withAffectedItems($items)
184 ->withActionButtonLabel($title);
186 $modal = $modal->withActionButtonLabel($this->
lng->txt(
'ok'));
197 $this->
lng->loadLanguageModule(
"meta");
201 $key = $langObj->install();
204 $lang_installed[] = $key;
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")) .
".";
215 foreach ($lang_installed as $lang_key) {
216 $langnames[] = $this->
lng->txt(
"meta_l_" . $lang_key);
218 $this->data = implode(
", ", $langnames) .
" " . strtolower($this->
lng->txt(
"installed")) .
".";
221 $this->data = $this->
lng->txt(
"languages_already_installed");
234 $this->
lng->loadLanguageModule(
"meta");
238 $key = $langObj->install();
241 $lang_installed[] = $key;
247 $key = $langObj->install(
"local");
250 $local_installed[] = $key;
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")) .
".";
261 foreach ($lang_installed as $lang_key) {
262 $langnames[] = $this->
lng->txt(
"meta_l_" . $lang_key);
264 $this->data = implode(
", ", $langnames) .
" " . strtolower($this->
lng->txt(
"installed")) .
".";
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")) .
".";
273 foreach ($local_installed as $lang_key) {
274 $langnames[] = $this->
lng->txt(
"meta_l_" . $lang_key);
276 $this->data .=
" " . implode(
", ", $langnames) .
" " . $this->
lng->txt(
"local_language_files") .
" " . strtolower($this->
lng->txt(
"installed")) .
".";
279 $this->data .=
" " . $this->
lng->txt(
"local_languages_already_installed");
292 $this->
lng->loadLanguageModule(
"meta");
300 if (!($sys_lang = $langObj->isSystemLanguage()) && !($usr_lang = $langObj->isUserLanguage())) {
301 $key = $langObj->uninstall();
303 $lang_uninstalled[] = $key;
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");
315 foreach ($lang_uninstalled as $lang_key) {
316 $langnames[] = $this->
lng->txt(
"meta_l_" . $lang_key);
319 $this->data = implode(
", ", $langnames) .
" " . $this->
lng->txt(
"uninstalled");
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");
326 $this->data = $this->
lng->txt(
"languages_already_uninstalled");
340 $this->data = $this->
lng->txt(
"selected_languages_updated");
341 $this->
lng->loadLanguageModule(
"meta");
344 foreach ($ids as
$id) {
347 if ($langObj->isInstalled()) {
348 if ($langObj->check()) {
349 $langObj->flush(
"all");
351 $langObj->setTitle($langObj->getKey());
352 $langObj->setDescription(
"installed");
354 $refreshed[] = $langObj->getKey();
356 $this->data .=
"<br />" . $this->
lng->txt(
"meta_l_" . $langObj->getKey());
373 $this->data = $this->
lng->txt(
"languages_updated");
383 $this->data = $this->
lng->txt(
"selected_languages_updated");
384 $this->
lng->loadLanguageModule(
"meta");
387 foreach ($ids as
$id) {
389 if ($langObj->refresh()) {
390 $refreshed[] = $langObj->getKey();
391 $this->data .=
"<br />" . $this->
lng->txt(
"meta_l_" . $langObj->getKey());
406 $ilUser = $DIC->user();
409 $this->
lng->loadLanguageModule(
"meta");
411 #require_once "./Services/User/classes/class.ilObjUser.php"; 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");
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");
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");
433 $curUser =
new ilObjUser($ilUser->getId());
434 $curUser->setLanguage($newUserLangObj->getKey());
437 $this->data = $this->
lng->txt(
"user_language") .
" " . $this->
lng->txt(
"changed_to") .
" " . $this->
lng->txt(
"meta_l_" . $newUserLangObj->getKey()) .
".";
449 $this->
lng->loadLanguageModule(
"meta");
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");
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");
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");
471 $this->
ilias->setSetting(
"language", $newSysLangObj->getKey());
474 $this->
ilias->ini->setVariable(
"language",
"default", $newSysLangObj->getKey());
475 $this->
ilias->ini->write();
477 $this->data = $this->
lng->txt(
"system_language") .
" " . $this->
lng->txt(
"changed_to") .
" " . $this->
lng->txt(
"meta_l_" . $newSysLangObj->getKey()) .
".";
488 $this->data = $this->
object->checkAllLanguages();
492 public function out(): void
494 $this->tpl->setOnScreenMessage(
'info', $this->data,
true);
495 $this->
ctrl->redirect($this,
"view");
509 $this->tabs_gui->addTab(
"settings", $this->
lng->txt(
"settings"), $this->
ctrl->getLinkTarget($this,
"view"));
513 $this->tabs_gui->addTab(
"perm_settings", $this->
lng->txt(
"perm_settings"), $this->
ctrl->getLinkTargetByClass(array(self::class,
"ilpermissiongui"),
"perm"));
522 $next_class = $this->
ctrl->getNextClass($this);
523 $cmd = $this->
ctrl->getCmd();
526 switch ($next_class) {
527 case "ilpermissiongui":
528 include_once
"Services/AccessControl/classes/class.ilPermissionGUI.php";
530 $this->tabs_gui->activateTab(
"perm_settings");
531 $this->
ctrl->forwardCommand($perm_gui);
535 $this->tabs_gui->activateTab(
"settings");
539 $this->
lng->loadLanguageModule(
"meta");
543 case 'confirmRefresh':
547 case 'checkLanguage':
552 if (current($ids) ===
'ALL_OBJECTS') {
555 foreach ($languages as
$lang) {
557 if ($langObj->isInstalled()) {
558 $ids[] = (string) $lang[
"obj_id"];
566 'lang_refresh_confirm_selected',
567 "lang_refresh_confirm_info" 569 echo(
$r->renderAsync([$modal]));
571 case 'refreshConfirmed':
577 if (current($ids) ===
'ALL_OBJECTS') {
580 foreach ($languages as
$lang) {
582 if ($langObj->isInstalled()) {
583 $ids[] = (string) $lang[
"obj_id"];
590 'uninstallConfirmed',
591 'lang_uninstall_confirm' 593 echo(
$r->renderAsync([$modal]));
595 case 'uninstallConfirmed':
601 if (current($ids) ===
'ALL_OBJECTS') {
604 foreach ($languages as
$lang) {
606 if (!$langObj->isInstalled()) {
607 $ids[] = (string) $lang[
"obj_id"];
613 case 'install_local':
615 if (current($ids) ===
'ALL_OBJECTS') {
618 foreach ($languages as
$lang) {
619 $ids[] = (string) $lang[
"obj_id"];
624 case 'lang_uninstall_changes':
626 if (current($ids) ===
'ALL_OBJECTS') {
629 foreach ($languages as
$lang) {
631 if ($langObj->isInstalled()) {
632 $ids[] = (string) $lang[
"obj_id"];
640 'lang_uninstall_changes_confirm' 642 echo(
$r->renderAsync([$modal]));
644 case 'uninstallChanges':
648 case 'setSystemLanguage':
652 case 'setUserLanguage':
674 if (!$this->request_wrapper->has($param)) {
677 $trafo = $this->
refinery->byTrying([
678 $this->
refinery->kindlyTo()->null(),
679 $this->
refinery->kindlyTo()->string()
681 return $this->request_wrapper->retrieve($param, $trafo);
691 foreach ($languages as
$lang) {
693 if ($langObj->isInstalled()) {
694 $ids[] = (string) $lang[
"obj_id"];
703 $this->
lng->loadLanguageModule(
"meta");
707 if (!empty($a_ids)) {
709 $header = $this->
lng->txt(
"lang_refresh_confirm");
712 $header = $this->
lng->txt(
"lang_refresh_confirm_selected");
714 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"no_checkbox"),
true);
715 $this->
ctrl->redirect($this,
"view");
719 $some_changed =
false;
720 foreach ($ids as
$id) {
722 $lang_title = $this->
lng->txt(
"meta_l_" . $lang_key);
724 if (!empty($last_change)) {
725 $some_changed =
true;
726 $lang_title .=
" (" . $this->
lng->txt(
"last_change") .
" " 729 $conf_screen->addItem(
"id[]", (
string) $id, $lang_title);
732 $conf_screen->setFormAction($this->
ctrl->getFormAction($this));
734 $header .=
"<br />" . $this->
lng->txt(
"lang_refresh_confirm_info");
736 $conf_screen->setHeaderText($header);
737 $conf_screen->setCancel($this->
lng->txt(
"cancel"),
"view");
738 $conf_screen->setConfirm($this->
lng->txt(
"ok"),
"refreshSelected");
739 $this->tpl->setContent($conf_screen->getHTML());
746 $this->
lng->loadLanguageModule(
"meta");
748 $conf_screen->setFormAction($this->
ctrl->getFormAction($this));
749 $conf_screen->setHeaderText($this->
lng->txt(
"lang_uninstall_confirm"));
752 $conf_screen->addItem(
"id[]", $id, $this->
lng->txt(
"meta_l_" . $lang_title));
754 $conf_screen->setCancel($this->
lng->txt(
"cancel"),
"view");
755 $conf_screen->setConfirm($this->
lng->txt(
"ok"),
"uninstall");
756 $this->tpl->setContent($conf_screen->getHTML());
763 $this->
lng->loadLanguageModule(
"meta");
765 $conf_screen->setFormAction($this->
ctrl->getFormAction($this));
766 $conf_screen->setHeaderText($this->
lng->txt(
"lang_uninstall_changes_confirm"));
769 $conf_screen->addItem(
"id[]", (
string)
$id, $this->
lng->txt(
"meta_l_" . $lang_title));
771 $conf_screen->setCancel($this->
lng->txt(
"cancel"),
"view");
772 $conf_screen->setConfirm($this->
lng->txt(
"ok"),
"uninstallChanges");
773 $this->tpl->setContent($conf_screen->getHTML());
783 'confirmRefreshSelected' =>
$f->table()->action()->standard(
784 $this->
lng->txt(
"refresh"),
785 $this->url_builder->withParameter($this->action_token,
"confirmRefreshSelected"),
788 'install' =>
$f->table()->action()->standard(
789 $this->
lng->txt(
"install"),
790 $this->url_builder->withParameter($this->action_token,
"install"),
793 'installLocal' =>
$f->table()->action()->standard(
794 $this->
lng->txt(
"install_local"),
795 $this->url_builder->withParameter($this->action_token,
"installLocal"),
798 'confirmUninstall' =>
$f->table()->action()->standard(
799 $this->
lng->txt(
"uninstall"),
800 $this->url_builder->withParameter($this->action_token,
"confirmUninstall"),
803 'confirmUninstallChanges' =>
$f->table()->action()->standard(
804 $this->
lng->txt(
"lang_uninstall_changes"),
805 $this->url_builder->withParameter($this->action_token,
"confirmUninstallChanges"),
808 'setSystemLanguage' =>
$f->table()->action()->single(
809 $this->
lng->txt(
"setSystemLanguage"),
810 $this->url_builder->withParameter($this->action_token,
"setSystemLanguage"),
813 'setUserLanguage' =>
$f->table()->action()->single(
814 $this->
lng->txt(
"setUserLanguage"),
815 $this->url_builder->withParameter($this->action_token,
"setUserLanguage"),
818 'editFolder' =>
$f->table()->action()->single(
819 $this->
lng->txt(
"edit"),
820 $this->url_builder->withParameter($this->action_token,
"editFolder"),
828 $this->
ctrl->setParameterByClass(
"ilobjlanguageextgui",
"obj_id", current($ids));
829 $this->
ctrl->redirectByClass(
"ilobjlanguageextgui");
837 $this->
settings->set(
"lang_detection",
'0');
838 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"saved_successfully"));
847 $this->
settings->set(
"lang_detection",
'1');
848 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"saved_successfully"));
857 $button = $this->ui_factory->button()->standard(
858 $this->
lng->txt(
"download"),
859 $this->
ctrl->getLinkTarget($this,
"downloadDeprecated")
861 $this->
toolbar->addComponent($button);
863 include_once
"./Services/Language/classes/class.ilLangDeprecated.php";
867 foreach (
$d->getDeprecatedLangVars() as $key => $mod) {
868 $res .= $mod .
"," . $key .
"\n";
871 $this->tpl->setContent(
"<pre>" .
$res .
"</pre>");
879 include_once
"./Services/Language/classes/class.ilLangDeprecated.php";
882 foreach (
$d->getDeprecatedLangVars() as $key => $mod) {
883 $res .= $mod .
"," . $key .
"\n";
889 protected function getUrl(
string $action, ?array $lang_ids =
null): string
891 $url_builder = $this->url_builder->
withParameter($this->action_token, $action);
893 $url_builder = $url_builder->
withParameter($this->id_token, $lang_ids);
895 return $url_builder->
buildURI()->__toString();
901 if ($this->request_wrapper->has($this->id_token->getName())) {
902 $ids = $this->request_wrapper->retrieve(
903 $this->id_token->getName(),
904 $this->
refinery->custom()->transformation(fn($v) => $v)
editFolderObject(array $ids)
getTabs()
Retrieves and adds tabs based on user permissions.
static _getObjectsByType(string $obj_type="", ?int $owner=null)
buildURI()
Get a URI representation of the full URL including query string and fragment/hash.
prepareOutput(bool $show_sub_objects=true)
refreshObject()
update all installed languages
refreshSelectedObject(array $ids)
update selected languages
Interface Observer Contains several chained tasks and infos about them.
installLocalObject(array $ids)
Install local language modifications.
acquireParameters(array $namespace, string ... $names)
listDeprecatedObject()
Download deprecated lang entries.
URLBuilderToken $id_token
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
getUrl(string $action, ?array $lang_ids=null)
uninstallChangesObject(array $ids)
Uninstall local changes in the database.
confirmRefreshSelectedObject(array $a_ids=[])
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Search for deprecated lang vars.
static _lookupTitle(int $obj_id)
static refreshPlugins(?array $a_lang_keys=null)
Refresh languages of activated plugins $a_lang_keys keys of languages to be refreshed (not yet suppor...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjectGUI Basic methods of all Output classes.
Class ilObjForumAdministration.
ilLanguageFolderTable $languageFolderTable
downloadDeprecatedObject()
Download deprecated lang entries.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
enableLanguageDetectionObject()
Enable language detection.
viewObject()
show installed languages
confirmUninstallChangesObject()
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
__construct(Container $dic, ilPlugin $plugin)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
buildConfirmModal(array $ids, string $title, string $action, string $text, string $add_text='')
installObject(array $ids)
install languages
disableLanguageDetectionObject()
Disable language detection.
static refreshAll()
Refresh all installed languages.
uninstallObject(array $ids)
uninstall language
getCommandFromQueryToken(string $param)
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" ...
URLBuilderToken $action_token
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
setSystemLanguageObject(array $ids)
set the system language
checkLanguageObject()
check all languages
Class ilObjLanguageFolderGUI.
setUserLanguageObject(array $ids)
set user language