4 define(
"ILIAS_LANGUAGE_MODULE",
"Services/Language");
6 require_once(
"./Services/Object/classes/class.ilObjectGUI.php");
7 require_once(
"Services/Language/classes/class.ilObjLanguageAccess.php");
42 $lng->loadLanguageModule(
"administration");
43 $lng->loadLanguageModule(
"meta");
46 $ilCtrl->saveParameter($this,
"view_mode");
50 if (! $this->
id =
$_GET[
'obj_id'])
56 $this->
ilObjectGUI($a_data, $this->
id,
false,
true);
59 if (!is_array(
$_SESSION[
'lang_ext_maintenance']))
61 $_SESSION[
'lang_ext_maintenance'] = array();
63 $this->session =&
$_SESSION[
'lang_ext_maintenance'];
67 $this->langmode = $ilClientIniFile->readVariable(
"system",
"LANGMODE");
79 require_once(
"Services/Language/classes/class.ilObjLanguageExt.php");
101 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
105 $cmd = $this->ctrl->getCmd(
"view").
"Object";
108 $ilHelp->setScreenIdComponent(
"lng");
128 include_once
'./Services/Language/classes/class.ilLanguageExtTableGUI.php';
130 'langmode' => $this->langmode,
131 'lang_key'=> $this->object->key,
148 $comments = $this->
object->getAllRemarks();
152 $compare = $table_gui->getFilterItemByPostVar(
'compare')->getValue();
153 if ($compare == $this->object->key)
155 $compare_object = $this->
object->getGlobalLanguageFile();
156 $compare_content = $compare_object->getAllValues();
157 $compare_comments = $compare_object->getAllComments();
169 if (
$_GET[
'reset_offset'])
171 $table_gui->resetOffset();
174 if (!isset($compare_content))
177 $compare, $modules, $topics);
183 $this->object->key, $modules, $topics);
187 foreach($translations as $name => $translation)
189 $keys = explode($this->lng->separator, $name);
190 $db_found[] = $keys[1];
192 $missing_entries = array_diff($topics, $db_found);
198 $filter_mode = $table_gui->getFilterItemByPostVar(
'mode')->getValue();
199 $filter_pattern = $table_gui->getFilterItemByPostVar(
'pattern')->getValue();
200 $filter_module = $table_gui->getFilterItemByPostVar(
'module')->getValue();
201 $filter_module = $filter_module ==
'all' ?
'' : $filter_module;
202 $filter_modules = $filter_module ? array($filter_module) : array();
204 if (!isset($compare_content))
207 $compare, $filter_modules);
212 switch ($filter_mode)
215 $translations = $this->
object->getChangedValues(
216 $filter_modules, $filter_pattern);
220 $translations = $this->
object->getAddedValues(
221 $filter_modules, $filter_pattern);
225 $translations = $this->
object->getUnchangedValues(
226 $filter_modules, $filter_pattern);
230 $translations = $this->
object->getCommentedValues(
231 $filter_modules, $filter_pattern);
235 $translations = $this->
object->getAllValues(
236 $filter_modules, $filter_pattern);
238 $translations = array_intersect_key($translations, $remarks);
242 $translations = $this->
object->getAllValues(
243 $filter_modules, $filter_pattern);
245 $translations = array_intersect_assoc($translations, $compare_content);
249 $translations = $this->
object->getAllValues(
250 $filter_modules, $filter_pattern);
252 $translations = array_diff_assoc($translations, $compare_content);
256 $former_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
257 if (!is_readable($former_file))
260 .
'<br />'. $this->lng->txt(
"language_former_file_description") ,
false);
261 $translations = array();
264 $global_file_obj = $this->
object->getGlobalLanguageFile();
266 $former_file_obj->read();
267 $global_changes = array_diff_assoc(
268 $global_file_obj->getAllValues(),
269 $former_file_obj->getAllValues());
270 if (!count($global_changes))
272 ilUtil::sendInfo(sprintf($this->lng->txt(
"language_former_file_equal"), $former_file)
273 .
'<br />'. $this->lng->txt(
"language_former_file_description") ,
false);
274 $translations = array();
277 $translations = $this->
object->getChangedValues(
278 $filter_modules, $filter_pattern);
280 $translations = array_intersect_key($translations, $global_changes);
285 $translations = $this->
object->getAllValues(
286 $filter_modules, $filter_pattern);
292 foreach($translations as $name => $translation)
294 $keys = explode($this->lng->separator, $name);
297 $row[
"module"] = $keys[0];
298 $row[
"topic"] = $keys[1];
299 $row[
"name"] = $name;
300 $row[
"translation"] = $translation;
301 $row[
"comment"] = $comments[$name];
302 $row[
"default"] = $compare_content[$name];
303 $row[
"default_comment"] = $compare_comments[$name];
309 $table_gui->setData(
$data);
310 $tpl->setContent($table_gui->getHTML().
320 $table_gui->writeFilterToSession();
321 $table_gui->resetOffset();
331 $table_gui->resetOffset();
332 $table_gui->resetFilter();
342 $save_array = array();
343 $remarks_array = array();
344 foreach (
$_POST as $key => $value)
348 if (count($keys) == 2)
351 $value = preg_replace(
"/(\015\012)|(\015)|(\012)/",
"<br />",$value);
353 $save_array[$key] = $value;
355 $remarks_array[$key] =
$_POST[$key.$this->lng->separator.
"comment"];
372 require_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
374 $form->setFormAction($this->ctrl->getFormAction($this));
375 $form->setTitle($this->lng->txt(
"language_import_file"));
376 $form->addCommandButton(
'upload',$this->lng->txt(
"upload"));
382 $ro =
new ilRadioOption($this->lng->txt(
"language_mode_existing_keepall"),
"keepall");
383 $ro->
setInfo($this->lng->txt(
"language_mode_existing_keepall_info"));
385 $ro =
new ilRadioOption($this->lng->txt(
"language_mode_existing_keepnew"),
"keepnew");
386 $ro->
setInfo($this->lng->txt(
"language_mode_existing_keepnew_info"));
388 $ro =
new ilRadioOption($this->lng->txt(
"language_mode_existing_replace"),
"replace");
389 $ro->
setInfo($this->lng->txt(
"language_mode_existing_replace_info"));
391 $ro =
new ilRadioOption($this->lng->txt(
"language_mode_existing_delete"),
"delete");
392 $ro->
setInfo($this->lng->txt(
"language_mode_existing_delete_info"));
394 $rg->setValue($this->session[
"import"][
"mode_existing"] ? $this->session[
"import"][
"mode_existing"] :
"keepall");
397 $this->tpl->setContent($form->getHTML());
409 if (
$_POST[
'cmd'][
'upload'])
411 $file = $_FILES[
'userfile'][
'tmp_name'].
'x';
414 $_FILES[
'userfile'][
'name'],
417 $this->
object->importLanguageFile(
$file,
$_POST[
'mode_existing']);
418 ilUtil::sendSuccess(sprintf($this->lng->txt(
"language_file_imported"), $_FILES[
'userfile'][
'name']) ,
true);
422 $this->ctrl->redirect($this,
'import');
431 require_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
433 $form->setFormAction($this->ctrl->getFormAction($this));
434 $form->setTitle($this->lng->txt(
"language_export_file"));
435 $form->setPreventDoubleSubmission(
false);
436 $form->addCommandButton(
'download',$this->lng->txt(
"download"));
439 $ro =
new ilRadioOption($this->lng->txt(
"language_scope_global"),
"global");
440 $ro->
setInfo($this->lng->txt(
"language_scope_global_info"));
442 $ro =
new ilRadioOption($this->lng->txt(
"language_scope_local"),
"local");
443 $ro->
setInfo($this->lng->txt(
"language_scope_local_info"));
447 $ro =
new ilRadioOption($this->lng->txt(
"language_scope_added"),
"added");
448 $ro->
setInfo($this->lng->txt(
"language_scope_added_info"));
451 $ro =
new ilRadioOption($this->lng->txt(
"language_scope_unchanged"),
"unchanged");
452 $ro->
setInfo($this->lng->txt(
"language_scope_unchanged_info"));
456 $ro =
new ilRadioOption($this->lng->txt(
"language_scope_merged"),
"merged");
457 $ro->
setInfo($this->lng->txt(
"language_scope_merged_info"));
461 $rg->setValue($this->session[
"export"][
"scope"] ? $this->session[
"export"][
"scope"] :
"global");
464 $this->tpl->setContent($form->getHTML());
476 $filename =
'ilias_' . $this->
object->key .
'_'
478 .
"-" . date(
'Y-m-d')
479 .
".lang.".$this->session[
"export"][
"scope"];
481 $global_file_obj = $this->
object->getGlobalLanguageFile();
484 if (
$_POST[
"scope"] ==
'global')
486 $local_file_obj->setParam(
"author", $global_file_obj->getParam(
'author'));
487 $local_file_obj->setParam(
"version", $global_file_obj->getParam(
'version'));
488 $local_file_obj->setAllValues($this->object->getAllValues());
491 $local_file_obj->setAllComments($this->object->getAllRemarks());
494 elseif (
$_POST[
"scope"] ==
'local')
496 $local_file_obj->setParam(
"based_on", $global_file_obj->getParam(
'version'));
497 $local_file_obj->setAllValues($this->object->getChangedValues());
500 $local_file_obj->setAllComments($this->object->getAllRemarks());
503 elseif (
$_POST[
"scope"] ==
'added')
505 $local_file_obj->setParam(
"author", $global_file_obj->getParam(
'author'));
506 $local_file_obj->setParam(
"version", $global_file_obj->getParam(
'version'));
507 $local_file_obj->setAllValues($this->object->getAddedValues());
508 $local_file_obj->setAllComments($this->object->getAllRemarks());
510 elseif (
$_POST[
"scope"] ==
'unchanged')
512 $local_file_obj->setParam(
"author", $global_file_obj->getParam(
'author'));
513 $local_file_obj->setParam(
"version", $global_file_obj->getParam(
'version'));
514 $local_file_obj->setAllValues($this->object->getUnchangedValues());
517 $local_file_obj->setAllComments($this->object->getAllRemarks());
520 elseif (
$_POST[
"scope"] ==
'merged')
522 $local_file_obj->setParam(
"author", $global_file_obj->getParam(
'author'));
523 $local_file_obj->setParam(
"version", $global_file_obj->getParam(
'version'));
524 $local_file_obj->setAllValues($this->object->getMergedValues());
525 $local_file_obj->setAllComments($this->object->getMergedRemarks());
537 require_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
539 $form->setFormAction($this->ctrl->getFormAction($this));
540 $form->setTitle($this->lng->txt(
"language_maintenance"));
541 $form->setPreventDoubleSubmission(
false);
542 $form->addCommandButton(
'maintainExecute',$this->lng->txt(
"language_process_maintenance"));
545 $ro =
new ilRadioOption($this->lng->txt(
"language_save_local_changes"),
"save");
546 $ro->
setInfo(sprintf($this->lng->txt(
"language_save_local_changes_info"),$this->
object->key));
548 $ro =
new ilRadioOption($this->lng->txt(
"language_load_local_changes"),
"load");
549 $ro->
setInfo(sprintf($this->lng->txt(
"language_load_local_changes_info"),$this->
object->key));
551 $ro =
new ilRadioOption($this->lng->txt(
"language_clear_local_changes"),
"clear");
552 $ro->
setInfo(sprintf($this->lng->txt(
"language_clear_local_changes_info"),$this->
object->key));
556 $ro =
new ilRadioOption($this->lng->txt(
"language_delete_local_additions"),
"delete_added");
557 $ro->
setInfo(sprintf($this->lng->txt(
"language_delete_local_additions_info"), $this->
object->key));
559 $ro =
new ilRadioOption($this->lng->txt(
"language_merge_local_changes"),
"merge");
560 $ro->
setInfo(sprintf($this->lng->txt(
"language_merge_local_changes_info"), $this->
object->key));
562 $ro =
new ilRadioOption($this->lng->txt(
"language_remove_local_file"),
"remove_local_file");
563 $ro->
setInfo(sprintf($this->lng->txt(
"language_remove_local_file_info"), $this->
object->key));
566 $rg->setValue($this->session[
"maintain"]);
569 $this->tpl->setContent($form->getHTML());
575 if (isset(
$_POST[
"maintain"]))
580 switch (
$_POST[
"maintain"])
584 $lang_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang.local';
586 if ((is_file($lang_file) and is_writable($lang_file))
587 or (!file_exists($lang_file) and is_writable($this->object->getCustLangPath())))
590 $orig_file = $this->
object->getLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
591 $copy_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
592 @copy($orig_file, $copy_file);
595 @rename($lang_file, $lang_file.
".bak");
598 $global_file_obj = $this->
object->getGlobalLanguageFile();
599 $local_file_obj =
new ilLanguageFile($lang_file, $this->object->key,
'local');
600 $local_file_obj->setParam(
'based_on', $global_file_obj->getParam(
'version'));
601 $local_file_obj->setAllValues($this->object->getChangedValues());
604 $local_file_obj->setAllComments($this->object->getAllRemarks());
606 $local_file_obj->write();
608 $this->
object->setLocal(
true);
619 $lang_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang.local';
620 if (is_file($lang_file) and is_readable($lang_file))
622 $this->
object->importLanguageFile($lang_file,
'replace');
623 $this->
object->setLocal(
true);
634 $lang_file = $this->
object->getLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
635 if (is_file($lang_file) and is_readable($lang_file))
637 $this->
object->importLanguageFile($lang_file,
'delete');
638 $this->
object->setLocal(
false);
655 $orig_file = $this->
object->getLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
656 $copy_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
658 if (is_file($orig_file) and is_writable($orig_file))
661 @copy($orig_file, $copy_file);
664 $global_file_obj = $this->
object->getGlobalLanguageFile();
665 $global_file_obj->setAllValues($this->object->getMergedValues());
666 $global_file_obj->setAllComments($this->object->getMergedRemarks());
667 $global_file_obj->write();
677 case "remove_local_file":
678 $lang_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang.local';
680 if (!is_file($lang_file))
682 $this->
object->setLocal(
false);
685 elseif (@unlink($lang_file))
687 $this->
object->setLocal(
false);
697 $this->ctrl->redirect($this,
"maintain");
707 $translate_key =
"lang_translate_". $this->
object->key;
712 $ilSetting->set($translate_key, (
bool)
$_POST[
"translation"]);
715 $translate = $ilSetting->get($translate_key,
false);
717 require_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
719 $form->setFormAction($this->ctrl->getFormAction($this));
720 $form->setTitle($this->lng->txt(
"language_settings"));
721 $form->setPreventDoubleSubmission(
false);
722 $form->addCommandButton(
'settings',$this->lng->txt(
"language_change_settings"));
724 $ci =
new ilCheckboxInputGUI($this->lng->txt(
"language_translation_enabled"),
"translation");
726 $ci->setInfo($this->lng->txt(
"language_note_translation"));
729 $this->tpl->setContent($form->getHTML());
740 $total = array(
"module"=>
'',
"all"=>0,
"changed"=>0,
"unchanged"=>0);
741 foreach($modules as $module)
744 $row[
'module'] = $module;
745 $row[
'all'] = count($this->object->getAllValues(array($module)));
746 $row[
'changed'] = count($this->object->getChangedValues(array($module)));
747 $row[
'unchanged'] = $row[
'all']-$row[
'changed'];
748 $total[
'all'] += $row[
'all'];
749 $total[
'changed'] += $row[
'changed'];
750 $total[
'unchanged'] += $row[
'unchanged'];
753 $total[
'module'] =
"<b>".$this->lng->txt(
"language_all_modules").
"</b>";
754 $total[
'all'] =
"<b>".$total[
'all'].
"</b>";
755 $total[
'changed'] =
"<b>".$total[
'changed'].
"</b>";
756 $total[
'unchanged'] =
"<b>".$total[
'unchanged'].
"</b>";
760 include_once
'Services/Table/classes/class.ilTable2GUI.php';
762 $table_gui->setRowTemplate(
"tpl.lang_statistics_row.html",
"Services/Language");
763 $table_gui->setEnableTitle(
false);
764 $table_gui->setEnableNumInfo(
false);
765 $table_gui->setLimit(count(
$data));
768 $table_gui->addColumn(ucfirst($this->lng->txt(
"module")),
"",
"25%");
769 $table_gui->addColumn($this->lng->txt(
"language_scope_global"),
"",
"25%");
770 $table_gui->addColumn($this->lng->txt(
"language_scope_local"),
"",
"25%");
771 $table_gui->addColumn($this->lng->txt(
"language_scope_unchanged"),
"",
"25%");
773 $table_gui->setData(
$data);
775 $this->tpl->setContent($table_gui->getHTML());
789 $tabs_gui->addTarget(
"edit",
790 $this->ctrl->getLinkTarget($this,
"view"),
791 array(
"",
"view",
"cancel",
"save"));
793 $tabs_gui->addTarget(
"export",
794 $this->ctrl->getLinkTarget($this,
"export"),
795 array(
"export",
"download"));
797 $tabs_gui->addTarget(
"import",
798 $this->ctrl->getLinkTarget($this,
"import"),
799 array(
"import",
"upload"));
801 $tabs_gui->addTarget(
"language_maintain",
802 $this->ctrl->getLinkTarget($this,
"maintain"),
805 $tabs_gui->addTarget(
"settings",
806 $this->ctrl->getLinkTarget($this,
"settings"),
809 $tabs_gui->addTarget(
"language_statistics",
810 $this->ctrl->getLinkTarget($this,
"statistics"),
811 array(
"statistics"));
828 $ilLocator->addItem($this->lng->txt(
"languages"),
829 $this->ctrl->getLinkTargetByClass(
"ilobjlanguagefoldergui",
""));
831 $ilLocator->addItem($this->lng->txt(
"meta_l_". $this->object->getTitle()),
832 $this->ctrl->getLinkTarget($this,
"view"));
845 $this->tpl->setHeaderPageTitle($this->lng->txt(
"translation"));
846 $this->tpl->setTitle($this->lng->txt(
"translation").
" ".$this->lng->txt(
"meta_l_".$this->object->key));
850 $this->tpl->setTitle($this->lng->txt(
"meta_l_".$this->object->key));
852 $this->tpl->setTitleIcon(
ilUtil::getImagePath(
"icon_lngf.svg"), $this->lng->txt(
"obj_" . $this->object->getType()));
864 if(!is_array($a_missing) ||
870 $res = array(
'<h3>'.$this->lng->txt(
"adm_missing_entries").
'</h3>',
'<ul>');
872 foreach($a_missing as $entry)
874 $ilCtrl->setParameter($this,
"eid", $entry);
875 $res[] =
'<li>'.$entry.
876 ' <a href="'.$ilCtrl->getLinkTarget($this,
"addNewEntry").
877 '">'.$this->lng->txt(
"adm_missing_entry_add_action").
'</a></li>';
878 $ilCtrl->setParameter($this,
"eid",
"");
883 return implode(
"\n",
$res);
890 $id = trim(
$_GET[
"eid"]);
897 $tpl->setContent($a_form->getHTML());
912 $ilCtrl->redirect($this,
"view");
915 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
917 $form->setFormAction($ilCtrl->getFormAction($this,
"saveNewEntry"));
918 $form->setTitle($this->lng->txt(
"adm_missing_entry_add"));
921 $options = array_combine($mods, $mods);
924 $mod->setOptions(array(
""=>$this->lng->txt(
"please_select"))+
$options);
925 $mod->setRequired(
true);
926 $form->addItem($mod);
928 $id =
new ilTextInputGUI(ucfirst($this->lng->txt(
"identifier")),
"id");
929 $id->setValue($a_id);
930 $id->setDisabled(
true);
933 foreach ($this->lng->getInstalledLanguages() as $lang_key)
935 $trans =
new ilTextInputGUI($this->lng->txt(
"meta_l_".$lang_key),
"trans_".$lang_key);
936 if(in_array($lang_key, array(
"de",
"en")))
940 $form->addItem($trans);
943 $form->addCommandButton(
"saveNewEntry", $this->lng->txt(
"save"));
944 $form->addCommandButton(
"view", $this->lng->txt(
"cancel"));
954 if($form->checkInput())
956 $mod = $form->getInput(
"mod");
957 $id = $form->getInput(
"id");
960 foreach ($this->lng->getInstalledLanguages() as $lang_key)
962 $trans = trim($form->getInput(
"trans_".$lang_key));
976 $set = $ilDB->query(
"SELECT lang_array FROM lng_modules".
977 " WHERE lang_key = ".$ilDB->quote($lang_key,
"text").
978 " AND module = ".$ilDB->quote($mod,
"text"));
979 $row = $ilDB->fetchAssoc($set);
980 $entries = unserialize(
$row[
"lang_array"]);
981 if(is_array($entries))
983 $entries[$id] = $trans;
990 $ilCtrl->redirect($this,
"view");
993 $form->setValuesByPost();