ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjLanguageExtGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 define("ILIAS_LANGUAGE_MODULE", "Services/Language");
5 
6 require_once("classes/class.ilObjectGUI.php");
7 require_once("Services/Language/classes/class.ilObjLanguageAccess.php");
8 
9 
25 {
30  private $inputsize = 40;
31 
43  function ilObjLanguageExtGUI($a_data, $a_id = 0, $a_call_by_reference = false)
44  {
45  global $lng, $ilCtrl;
46 
47  // language maintenance strings are defined in administration
48  $lng->loadLanguageModule("administration");
49  $lng->loadLanguageModule("meta");
50 
51  // view mode ('translate' or empty) needed for prepareOutput()
52  $ilCtrl->saveParameter($this, "view_mode");
53 
54  // type and id of get the bound object
55  $this->type = "lng";
56  if (! $this->id = $_GET['obj_id'])
57  {
58  $this->id = ilObjLanguageAccess::_lookupId($lng->getUserLanguage());
59  }
60 
61  // do all generic GUI initialisations
62  $this->ilObjectGUI($a_data, $this->id, false, true);
63 
64  // initialize the array to store GUI session variables
65  if (!is_array($_SESSION[get_class($this)]))
66  {
67  $_SESSION[get_class($this)] = array();
68  }
69  $this->session =& $_SESSION[get_class($this)];
70  }
71 
72 
79  function assignObject()
80  {
81  require_once("Services/Language/classes/class.ilObjLanguageExt.php");
82  $this->object =& new ilObjLanguageExt($this->id);
83  }
84 
85 
89  function &executeCommand()
90  {
92  {
93  $this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
94  exit;
95  }
96 
97  $cmd = $this->ctrl->getCmd("view")."Object";
98  $this->$cmd();
99  exit;
100  }
101 
102 
106  function cancelObject()
107  {
108  $this->viewObject();
109  }
110 
114  function viewObject()
115  {
116  global $ilUser;
117 
118  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_edit_items.html", "Services/Language");
119 
120  // set the language to compare with
121  $compare = $this->getPar('compare', $this->lng->getDefaultLanguage());
122 
123  // get the default values if the compare language is the same
124  if ($compare == $this->object->key)
125  {
126  $compare_object = $this->object->getGlobalLanguageFile();
127  $compare_content = $compare_object->getAllValues();
128  $compare_comments = $compare_object->getAllComments();
129  $compare_note = " ". $this->lng->txt("language_default_entries");
130  }
131 
132  // page translation mode:
133  // - the table is filtered by a list of modules and topics
134  // - all found entries are shown on the same page
135  if ($this->_isPageTranslation())
136  {
137  $offset = 0;
138  $limit = 0;
139 
140  $modules = $this->getPar("page_modules", array());
141  $topics = $this->getPar("page_topics", array());
142 
143  if (!isset($compare_content))
144  {
145  $compare_content = ilObjLanguageExt::_getValues(
146  $compare, $modules, $topics);
147  }
148 
149  $translations = ilObjLanguageExt::_getValues(
150  $this->object->key, $modules, $topics);
151  }
152  // normal view mode:
153  // - the table is filtered manually by module, mode and pattern
154  // - found entries are paged by maximum list length
155  // - the filter selection is shown
156  else
157  {
158  $offset = $this->getPar('offset','0');
159  $limit = $ilUser->getPref("hits_per_page");
160 
161  $filter_mode = $this->getPar('filter_mode','all');
162  $filter_pattern = $this->getPar('filter_pattern','');
163  $filter_module = $this->getPar('filter_module','administration');
164  $filter_modules = $filter_module ? array($filter_module) : array();
165 
166  if (!isset($compare_content))
167  {
168  $compare_content = ilObjLanguageExt::_getValues(
169  $compare, $filter_modules);
170  }
171 
172  switch ($filter_mode)
173  {
174  case "changed":
175  $translations = $this->object->getChangedValues(
176  $filter_modules, $filter_pattern);
177  break;
178 
179  case "unchanged":
180  $translations = $this->object->getUnchangedValues(
181  $filter_modules, $filter_pattern);
182  break;
183 
184  case "commented":
185  $translations = $this->object->getCommentedValues(
186  $filter_modules, $filter_pattern);
187  break;
188 
189  case "equal":
190  $translations = $this->object->getAllValues(
191  $filter_modules, $filter_pattern);
192 
193  $translations = array_intersect_assoc($translations, $compare_content);
194  break;
195 
196  case "different":
197  $translations = $this->object->getAllValues(
198  $filter_modules, $filter_pattern);
199 
200  $translations = array_diff_assoc($translations, $compare_content);
201  break;
202 
203  case "conflicts":
204  $former_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang';
205  if (!is_readable($former_file))
206  {
207  ilUtil::sendFailure(sprintf($this->lng->txt("language_former_file_missing"), $former_file)
208  .'<br />'. $this->lng->txt("language_former_file_description") , false);
209  $translations = array();
210  break;
211  }
212  $global_file_obj = $this->object->getGlobalLanguageFile();
213  $former_file_obj = new ilLanguageFile($former_file);
214  $former_file_obj->read();
215  $global_changes = array_diff_assoc(
216  $global_file_obj->getAllValues(),
217  $former_file_obj->getAllValues());
218  if (!count($global_changes))
219  {
220  ilUtil::sendInfo(sprintf($this->lng->txt("language_former_file_equal"), $former_file)
221  .'<br />'. $this->lng->txt("language_former_file_description") , false);
222  $translations = array();
223  break;
224  }
225  $translations = $this->object->getChangedValues(
226  $filter_modules, $filter_pattern);
227 
228  $translations = array_intersect_key($translations, $global_changes);
229  break;
230 
231  case "all":
232  default:
233  $translations = $this->object->getAllValues(
234  $filter_modules, $filter_pattern);
235  }
236 
237  // show the filter section
238  $this->tpl->setCurrentBlock("filter");
239 
240  // filter by language module
241  $options = array();
242  $options[""] = $this->lng->txt("language_all_modules");
243  $modules = ilObjLanguageExt::_getModules($this->object->key);
244  foreach ($modules as $mod)
245  {
246  $options[$mod] = $mod;
247  }
248  $this->tpl->setVariable("SELECT_MODULE",
249  ilUtil::formSelect($filter_module, "filter_module", $options, false, true));
250 
251  // filter by mode
252  $options = array();
253  $options["all"] = $this->lng->txt("language_scope_global");
254  $options["changed"] = $this->lng->txt("language_scope_local");
255  $options["unchanged"] = $this->lng->txt("language_scope_unchanged");
256  $options["equal"] = $this->lng->txt("language_scope_equal");
257  $options["different"] = $this->lng->txt("language_scope_different");
258  $options["commented"] = $this->lng->txt("language_scope_commented");
259  $options["conflicts"] = $this->lng->txt("language_scope_conflicts");
260  $this->tpl->setVariable("SELECT_MODE",
261  ilUtil::formSelect($filter_mode, "filter_mode", $options, false, true));
262 
263  // filter by pattern
264  $this->tpl->setVariable("PATTERN_NAME", "filter_pattern");
265  $this->tpl->setVariable("PATTERN_VALUE", ilUtil::prepareFormOutput($filter_pattern));
266 
267  // and general filter variables
268  $this->tpl->setVariable("FILTER_ACTION", $this->ctrl->getFormAction($this));
269  $this->tpl->setVariable("TXT_FILTER", $this->lng->txt("filter"));
270  $this->tpl->setVariable("OFFSET_NAME", "offset");
271  $this->tpl->setVariable("OFFSET_VALUE", "0");
272  $this->tpl->setVariable("TXT_APPLY_FILTER", $this->lng->txt("apply_filter"));
273  $this->tpl->setVariable("CMD_FILTER", "view");
274  $this->tpl->parseCurrentBlock();
275  }
276 
277  // show the compare section
278  $this->tpl->setCurrentBlock("compare");
279  $this->tpl->setVariable("COMPARE_ACTION", $this->ctrl->getFormAction($this));
280  $this->tpl->setVariable("TXT_COMPARE", $this->lng->txt("language_compare"));
281  $this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("change"));
282  $options = array();
283  $langlist = $this->lng->getInstalledLanguages();
284  foreach ($langlist as $lang_key)
285  {
286  $options[$lang_key] = $this->lng->txt("meta_l_".$lang_key);
287  }
288  $this->tpl->setVariable("SELECT_COMPARE",
289  ilUtil::formSelect($compare, "compare", $options, false, true,1));
290  $this->tpl->setVariable("CMD_COMPARE", "view");
291  $this->tpl->parseCurrentBlock();
292 
293  // prepare the dataset for the output table
294  $sort_by = $this->getPar('sort_by','translation');
295  $sort_order = $this->getPar('sort_order','asc');
296 
297  $list = array();
298  foreach($translations as $name => $translation)
299  {
300  $keys = explode("#:#", $name);
301  $data = array();
302 
303  $data["module"] = $keys[0];
304  $data["topic"] = str_replace('_', ' ', $keys[1]);
305  $data["name"] = $name;
306  $data["translation"] = $translation;
307  $data["default"] = $compare_content[$name];
308  $data["comment"] = $compare_comments[$name];
309 
310  $list[] = $data;
311  }
312  $list = ilUtil::sortArray($list, $sort_by, $sort_order);
313  if ($limit > 0)
314  {
315  $list = array_slice($list, $offset, $limit);
316  }
317 
318  // create and configure the table object
319  include_once 'Services/Table/classes/class.ilTableGUI.php';
320  $tbl = new ilTableGUI();
321 
322  $tbl->disable('title');
323 
324  $tbl->setHeaderNames(array($this->lng->txt("module"),
325  $this->lng->txt("identifier"),
326  $this->lng->txt("meta_l_".$this->object->key),
327  $this->lng->txt("meta_l_".$compare).$compare_note));
328 
329  $tbl->setHeaderVars(array("module",
330  "topic",
331  "translation",
332  "default"),
333  $this->ctrl->getParameterArray($this));
334 
335 
336  $tbl->setColumnWidth(array( "10%",
337  "20%",
338  "40%",
339  "30%"));
340 
341  $tbl->setOrderColumn($sort_by);
342  $tbl->setOrderDirection($sort_order);
343  $tbl->setLimit($limit);
344  $tbl->setOffset($offset);
345  $tbl->setMaxCount(count($translations));
346 
347 
348  // prepare the table template
349  $tpl =& new ilTemplate("tpl.table.html", true, true);
350  $tpl->setCurrentBlock("tbl_form_header");
351  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
352  $tpl->parseCurrentBlock();
353 
354  $tpl->setCurrentBlock("tbl_action_btn");
355  $tpl->setVariable("BTN_NAME",'save');
356  $tpl->setVariable("BTN_VALUE",$this->lng->txt('save'));
357  $tpl->parseCurrentBlock();
358 
359  $tpl->setCurrentBlock("tbl_action_row");
360  $tpl->setVariable("COLUMN_COUNTS","4");
361  $tpl->parseCurrentBlock();
362 
363  // render the table rows
364  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.lang_items_row.html", "Services/Language");
365  foreach ($list as $data)
366  {
367  if (strlen($data["translation"]) <= $this->inputsize)
368  {
369  $tpl->setCurrentBlock("input");
370  $tpl->setVariable("I_NAME", ilUtil::prepareFormOutput($data["name"]));
371  $tpl->setVariable("I_SIZE", $this->inputsize);
372  $tpl->setVariable("I_USER_VALUE", ilUtil::prepareFormOutput($data["translation"]));
373  }
374  else
375  {
376  $tpl->setCurrentBlock("textarea");
377  $tpl->setVariable("T_ROWS", ceil(strlen($data["translation"]) / $this->inputsize));
378  $tpl->setVariable("T_SIZE", $this->inputsize);
379  $tpl->setVariable("T_NAME", ilUtil::prepareFormOutput($data["name"]));
380  $tpl->setVariable("T_USER_VALUE", ilUtil::prepareFormOutput($data["translation"]));
381  $tpl->parseCurrentBlock();
382  }
383 
384  $tpl->setCurrentBlock("row");
385  $tpl->setVariable("MODULE", ilUtil::prepareFormOutput($data["module"]));
386  $tpl->setVariable("TOPIC", ilUtil::prepareFormOutput($data["topic"]));
387  $tpl->setVariable("DEFAULT_VALUE", ilUtil::prepareFormOutput($data["default"]));
388  $tpl->setVariable("COMMENT", ilUtil::prepareFormOutput($data["comment"]));
389  $tpl->parseCurrentBlock();
390  }
391 
392  // render and show the table
393  $tbl->setTemplate($tpl);
394  $tbl->render();
395  $this->tpl->setVariable("TRANSLATION_TABLE", $tpl->get());
396  $this->tpl->show();
397  }
398 
399 
403  function saveObject()
404  {
405  // prepare the values to be saved
406  $save_array = array();
407  foreach ($_POST as $key => $value)
408  {
409  $keys = explode("#:#", ilUtil::stripSlashes($key, false));
410  if (count($keys) == 2)
411  {
412  // avoid line breaks
413  $value = preg_replace("/(\015\012)|(\015)|(\012)/","<br />",$value);
414  $value = ilUtil::stripSlashes($value, false);
415  $save_array[$key] = $value;
416  }
417  }
418 
419  // save the translations
420  ilObjLanguageExt::_saveValues($this->object->key, $save_array);
421 
422  // view the list
423  $this->viewObject();
424  }
425 
426 
430  function importObject()
431  {
432  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_file_import.html", "Services/Language");
433 
434  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
435  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("language_import_file"));
436  $this->tpl->setVariable("TXT_FILE",$this->lng->txt("file"));
437 
438  $this->tpl->setVariable("TXT_MODE",$this->lng->txt("language_mode_existing"));
439  $this->tpl->setVariable("TXT_MODE_KEEPALL",$this->lng->txt("language_mode_existing_keepall"));
440  $this->tpl->setVariable("TXT_MODE_KEEPNEW",$this->lng->txt("language_mode_existing_keepnew"));
441  $this->tpl->setVariable("TXT_MODE_REPLACE",$this->lng->txt("language_mode_existing_replace"));
442  $this->tpl->setVariable("TXT_MODE_DELETE",$this->lng->txt("language_mode_existing_delete"));
443 
444  $this->tpl->setVariable("TXT_UPLOAD",$this->lng->txt("upload"));
445  $this->tpl->setVariable("CMD_UPLOAD","upload");
446  $this->tpl->show();
447  }
448 
449 
453  function uploadObject()
454  {
455  if ($_POST['cmd']['upload'])
456  {
457  $file = $_FILES['userfile']['tmp_name'].'x';
458 
459  if (ilUtil::moveUploadedFile($_FILES['userfile']['tmp_name'],
460  $_FILES['userfile']['name'],
461  $file))
462  {
463  $this->object->importLanguageFile($file,$_POST['mode_existing']);
464  ilUtil::sendSuccess(sprintf($this->lng->txt("language_file_imported"), $_FILES['userfile']['name']) , false);
465  $this->importObject();
466  }
467  else
468  {
469  $this->importObject();
470  }
471  }
472  else
473  {
474  $this->cancelObject();
475  }
476  }
477 
478 
482  function exportObject()
483  {
484  $scope = $_POST["scope"] ? $_POST["scope"] : "global";
485 
486  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_file_export.html", "Services/Language");
487 
488  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
489  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("language_export_file"));
490 
491  $this->tpl->setVariable("TXT_SCOPE",$this->lng->txt("language_file_scope"));
492  $this->tpl->setVariable("TXT_SCOPE_GLOBAL",$this->lng->txt("language_scope_global"));
493  $this->tpl->setVariable("TXT_SCOPE_LOCAL",$this->lng->txt("language_scope_local"));
494  $this->tpl->setVariable("TXT_SCOPE_UNCHANGED",$this->lng->txt("language_scope_unchanged"));
495 
496  $this->tpl->setVariable("CHECKED_GLOBAL",$scope == 'global' ? 'checked="checked"' : '');
497  $this->tpl->setVariable("CHECKED_LOCAL",$scope == 'local' ? 'checked="checked"' : '');
498  $this->tpl->setVariable("CHECKED_UNCHANGED",$scope == 'unchanged' ? 'checked="checked"' : '');
499 
500  $this->tpl->setVariable("TXT_DOWNLOAD",$this->lng->txt("download"));
501  $this->tpl->setVariable("CMD_DOWNLOAD","download");
502  $this->tpl->show();
503  }
504 
505 
509  function downloadObject()
510  {
511  $filename = 'ilias_' . $this->object->key . '_'
512  . str_replace(".", "_", substr(ILIAS_VERSION, 0, strpos(ILIAS_VERSION, " ")))
513  . "-" . date('Y-m-d')
514  . ".lang.".$_POST["scope"];
515 
516  $global_file_obj = $this->object->getGlobalLanguageFile();
517  $local_file_obj = new ilLanguageFile($filename, $this->object->key, $_POST["scope"]);
518 
519  if ($_POST["scope"] == 'global')
520  {
521  $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
522  $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
523  $local_file_obj->setAllValues($this->object->getAllValues());
524  }
525  elseif ($_POST["scope"] == 'local')
526  {
527  $local_file_obj->setParam("based_on", $global_file_obj->getParam('version'));
528  $local_file_obj->setAllValues($this->object->getChangedValues());
529  }
530  elseif ($_POST["scope"] == 'unchanged')
531  {
532  $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
533  $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
534  $local_file_obj->setAllValues($this->object->getUnchangedValues());
535  }
536 
537  ilUtil::deliverData($local_file_obj->build(), $filename);
538  }
539 
540 
544  function maintainObject()
545  {
546  global $ilUser;
547 
548  switch ($_POST["maintain"])
549  {
550  // save the local changes to the local language file
551  case "save":
552  $lang_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang.local';
553 
554  if ((is_file($lang_file) and is_writable($lang_file))
555  or (!file_exists($lang_file) and is_writable($this->object->getCustLangPath())))
556  {
557  // save a copy of the distributed language file
558  $orig_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
559  $copy_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang';
560  @copy($orig_file, $copy_file);
561 
562  // save a backup of the old local language file
563  @rename($lang_file, $lang_file.".bak");
564 
565  // create and write the new local language file
566  $global_file_obj = $this->object->getGlobalLanguageFile();
567  $local_file_obj = new ilLanguageFile($lang_file, $this->object->key, 'local');
568  $local_file_obj->setParam('based_on', $global_file_obj->getParam('version'));
569  $local_file_obj->setAllValues($this->object->getChangedValues());
570  $local_file_obj->write();
571 
572  $this->object->setLocal(true);
573  ilUtil::sendSuccess($this->lng->txt("language_saved_local") , false);
574  }
575  else
576  {
577  ilUtil::sendFailure($this->lng->txt("language_error_write_local") , false);
578  }
579  break;
580 
581  // load the content of the local language file
582  case "load":
583  $lang_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang.local';
584  if (is_file($lang_file) and is_readable($lang_file))
585  {
586  $this->object->importLanguageFile($lang_file, 'replace');
587  $this->object->setLocal(true);
588  ilUtil::sendSuccess($this->lng->txt("language_loaded_local") , false);
589  }
590  else
591  {
592  ilUtil::sendFailure($this->lng->txt("language_error_read_local") , false);
593  }
594  break;
595 
596  // revert the database to the default language file
597  case "clear":
598  $lang_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
599  if (is_file($lang_file) and is_readable($lang_file))
600  {
601  $this->object->importLanguageFile($lang_file, 'delete');
602  $this->object->setLocal(false);
603  ilUtil::sendSuccess($this->lng->txt("language_cleared_local") , false);
604  }
605  else
606  {
607  ilUtil::sendFailure($this->lng->txt("language_error_clear_local") , false);
608  }
609  break;
610  }
611 
612  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_maintenance.html", "Services/Language");
613  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
614  $this->tpl->setVariable("TXT_MAINTENANCE",$this->lng->txt("language_maintenance"));
615  $this->tpl->setVariable("TXT_MAINTAIN_LOCAL",$this->lng->txt("language_maintain_local_changes"));
616  $this->tpl->setVariable("TXT_SELECT",$this->lng->txt("please_select"));
617  $this->tpl->setVariable("TXT_SAVE",$this->lng->txt("language_save_local_changes"));
618  $this->tpl->setVariable("TXT_LOAD",$this->lng->txt("language_load_local_changes"));
619  $this->tpl->setVariable("TXT_CLEAR",$this->lng->txt("language_clear_local_changes"));
620  $this->tpl->setVariable("TXT_NOTE_SAVE",$this->lng->txt("language_note_save_local"));
621  $this->tpl->setVariable("TXT_MAINTAIN",$this->lng->txt("language_process_maintenance"));
622  $this->tpl->setVariable("VAR_MAINTAIN", "maintain");
623  $this->tpl->setVariable("CMD_MAINTAIN", "maintain");
624  $this->tpl->show();
625  }
626 
630  function settingsObject()
631  {
632  global $ilSetting;
633 
634  $translate_key = "lang_translate_". $this->object->key;
635 
636  // save and get the page translation setting
637  switch ($_POST["translation"])
638  {
639  case "enable":
640  $ilSetting->set($translate_key, true);
641  break;
642  case "disable":
643  $ilSetting->set($translate_key, false);
644  }
645  $translate = $ilSetting->get($translate_key, false);
646 
647  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_settings.html", "Services/Language");
648 
649  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
650  $this->tpl->setVariable("TXT_SETTINGS",$this->lng->txt("language_settings"));
651  $this->tpl->setVariable("TXT_TRANSLATION",$this->lng->txt("language_translation_mode"));
652  $this->tpl->setVariable("TXT_TRANSLATION_ENABLED",$this->lng->txt("language_translation_enabled"));
653  $this->tpl->setVariable("TXT_TRANSLATION_DISABLED",$this->lng->txt("language_translation_disabled"));
654  $this->tpl->setVariable("CHECKED_ENABLE", $translate ? 'checked="checked"': '');
655  $this->tpl->setVariable("CHECKED_DISABLE", $translate ? '' : 'checked="checked"');
656  $this->tpl->setVariable("TXT_NOTE_TRANSLATION",$this->lng->txt("language_note_translation"));
657  $this->tpl->setVariable("TXT_CHANGE_SETTINGS",$this->lng->txt("language_change_settings"));
658  $this->tpl->setVariable("CMD_SETTINGS", "settings");
659  $this->tpl->show();
660  }
661 
665  function statisticsObject()
666  {
667  $modules = ilObjLanguageExt::_getModules($this->object->key);
668 
669  $data = array();
670  $total = array("",0,0,0);
671  foreach($modules as $module)
672  {
673  $row = array();
674  $row[0] = $module;
675  $row[1] = count($this->object->getAllValues(array($module)));
676  $row[2] = count($this->object->getChangedValues(array($module)));
677  $row[3] = $row[1]-$row[2];
678  $total[1] += $row[1];
679  $total[2] += $row[2];
680  $total[3] += $row[3];
681  $data[] = $row;
682  }
683  $total[0] = "<b>".$this->lng->txt("language_all_modules")."</b>";
684  $total[1] = "<b>".$total[1]."</b>";
685  $total[2] = "<b>".$total[2]."</b>";
686  $total[3] = "<b>".$total[3]."</b>";
687  $data[] = $total;
688 
689  // prepare the templates for output
690  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_statistics.html", "Services/Language");
691  $this->tpl->addBlockFile("TABLE_STATISTICS", "table_statistics", "tpl.table.html");
692  $this->tpl->addBlockFile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
693 
694  // create and configure the table object
695  include_once 'Services/Table/classes/class.ilTableGUI.php';
696  $tbl = new ilTableGUI();
697  $tbl->disable('title');
698  $tbl->disable('sort');
699  $tbl->disable('numinfo');
700 
701  $tbl->setHeaderNames(array($this->lng->txt("module"),
702  $this->lng->txt("language_scope_global"),
703  $this->lng->txt("language_scope_local"),
704  $this->lng->txt("language_scope_unchanged")));
705  $tbl->setColumnWidth(array( "25%", "25%", "25%", "25%"));
706  $tbl->setLimit(count($data));
707  $tbl->setData($data);
708 
709  // show the table
710  $tbl->render();
711  $this->tpl->show();
712  }
713 
714 
724  function getPar($a_request_name, $a_default_value)
725  {
726  // get the parameter value
727  if (isset($_GET[$a_request_name]))
728  {
729  $param = $_GET[$a_request_name];
730  $from_request = true;
731  }
732  elseif (isset($_POST[$a_request_name]))
733  {
734  $param = $_POST[$a_request_name];
735  $from_request = true;
736  }
737  elseif (isset($this->session[$a_request_name]))
738  {
739  $param = $this->session[$a_request_name];
740  $from_request = false;
741  }
742  else
743  {
744  $param = $a_default_value;
745  $from_request = false;
746  }
747 
748  // strip slashes from request parameters
749  if ($from_request)
750  {
751  if (is_array($param))
752  {
753  foreach ($param as $key => $value)
754  {
755  $param[$key] = ilUtil::stripSlashes($value);
756  }
757  }
758  else
759  {
761  }
762  }
763 
764  // make the parameter available to further requests
765  $this->session[$a_request_name] = $param;
766 
767  return $param;
768  }
769 
774  function getAdminTabs(&$tabs_gui)
775  {
776  global $rbacsystem;
777 
778  $tabs_gui->addTarget("edit",
779  $this->ctrl->getLinkTarget($this, "view"),
780  array("","view","cancel","save"));
781 
782  $tabs_gui->addTarget("export",
783  $this->ctrl->getLinkTarget($this, "export"),
784  array("export","download"));
785 
786  $tabs_gui->addTarget("import",
787  $this->ctrl->getLinkTarget($this, "import"),
788  array("import","upload"));
789 
790  $tabs_gui->addTarget("language_maintain",
791  $this->ctrl->getLinkTarget($this, "maintain"),
792  array("maintain"));
793 
794  $tabs_gui->addTarget("settings",
795  $this->ctrl->getLinkTarget($this, "settings"),
796  array("settings"));
797 
798  $tabs_gui->addTarget("language_statistics",
799  $this->ctrl->getLinkTarget($this, "statistics"),
800  array("statistics"));
801  }
802 
803 
808  function prepareOutput()
809  {
810  if ($this->_isPageTranslation())
811  {
812  // show the pure translation page without menu, tabs etc.
813  $this->tpl->addBlockFile("CONTENT","content","tpl.adm_translate.html","Services/Language");
814  $this->tpl->setHeaderPageTitle($this->lng->txt("translation"));
815  $this->tpl->setTitle($this->lng->txt("translation"). " "
816  .$this->lng->txt("meta_l_".$this->object->key));
817  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lng_b.gif"),
818  $this->lng->txt("obj_" . $this->object->getType()));
819  }
820  else
821  {
822  // show the full page framework
824  }
825  }
826 
827 
833  {
834  global $ilLocator, $tpl;
835 
836  $ilLocator->addItem($this->lng->txt("administration"),
837  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
838  ilFrameTargetInfo::_getFrame("MainContent"));
839 
840  $ilLocator->addItem($this->lng->txt("languages"),
841  $this->ctrl->getLinkTargetByClass("ilobjlanguagefoldergui", ""));
842 
843  $ilLocator->addItem($this->lng->txt("meta_l_". $this->object->getTitle()),
844  $this->ctrl->getLinkTarget($this, "view"));
845  }
846 
847 
853  {
854  $this->tpl->setTitle($this->lng->txt("meta_l_".$this->object->getTitle()));
855  // $this->tpl->setDescription($this->object->getLongDescription());
856  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.gif"), $this->lng->txt("obj_" . $this->object->getType()));
857  }
858 
859 
860  //
861  // STATIC FUNCTIONS
862  //
863 
876  public static function _isPageTranslation()
877  {
878  return ($_GET['view_mode'] == "translate");
879  }
880 
881 
890  public static function _getTranslationLink()
891  {
892  global $ilSetting, $lng;
893 
894  // prevent translation link on translation screen
895  // check setting of translation mode
896  if (self::_isPageTranslation()
897  or !$ilSetting->get("lang_translate_".$lng->getLangKey()))
898  {
899  return "";
900  }
901 
902  // set the target for translation
903  // ref id must be given to prevent params being deleted by ilAdministrtionGUI
904  $action = "ilias.php"
905  ."?ref_id=".ilobjLanguageAccess::_lookupLangFolderRefId()
906  ."&baseClass=ilAdministrationGUI"
907  ."&cmdClass=ilobjlanguageextgui"
908  ."&view_mode=translate";
909 
910  $tpl = new ilTemplate("tpl.translation_link.html",true,true, "Services/Language");
911 
912  foreach($lng->getUsedModules() as $module => $dummy)
913  {
914  $tpl->setCurrentBlock("hidden");
915  $tpl->setVariable("NAME", "page_modules[]");
916  $tpl->setVariable("VALUE", ilUtil::prepareFormOutput($module));
917  $tpl->parseCurrentBlock();
918  }
919 
920  foreach($lng->getUsedTopics() as $topic => $dummy)
921  {
922  $tpl->setCurrentBlock("hidden");
923  $tpl->setVariable("NAME", "page_topics[]");
924  $tpl->setVariable("VALUE", ilUtil::prepareFormOutput($topic));
925  $tpl->parseCurrentBlock();
926  }
927 
928  $tpl->setVariable("ACTION", $action);
929  $tpl->setVariable("TXT_TRANSLATE",$lng->txt("translation"));
930 
931  return $tpl->get();
932  }
933 
934 
935 } // END class.ilObjLanguageExtGUI
936 ?>