ILIAS  release_8 Revision v8.24
class.ilLanguageTableGUI.php
Go to the documentation of this file.
1<?php
2
20declare(strict_types=1);
21
22include_once "./Services/Table/classes/class.ilTable2GUI.php";
23
33{
35
39 public function __construct(object $a_parent_obj, string $a_parent_cmd, $a_folder)
40 {
41 global $DIC;
42 $ilAccess = $DIC->access();
43
44 $this->folder = $a_folder;
45
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47 $this->setLimit(9999);
48
49 if ($ilAccess->checkAccess("write", "", $this->folder->getRefId())) {
50 $this->addColumn("", "", "1", true);
51 }
52 $this->addColumn($this->lng->txt("language"));
53 $this->addColumn($this->lng->txt("status"));
54 $this->addColumn($this->lng->txt("users"));
55 $this->addColumn($this->lng->txt("last_refresh"));
56 $this->addColumn($this->lng->txt("last_change"));
57
58 $this->setEnableHeader(true);
59 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
60 $this->setRowTemplate("tpl.lang_list_row_extended.html", "Services/Language");
61 $this->disable("footer");
62 $this->setEnableTitle(true);
63
64 if ($ilAccess->checkAccess("write", "", $this->folder->getRefId())) {
65 $this->setSelectAllCheckbox("id[]");
66 $this->addMultiCommand("confirmRefreshSelected", $this->lng->txt("refresh"));
67 $this->addMultiCommand("install", $this->lng->txt("install"));
68 $this->addMultiCommand("installLocal", $this->lng->txt("install_local"));
69 $this->addMultiCommand("confirmUninstall", $this->lng->txt("uninstall"));
70 $this->addMultiCommand("confirmUninstallChanges", $this->lng->txt("lang_uninstall_changes"));
71 $this->addMultiCommand("setSystemLanguage", $this->lng->txt("setSystemLanguage"));
72 $this->addMultiCommand("setUserLanguage", $this->lng->txt("setUserLanguage"));
73 }
74
75 $this->getItems();
76 }
77
81 public function getItems(): void
82 {
83 $languages = $this->folder->getLanguages();
84 $data = [];
85 $names = [];
86 $installed = [];
87
88 foreach ($languages as $k => $l) {
89 $data[] = array_merge($l, ["key" => $k]);
90 $names[] = $l['name'];
91 $installed[] = str_starts_with($l["desc"], 'installed') ? 1 : 2;
92 }
93
94 // sort alphabetically but show installed languages first
95 array_multisort($installed, SORT_ASC, $names, SORT_ASC, $data);
96
97 $this->setData($data);
98 }
99
100
104 protected function fillRow(array $a_set): void
105 {
106 global $DIC;
107 $ilSetting = $DIC->settings();
108 $ilAccess = $DIC->access();
109
110 $status = "";
111
112 // set status info (in use or systemlanguage)
113 if ($a_set["status"] ?? false) {
114 $status = "<span class=\"small\"> (" . $this->lng->txt($a_set["status"]) . ")</span>";
115 }
116
117 // set remark color
118 $remark = "";
119 switch ($a_set["info"]) {
120 case "file_not_found":
121 $remark = "<span class=\"smallred\"> " . $this->lng->txt($a_set["info"]) . "</span>";
122 break;
123 case "new_language":
124 //$remark = "<span class=\"smallgreen\"> ".$lng->txt($a_set["info"])."</span>";
125 break;
126 }
127
128 // show page translation
129 if ($ilSetting->get("lang_translate_" . $a_set["key"])) {
130 $remark .= $remark ? '<br />' : '';
131 $remark .= "<span class=\"smallgreen\"> " . $this->lng->txt("language_translation_enabled") . "</span>";
132 }
133
134 if ($a_set["desc"] !== "not_installed") {
135 $this->tpl->setVariable(
136 "LAST_REFRESH",
138 );
139
140 $last_change = ilObjLanguage::_getLastLocalChange($a_set["key"]);
141 $this->tpl->setVariable(
142 "LAST_CHANGE",
144 );
145 }
146
147 $this->tpl->setVariable("NR_OF_USERS", ilObjLanguage::countUsers($a_set["key"]));
148
149 // make language name clickable
150 if ($ilAccess->checkAccess("write", "", $this->folder->getRefId()) && strpos(
151 $a_set["description"],
152 "installed"
153 ) === 0) {
154 $this->ctrl->setParameterByClass("ilobjlanguageextgui", "obj_id", $a_set["obj_id"]);
155 $url = $this->ctrl->getLinkTargetByClass("ilobjlanguageextgui", "");
156 $a_set["name"] = '<a href="' . $url . '">' . $a_set["name"] . '</a>';
157 }
158
159 $this->tpl->setVariable("VAL_LANGUAGE", $a_set["name"] . $status);
160 $this->tpl->setVariable("VAL_STATUS", $this->lng->txt($a_set["desc"]) . "<br/>" . $remark);
161
162 if ($ilAccess->checkAccess("write", '', $this->folder->getRefId())) {
163 $this->tpl->setVariable("OBJ_ID", $a_set["obj_id"]);
164 }
165 }
166}
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
fillRow(array $a_set)
Fill table row.
getItems()
Get language data.
__construct(object $a_parent_obj, string $a_parent_cmd, $a_folder)
Constructor.
ilObjLanguageFolder $folder
Class ilObjLanguageFolder contains all function to manage language support for ILIAS3 install,...
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 countUsers(string $a_lang)
Count number of users that use a language.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setEnableTitle(bool $a_enabletitle)
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
disable(string $a_module_name)
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
$url