ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLanguageExtTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-20014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once "./Services/Table/classes/class.ilTable2GUI.php";
5
7{
12 private $inputsize = 40;
13 private $commentsize = 30;
14
18 private $params = array();
19
20 public function __construct($a_parent_obj, $a_parent_cmd, $a_params = array())
21 {
22 global $DIC;
23 $ilCtrl = $DIC->ctrl();
24 $lng = $DIC->language();
25
26 // allow a different sorting/paging for admin and translation tables
27 $this->params = $a_params;
28 $this->setId("lang_ext_" . (ilObjLanguageAccess::_isPageTranslation() ? 'trans' : 'admin'));
29
30 parent::__construct($a_parent_obj, $a_parent_cmd);
31
32 $this->setRowTemplate("tpl.lang_items_row.html", "Services/Language");
33 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
34 $this->setDisableFilterHiding(true);
35
36 $this->initFilter();
37
38 // set the compare language
39 $compare = $this->getFilterItemByPostVar('compare')->getValue();
40 if ($compare == $this->params['lang_key']) {
41 $compare_note = " " . $lng->txt("language_default_entries");
42 }
43
44 $this->addColumn(ucfirst($lng->txt("module")), "module", "10em");
45 $this->addColumn(ucfirst($lng->txt("identifier")), "topic", "10em");
46 $this->addColumn($lng->txt("meta_l_" . $this->params['lang_key']), "translation");
47 $this->addColumn($lng->txt("meta_l_" . $compare) . $compare_note, "default");
48 $this->addCommandButton('save', $lng->txt('save'));
49 }
50
51
55 protected function fillRow($data)
56 {
57 global $DIC;
58 $ilDB = $DIC->database();
59 $ilCtrl = $DIC->ctrl();
60 $lng = $DIC->language();
61
62 // mantis #25237
63 // @see https://php.net/manual/en/language.variables.external.php
64 $data['name'] = str_replace('.', '_POSTDOT_', $data['name']);
65 $data['name'] = str_replace(' ', '_POSTSPACE_', $data['name']);
66
67 if ($this->params['langmode']) {
68 $this->tpl->setCurrentBlock('comment');
69 $this->tpl->setVariable("COM_ID", ilUtil::prepareFormOutput($data["name"] . $lng->separator . "comment"));
70 $this->tpl->setVariable("COM_NAME", ilUtil::prepareFormOutput($data["name"] . $lng->separator . "comment"));
71 $this->tpl->setVariable("COM_VALUE", ilUtil::prepareFormOutput($data["comment"]));
72 $this->tpl->setVariable("COM_SIZE", $this->commentsize);
73 $this->tpl->setVariable("COM_MAX", 250);
74 $this->tpl->setVariable("TXT_COMMENT", $lng->txt('comment'));
75 $this->tpl->parseCurrentBlock();
76 } else {
77 $this->tpl->setCurrentBlock('hidden_comment');
78 $this->tpl->setVariable("COM_NAME", ilUtil::prepareFormOutput($data["name"] . $lng->separator . "comment"));
79 $this->tpl->setVariable("COM_VALUE", ilUtil::prepareFormOutput($data["comment"]));
80 $this->tpl->parseCurrentBlock();
81 }
82
83 $this->tpl->setVariable("T_ROWS", ceil(strlen($data["translation"]) / $this->inputsize));
84 $this->tpl->setVariable("T_SIZE", $this->inputsize);
85 $this->tpl->setVariable("T_NAME", ilUtil::prepareFormOutput($data["name"]));
86 $this->tpl->setVariable("T_USER_VALUE", ilUtil::prepareFormOutput($data["translation"]));
87
88 $this->tpl->setVariable("MODULE", ilUtil::prepareFormOutput($data["module"]));
89 $this->tpl->setVariable("TOPIC", ilUtil::prepareFormOutput($data["topic"]));
90
91 $this->tpl->setVariable("DEFAULT_VALUE", ilUtil::prepareFormOutput($data["default"]));
92 $this->tpl->setVariable("COMMENT", ilUtil::prepareFormOutput($data["default_comment"]));
93 }
94
98 public function initFilter()
99 {
100 global $DIC;
101 $lng = $DIC->language();
102
103 // most filters are only
105 // pattern
106 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
107 $ti = new ilTextInputGUI($lng->txt("search"), "pattern");
108 $ti->setParent($this->parent_obj);
109 $ti->setMaxLength(64);
110 $ti->setSize(20);
111 $this->addFilterItem($ti);
112 $ti->readFromSession();
113
114 // module
115 $options = array();
116 $options["all"] = $lng->txt("language_all_modules");
117 $modules = ilObjLanguageExt::_getModules($lng->getLangKey());
118 foreach ($modules as $mod) {
119 $options[$mod] = $mod;
120 }
121
122 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
123 $si = new ilSelectInputGUI(ucfirst($lng->txt("module")), "module");
124 $si->setParent($this->parent_obj);
125 $si->setOptions($options);
126 $this->addFilterItem($si);
127 $si->readFromSession();
128 if (!$si->getValue()) {
129 $si->setValue('administration');
130 }
131
132 // identifier
133 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
134 $ti = new ilTextInputGUI(ucfirst($lng->txt("identifier")), "identifier");
135 $ti->setParent($this->parent_obj);
136 $ti->setMaxLength(200);
137 $ti->setSize(20);
138 $this->addFilterItem($ti);
139 $ti->readFromSession();
140
141 // mode
142 $options = array();
143 $options["all"] = $lng->txt("language_scope_global");
144 $options["changed"] = $lng->txt("language_scope_local");
145 if ($this->params['langmode']) {
146 $options["added"] = $lng->txt("language_scope_added");
147 }
148 $options["unchanged"] = $lng->txt("language_scope_unchanged");
149 $options["equal"] = $lng->txt("language_scope_equal");
150 $options["different"] = $lng->txt("language_scope_different");
151 $options["commented"] = $lng->txt("language_scope_commented");
152 if ($this->params['langmode']) {
153 $options["dbremarks"] = $lng->txt("language_scope_dbremarks");
154 }
155 $options["conflicts"] = $lng->txt("language_scope_conflicts");
156
157 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
158 $si = new ilSelectInputGUI($lng->txt("filter"), "mode");
159 $si->setParent($this->parent_obj);
160 $si->setOptions($options);
161 $this->addFilterItem($si);
162 $si->readFromSession();
163 if (!$si->getValue()) {
164 $si->setValue('all');
165 }
166 }
167
168 //compare
169 $options = array();
170 $langlist = $lng->getInstalledLanguages();
171 foreach ($langlist as $lang_key) {
172 $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
173 }
174
175 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
176 $si = new ilSelectInputGUI($lng->txt("language_compare"), "compare");
177 $si->setParent($this->parent_obj);
178 $si->setOptions($options);
179 $this->addFilterItem($si);
180 $si->readFromSession();
181 if (!$si->getValue()) {
182 $si->setValue($lng->getDefaultLanguage());
183 }
184 }
185}
An exception for terminatinating execution or to throw for unit testing.
__construct($a_parent_obj, $a_parent_cmd, $a_params=array())
ilTable2GUI constructor.
fillRow($data)
Fill a single data row.
static _isPageTranslation()
Check if the current request is a page translation.
static _getModules($a_lang_key)
Get all modules of a language.
This class represents a selection list property in a property form.
Class ilTable2GUI.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
getFilterItemByPostVar($a_post_var)
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
This class represents a text property in a property form.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilDB