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