ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  if ($this->params['langmode'])
59  {
60  $this->tpl->setCurrentBlock('comment');
61  $this->tpl->setVariable("COM_ID", ilUtil::prepareFormOutput($data["name"].$lng->separator."comment"));
62  $this->tpl->setVariable("COM_NAME", ilUtil::prepareFormOutput($data["name"].$lng->separator."comment"));
63  $this->tpl->setVariable("COM_VALUE", ilUtil::prepareFormOutput($data["comment"]));
64  $this->tpl->setVariable("COM_SIZE", $this->commentsize);
65  $this->tpl->setVariable("COM_MAX", 250);
66  $this->tpl->setVariable("TXT_COMMENT", $lng->txt('comment'));
67  $this->tpl->parseCurrentBlock();
68  }
69  else
70  {
71  $this->tpl->setCurrentBlock('hidden_comment');
72  $this->tpl->setVariable("COM_NAME", ilUtil::prepareFormOutput($data["name"].$lng->separator."comment"));
73  $this->tpl->setVariable("COM_VALUE", ilUtil::prepareFormOutput($data["comment"]));
74  $this->tpl->parseCurrentBlock();
75  }
76 
77  $this->tpl->setVariable("T_ROWS", ceil(strlen($data["translation"]) / $this->inputsize));
78  $this->tpl->setVariable("T_SIZE", $this->inputsize);
79  $this->tpl->setVariable("T_NAME", ilUtil::prepareFormOutput($data["name"]));
80  $this->tpl->setVariable("T_USER_VALUE", ilUtil::prepareFormOutput($data["translation"]));
81 
82  $this->tpl->setVariable("MODULE", ilUtil::prepareFormOutput($data["module"]));
83  $this->tpl->setVariable("TOPIC", ilUtil::prepareFormOutput($data["topic"]));
84 
85  $this->tpl->setVariable("DEFAULT_VALUE", ilUtil::prepareFormOutput($data["default"]));
86  $this->tpl->setVariable("COMMENT", ilUtil::prepareFormOutput($data["default_comment"]));
87  }
88 
92  function initFilter()
93  {
94  global $lng;
95 
96  // most filters are only
98  {
99  // pattern
100  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
101  $ti = new ilTextInputGUI($lng->txt("search"), "pattern");
102  $ti->setParent($this->parent_obj);
103  $ti->setMaxLength(64);
104  $ti->setSize(20);
105  $this->addFilterItem($ti);
106  $ti->readFromSession();
107 
108  // module
109  $options = array();
110  $options["all"] = $lng->txt("language_all_modules");
111  $modules = ilObjLanguageExt::_getModules($lng->getLangKey());
112  foreach ($modules as $mod)
113  {
114  $options[$mod] = $mod;
115  }
116 
117  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
118  $si = new ilSelectInputGUI(ucfirst($lng->txt("module")), "module");
119  $si->setParent($this->parent_obj);
120  $si->setOptions($options);
121  $this->addFilterItem($si);
122  $si->readFromSession();
123  if (!$si->getValue())
124  {
125  $si->setValue('administration');
126  }
127 
128  // mode
129  $options = array();
130  $options["all"] = $lng->txt("language_scope_global");
131  $options["changed"] = $lng->txt("language_scope_local");
132  if ($this->params['langmode'])
133  {
134  $options["added"] = $lng->txt("language_scope_added");
135  }
136  $options["unchanged"] = $lng->txt("language_scope_unchanged");
137  $options["equal"] = $lng->txt("language_scope_equal");
138  $options["different"] = $lng->txt("language_scope_different");
139  $options["commented"] = $lng->txt("language_scope_commented");
140  if ($this->params['langmode'])
141  {
142  $options["dbremarks"] = $lng->txt("language_scope_dbremarks");
143  }
144  $options["conflicts"] = $lng->txt("language_scope_conflicts");
145 
146  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
147  $si = new ilSelectInputGUI($lng->txt("filter"), "mode");
148  $si->setParent($this->parent_obj);
149  $si->setOptions($options);
150  $this->addFilterItem($si);
151  $si->readFromSession();
152  if (!$si->getValue())
153  {
154  $si->setValue('all');
155  }
156  }
157 
158  //compare
159  $options = array();
160  $langlist = $lng->getInstalledLanguages();
161  foreach ($langlist as $lang_key)
162  {
163  $options[$lang_key] = $lng->txt("meta_l_".$lang_key);
164  }
165 
166  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
167  $si = new ilSelectInputGUI($lng->txt("language_compare"), "compare");
168  $si->setParent($this->parent_obj);
169  $si->setOptions($options);
170  $this->addFilterItem($si);
171  $si->readFromSession();
172  if (!$si->getValue())
173  {
174  $si->setValue($lng->getDefaultLanguage());
175  }
176  }
177 }