ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLanguageExtTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 private int $inputsize = 40;
24 private int $commentsize = 30;
25 private array $params;
26
27 public function __construct(object $a_parent_obj, string $a_parent_cmd, array $a_params = array())
28 {
29 global $DIC;
30 $ilCtrl = $DIC->ctrl();
31 $lng = $DIC->language();
32
33 // allow a different sorting/paging for admin and translation tables
34 $this->params = $a_params;
35 $this->setId("lang_ext_" . (ilObjLanguageAccess::_isPageTranslation() ? "trans" : "admin"));
36
37 parent::__construct($a_parent_obj, $a_parent_cmd);
38
39 $this->setRowTemplate("tpl.lang_items_row.html", "components/ILIAS/Language");
40 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
41 $this->setDisableFilterHiding(true);
42
43 $this->initFilter();
44
45 // set the compare language
46 $compare = $this->getFilterItemByPostVar("compare")->getValue();
47 $compare_note = '';
48 if ($compare === $this->params["lang_key"]) {
49 $compare_note = " " . $lng->txt("language_default_entries");
50 }
51
52 $this->addColumn(ucfirst($lng->txt("module")), "module", "10em");
53 $this->addColumn(ucfirst($lng->txt("identifier")), "topic", "10em");
54 $this->addColumn($lng->txt("meta_l_" . $this->params['lang_key']), "translation");
55 $this->addColumn($lng->txt("meta_l_" . $compare) . $compare_note, "default");
56 $this->addCommandButton("save", $lng->txt("save"));
57 }
58
59
63 protected function fillRow(array $a_set): void
64 {
65 global $DIC;
66 $ilDB = $DIC->database();
67 $ilCtrl = $DIC->ctrl();
68 $lng = $DIC->language();
69
70 // mantis #25237
71 // @see https://php.net/manual/en/language.variables.external.php
72 $a_set["name"] = str_replace(".", "_POSTDOT_", $a_set["name"]);
73 $a_set["name"] = str_replace(" ", "_POSTSPACE_", $a_set["name"]);
74
75 if ($this->params["langmode"]) {
76 $this->tpl->setCurrentBlock("comment");
77 $this->tpl->setVariable(
78 "COM_ID",
79 ilLegacyFormElementsUtil::prepareFormOutput($a_set["name"] . $lng->separator . "comment")
80 );
81 $this->tpl->setVariable(
82 "COM_NAME",
83 ilLegacyFormElementsUtil::prepareFormOutput($a_set["name"] . $lng->separator . "comment")
84 );
85 $this->tpl->setVariable("COM_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($a_set["comment"]));
86 $this->tpl->setVariable("COM_SIZE", $this->commentsize);
87 $this->tpl->setVariable("COM_MAX", 250);
88 $this->tpl->setVariable("TXT_COMMENT", $lng->txt("comment"));
89 $this->tpl->parseCurrentBlock();
90 } else {
91 $this->tpl->setCurrentBlock("hidden_comment");
92 $this->tpl->setVariable(
93 "COM_NAME",
94 ilLegacyFormElementsUtil::prepareFormOutput($a_set["name"] . $lng->separator . "comment")
95 );
96 $this->tpl->setVariable("COM_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($a_set["comment"] ?? ""));
97 $this->tpl->parseCurrentBlock();
98 }
99
100 $this->tpl->setVariable("T_ROWS", ceil(strlen($a_set["translation"] ?? " ") / $this->inputsize));
101 $this->tpl->setVariable("T_SIZE", $this->inputsize);
102 $this->tpl->setVariable("T_NAME", ilLegacyFormElementsUtil::prepareFormOutput($a_set["name"]));
103 $this->tpl->setVariable("T_USER_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($a_set["translation"]));
104
105 $this->tpl->setVariable("MODULE", ilLegacyFormElementsUtil::prepareFormOutput($a_set["module"]));
106 $this->tpl->setVariable("TOPIC", ilLegacyFormElementsUtil::prepareFormOutput($a_set["topic"]));
107
108 $this->tpl->setVariable("DEFAULT_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($a_set["default"] ?? ""));
109 $this->tpl->setVariable("COMMENT", ilLegacyFormElementsUtil::prepareFormOutput($a_set["default_comment"] ?? ""));
110 }
111
115 public function initFilter(): void
116 {
117 global $DIC;
118 $lng = $DIC->language();
119
120 // most filters are only
122 // pattern
123 $ti = new ilTextInputGUI($lng->txt("search"), "pattern");
124 $ti->setMaxLength(64);
125 $ti->setSize(20);
126 $this->addFilterItem($ti);
127 $ti->readFromSession();
128
129 // module
130 $options = array();
131 $options["all"] = $lng->txt("language_all_modules");
133 foreach ($modules as $mod) {
134 $options[$mod] = $mod;
135 }
136
137 $si = new ilSelectInputGUI(ucfirst($lng->txt("module")), "module");
138 $si->setOptions($options);
139 $this->addFilterItem($si);
140 $si->readFromSession();
141 if (!$si->getValue()) {
142 $si->setValue("administration");
143 }
144
145 // identifier
146 $ti = new ilTextInputGUI(ucfirst($lng->txt("identifier")), "identifier");
147 $ti->setMaxLength(200);
148 $ti->setSize(20);
149 $this->addFilterItem($ti);
150 $ti->readFromSession();
151
152 // mode
153 $options = array();
154 $options["all"] = $lng->txt("language_scope_global");
155 $options["changed"] = $lng->txt("language_scope_local");
156 if ($this->params['langmode']) {
157 $options["added"] = $lng->txt("language_scope_added");
158 }
159 $options["unchanged"] = $lng->txt("language_scope_unchanged");
160 $options["equal"] = $lng->txt("language_scope_equal");
161 $options["different"] = $lng->txt("language_scope_different");
162 $options["commented"] = $lng->txt("language_scope_commented");
163 if ($this->params['langmode']) {
164 $options["dbremarks"] = $lng->txt("language_scope_dbremarks");
165 }
166 $options["conflicts"] = $lng->txt("language_scope_conflicts");
167
168 $si = new ilSelectInputGUI($lng->txt("filter"), "mode");
169 $si->setOptions($options);
170 $this->addFilterItem($si);
171 $si->readFromSession();
172 if (!$si->getValue()) {
173 $si->setValue("all");
174 }
175 }
176
177 //compare
178 $options = array();
179 $langlist = $lng->getInstalledLanguages();
180 foreach ($langlist as $lang_key) {
181 $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
182 }
183
184 $si = new ilSelectInputGUI($lng->txt("language_compare"), "compare");
185 $si->setOptions($options);
186 $this->addFilterItem($si);
187 $si->readFromSession();
188 if (!$si->getValue()) {
189 $si->setValue($lng->getDefaultLanguage());
190 }
191 }
192}
__construct(object $a_parent_obj, string $a_parent_cmd, array $a_params=array())
fillRow(array $a_set)
Fill a single data row.
getLangKey()
Return lang key.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getDefaultLanguage()
Return default language.
getInstalledLanguages()
Get installed languages.
static prepareFormOutput($a_str, bool $a_strip=false)
static _isPageTranslation()
Check if the current request is a page translation.
static _getModules(string $a_lang_key)
Get all modules of a language.
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getFilterItemByPostVar(string $a_post_var)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
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)
setDisableFilterHiding(bool $a_val=true)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
ilLanguage $lng
This class represents a text property in a property form.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26