24 define(
"ILIAS_LANGUAGE_MODULE",
"Services/Language");
26 require_once(
"classes/class.ilObjectGUI.php");
27 require_once(
"Services/Language/classes/class.ilObjLanguageAccess.php");
68 $lng->loadLanguageModule(
"administration");
69 $lng->loadLanguageModule(
"meta");
72 $ilCtrl->saveParameter($this,
"view_mode");
76 if (! $this->
id =
$_GET[
'obj_id'])
82 $this->
ilObjectGUI($a_data, $this->
id,
false,
true);
85 if (!is_array(
$_SESSION[get_class($this)]))
89 $this->session =&
$_SESSION[get_class($this)];
101 require_once(
"Services/Language/classes/class.ilObjLanguageExt.php");
113 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
117 $cmd = $this->ctrl->getCmd(
"view").
"Object";
139 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.lang_edit_items.html",
"Services/Language");
142 $compare = $this->
getPar(
'compare', $this->lng->getDefaultLanguage());
145 if ($compare == $this->object->key)
147 $compare_object = $this->
object->getGlobalLanguageFile();
148 $compare_content = $compare_object->getAllValues();
149 $compare_comments = $compare_object->getAllComments();
150 $compare_note =
" ". $this->lng->txt(
"language_default_entries");
161 $modules = $this->
getPar(
"page_modules", array());
162 $topics = $this->
getPar(
"page_topics", array());
164 if (!isset($compare_content))
167 $compare, $modules, $topics);
171 $this->object->key, $modules, $topics);
179 $offset = $this->
getPar(
'offset',
'0');
180 $limit = $ilUser->getPref(
"hits_per_page");
182 $filter_mode = $this->
getPar(
'filter_mode',
'all');
183 $filter_pattern = $this->
getPar(
'filter_pattern',
'');
184 $filter_module = $this->
getPar(
'filter_module',
'administration');
185 $filter_modules = $filter_module ? array($filter_module) : array();
187 if (!isset($compare_content))
190 $compare, $filter_modules);
193 switch ($filter_mode)
196 $translations = $this->
object->getChangedValues(
197 $filter_modules, $filter_pattern);
201 $translations = $this->
object->getUnchangedValues(
202 $filter_modules, $filter_pattern);
206 $translations = $this->
object->getCommentedValues(
207 $filter_modules, $filter_pattern);
211 $translations = $this->
object->getAllValues(
212 $filter_modules, $filter_pattern);
214 $translations = array_intersect_assoc($translations, $compare_content);
218 $translations = $this->
object->getAllValues(
219 $filter_modules, $filter_pattern);
221 $translations = array_diff_assoc($translations, $compare_content);
225 $former_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
226 if (!is_readable($former_file))
228 ilUtil::sendInfo(sprintf($this->lng->txt(
"language_former_file_missing"), $former_file)
229 .
'<br />'. $this->lng->txt(
"language_former_file_description") ,
false);
230 $translations = array();
233 $global_file_obj = $this->
object->getGlobalLanguageFile();
235 $former_file_obj->read();
236 $global_changes = array_diff_assoc(
237 $global_file_obj->getAllValues(),
238 $former_file_obj->getAllValues());
239 if (!count($global_changes))
241 ilUtil::sendInfo(sprintf($this->lng->txt(
"language_former_file_equal"), $former_file)
242 .
'<br />'. $this->lng->txt(
"language_former_file_description") ,
false);
243 $translations = array();
246 $translations = $this->
object->getChangedValues(
247 $filter_modules, $filter_pattern);
249 $translations = array_intersect_key($translations, $global_changes);
254 $translations = $this->
object->getAllValues(
255 $filter_modules, $filter_pattern);
259 $this->tpl->setCurrentBlock(
"filter");
263 $options[
""] = $this->lng->txt(
"language_all_modules");
265 foreach ($modules as $mod)
267 $options[$mod] = $mod;
269 $this->tpl->setVariable(
"SELECT_MODULE",
274 $options[
"all"] = $this->lng->txt(
"language_scope_global");
275 $options[
"changed"] = $this->lng->txt(
"language_scope_local");
276 $options[
"unchanged"] = $this->lng->txt(
"language_scope_unchanged");
277 $options[
"equal"] = $this->lng->txt(
"language_scope_equal");
278 $options[
"different"] = $this->lng->txt(
"language_scope_different");
279 $options[
"commented"] = $this->lng->txt(
"language_scope_commented");
280 $options[
"conflicts"] = $this->lng->txt(
"language_scope_conflicts");
281 $this->tpl->setVariable(
"SELECT_MODE",
285 $this->tpl->setVariable(
"PATTERN_NAME",
"filter_pattern");
289 $this->tpl->setVariable(
"FILTER_ACTION", $this->ctrl->getFormAction($this));
290 $this->tpl->setVariable(
"TXT_FILTER", $this->lng->txt(
"filter"));
291 $this->tpl->setVariable(
"OFFSET_NAME",
"offset");
292 $this->tpl->setVariable(
"OFFSET_VALUE",
"0");
293 $this->tpl->setVariable(
"TXT_APPLY_FILTER", $this->lng->txt(
"apply_filter"));
294 $this->tpl->setVariable(
"CMD_FILTER",
"view");
295 $this->tpl->parseCurrentBlock();
299 $this->tpl->setCurrentBlock(
"compare");
300 $this->tpl->setVariable(
"COMPARE_ACTION", $this->ctrl->getFormAction($this));
301 $this->tpl->setVariable(
"TXT_COMPARE", $this->lng->txt(
"language_compare"));
302 $this->tpl->setVariable(
"TXT_CHANGE", $this->lng->txt(
"change"));
304 $langlist = $this->lng->getInstalledLanguages();
305 foreach ($langlist as $lang_key)
307 $options[$lang_key] = $this->lng->txt(
"meta_l_".$lang_key);
309 $this->tpl->setVariable(
"SELECT_COMPARE",
311 $this->tpl->setVariable(
"CMD_COMPARE",
"view");
312 $this->tpl->parseCurrentBlock();
315 $sort_by = $this->
getPar(
'sort_by',
'translation');
316 $sort_order = $this->
getPar(
'sort_order',
'asc');
319 foreach($translations as $name => $translation)
321 $keys = explode(
"#:#", $name);
324 $data[
"module"] = $keys[0];
325 $data[
"topic"] = str_replace(
'_',
' ', $keys[1]);
326 $data[
"name"] = $name;
327 $data[
"translation"] = $translation;
328 $data[
"default"] = $compare_content[$name];
329 $data[
"comment"] = $compare_comments[$name];
336 $list = array_slice($list, $offset, $limit);
340 include_once
'Services/Table/classes/class.ilTableGUI.php';
343 $tbl->disable(
'title');
345 $tbl->setHeaderNames(array($this->lng->txt(
"module"),
346 $this->lng->txt(
"identifier"),
347 $this->lng->txt(
"meta_l_".$this->object->key),
348 $this->lng->txt(
"meta_l_".$compare).$compare_note));
350 $tbl->setHeaderVars(array(
"module",
354 $this->ctrl->getParameterArray($this));
357 $tbl->setColumnWidth(array(
"10%",
362 $tbl->setOrderColumn($sort_by);
363 $tbl->setOrderDirection($sort_order);
364 $tbl->setLimit($limit);
365 $tbl->setOffset($offset);
366 $tbl->setMaxCount(count($translations));
371 $tpl->setCurrentBlock(
"tbl_form_header");
372 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
373 $tpl->parseCurrentBlock();
375 $tpl->setCurrentBlock(
"tbl_action_btn");
376 $tpl->setVariable(
"BTN_NAME",
'save');
377 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
'save'));
378 $tpl->parseCurrentBlock();
380 $tpl->setCurrentBlock(
"tbl_action_row");
381 $tpl->setVariable(
"COLUMN_COUNTS",
"4");
382 $tpl->parseCurrentBlock();
385 $tpl->addBlockfile(
"TBL_CONTENT",
"tbl_content",
"tpl.lang_items_row.html",
"Services/Language");
386 foreach ($list as
$data)
388 if (strlen($data[
"translation"]) <= $this->inputsize)
390 $tpl->setCurrentBlock(
"input");
392 $tpl->setVariable(
"I_SIZE", $this->inputsize);
397 $tpl->setCurrentBlock(
"textarea");
398 $tpl->setVariable(
"T_ROWS", ceil(strlen($data[
"translation"]) / $this->inputsize));
399 $tpl->setVariable(
"T_SIZE", $this->inputsize);
402 $tpl->parseCurrentBlock();
405 $tpl->setCurrentBlock(
"row");
410 $tpl->parseCurrentBlock();
414 $tbl->setTemplate(
$tpl);
416 $this->tpl->setVariable(
"TRANSLATION_TABLE",
$tpl->get());
427 $save_array = array();
428 foreach ($_POST as $key => $value)
431 if (count($keys) == 2)
434 $value = preg_replace(
"/(\015\012)|(\015)|(\012)/",
"<br />",$value);
436 $save_array[$key] = $value;
453 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.lang_file_import.html",
"Services/Language");
455 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
456 $this->tpl->setVariable(
"TXT_HEADER",$this->lng->txt(
"language_import_file"));
457 $this->tpl->setVariable(
"TXT_FILE",$this->lng->txt(
"file"));
459 $this->tpl->setVariable(
"TXT_MODE",$this->lng->txt(
"language_mode_existing"));
460 $this->tpl->setVariable(
"TXT_MODE_KEEPALL",$this->lng->txt(
"language_mode_existing_keepall"));
461 $this->tpl->setVariable(
"TXT_MODE_KEEPNEW",$this->lng->txt(
"language_mode_existing_keepnew"));
462 $this->tpl->setVariable(
"TXT_MODE_REPLACE",$this->lng->txt(
"language_mode_existing_replace"));
463 $this->tpl->setVariable(
"TXT_MODE_DELETE",$this->lng->txt(
"language_mode_existing_delete"));
465 $this->tpl->setVariable(
"TXT_UPLOAD",$this->lng->txt(
"upload"));
466 $this->tpl->setVariable(
"CMD_UPLOAD",
"upload");
476 if ($_POST[
'cmd'][
'upload'])
478 $file = $_FILES[
'userfile'][
'tmp_name'].
'x';
481 $_FILES[
'userfile'][
'name'],
484 $this->
object->importLanguageFile(
$file,$_POST[
'mode_existing']);
485 ilUtil::sendInfo(sprintf($this->lng->txt(
"language_file_imported"), $_FILES[
'userfile'][
'name']) ,
false);
505 $scope = $_POST[
"scope"] ? $_POST[
"scope"] :
"global";
507 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.lang_file_export.html",
"Services/Language");
509 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
510 $this->tpl->setVariable(
"TXT_HEADER",$this->lng->txt(
"language_export_file"));
512 $this->tpl->setVariable(
"TXT_SCOPE",$this->lng->txt(
"language_file_scope"));
513 $this->tpl->setVariable(
"TXT_SCOPE_GLOBAL",$this->lng->txt(
"language_scope_global"));
514 $this->tpl->setVariable(
"TXT_SCOPE_LOCAL",$this->lng->txt(
"language_scope_local"));
515 $this->tpl->setVariable(
"TXT_SCOPE_UNCHANGED",$this->lng->txt(
"language_scope_unchanged"));
517 $this->tpl->setVariable(
"CHECKED_GLOBAL",$scope ==
'global' ?
'checked="checked"' :
'');
518 $this->tpl->setVariable(
"CHECKED_LOCAL",$scope ==
'local' ?
'checked="checked"' :
'');
519 $this->tpl->setVariable(
"CHECKED_UNCHANGED",$scope ==
'unchanged' ?
'checked="checked"' :
'');
521 $this->tpl->setVariable(
"TXT_DOWNLOAD",$this->lng->txt(
"download"));
522 $this->tpl->setVariable(
"CMD_DOWNLOAD",
"download");
532 $filename =
'ilias_' . $this->
object->key .
'_'
534 .
"-" . date(
'Y-m-d')
535 .
".lang.".$_POST[
"scope"];
537 $global_file_obj = $this->
object->getGlobalLanguageFile();
540 if ($_POST[
"scope"] ==
'global')
542 $local_file_obj->setParam(
"author", $global_file_obj->getParam(
'author'));
543 $local_file_obj->setParam(
"version", $global_file_obj->getParam(
'version'));
544 $local_file_obj->setAllValues($this->object->getAllValues());
546 elseif ($_POST[
"scope"] ==
'local')
548 $local_file_obj->setParam(
"based_on", $global_file_obj->getParam(
'version'));
549 $local_file_obj->setAllValues($this->object->getChangedValues());
551 elseif ($_POST[
"scope"] ==
'unchanged')
553 $local_file_obj->setParam(
"author", $global_file_obj->getParam(
'author'));
554 $local_file_obj->setParam(
"version", $global_file_obj->getParam(
'version'));
555 $local_file_obj->setAllValues($this->object->getUnchangedValues());
569 switch ($_POST[
"maintain"])
573 $lang_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang.local';
575 if ((is_file($lang_file) and is_writable($lang_file))
576 or (!file_exists($lang_file) and is_writable($this->object->getCustLangPath())))
579 $orig_file = $this->
object->getLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
580 $copy_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
581 @copy($orig_file, $copy_file);
584 @rename($lang_file, $lang_file.
".bak");
587 $global_file_obj = $this->
object->getGlobalLanguageFile();
588 $local_file_obj =
new ilLanguageFile($lang_file, $this->object->key,
'local');
589 $local_file_obj->setParam(
'based_on', $global_file_obj->getParam(
'version'));
590 $local_file_obj->setAllValues($this->object->getChangedValues());
591 $local_file_obj->write();
593 $this->
object->setLocal(
true);
604 $lang_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang.local';
605 if (is_file($lang_file) and is_readable($lang_file))
607 $this->
object->importLanguageFile($lang_file,
'replace');
608 $this->
object->setLocal(
true);
619 $lang_file = $this->
object->getLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
620 if (is_file($lang_file) and is_readable($lang_file))
622 $this->
object->importLanguageFile($lang_file,
'delete');
623 $this->
object->setLocal(
false);
633 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.lang_maintenance.html",
"Services/Language");
634 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
635 $this->tpl->setVariable(
"TXT_MAINTENANCE",$this->lng->txt(
"language_maintenance"));
636 $this->tpl->setVariable(
"TXT_MAINTAIN_LOCAL",$this->lng->txt(
"language_maintain_local_changes"));
637 $this->tpl->setVariable(
"TXT_SELECT",$this->lng->txt(
"please_select"));
638 $this->tpl->setVariable(
"TXT_SAVE",$this->lng->txt(
"language_save_local_changes"));
639 $this->tpl->setVariable(
"TXT_LOAD",$this->lng->txt(
"language_load_local_changes"));
640 $this->tpl->setVariable(
"TXT_CLEAR",$this->lng->txt(
"language_clear_local_changes"));
641 $this->tpl->setVariable(
"TXT_NOTE_SAVE",$this->lng->txt(
"language_note_save_local"));
642 $this->tpl->setVariable(
"TXT_MAINTAIN",$this->lng->txt(
"language_process_maintenance"));
643 $this->tpl->setVariable(
"VAR_MAINTAIN",
"maintain");
644 $this->tpl->setVariable(
"CMD_MAINTAIN",
"maintain");
655 $translate_key =
"lang_translate_". $this->
object->key;
658 switch ($_POST[
"translation"])
661 $ilSetting->set($translate_key,
true);
664 $ilSetting->set($translate_key,
false);
666 $translate = $ilSetting->get($translate_key,
false);
668 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.lang_settings.html",
"Services/Language");
670 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
671 $this->tpl->setVariable(
"TXT_SETTINGS",$this->lng->txt(
"language_settings"));
672 $this->tpl->setVariable(
"TXT_TRANSLATION",$this->lng->txt(
"language_translation_mode"));
673 $this->tpl->setVariable(
"TXT_TRANSLATION_ENABLED",$this->lng->txt(
"language_translation_enabled"));
674 $this->tpl->setVariable(
"TXT_TRANSLATION_DISABLED",$this->lng->txt(
"language_translation_disabled"));
675 $this->tpl->setVariable(
"CHECKED_ENABLE", $translate ?
'checked="checked"':
'');
676 $this->tpl->setVariable(
"CHECKED_DISABLE", $translate ?
'' :
'checked="checked"');
677 $this->tpl->setVariable(
"TXT_NOTE_TRANSLATION",$this->lng->txt(
"language_note_translation"));
678 $this->tpl->setVariable(
"TXT_CHANGE_SETTINGS",$this->lng->txt(
"language_change_settings"));
679 $this->tpl->setVariable(
"CMD_SETTINGS",
"settings");
692 foreach($modules as $module)
696 $row[1] = count($this->object->getAllValues(array($module)));
697 $row[2] = count($this->object->getChangedValues(array($module)));
698 $row[3] = $row[1]-$row[2];
704 $total[0] =
"<b>".$this->lng->txt(
"language_all_modules").
"</b>";
705 $total[1] =
"<b>".$total[1].
"</b>";
706 $total[2] =
"<b>".$total[2].
"</b>";
707 $total[3] =
"<b>".$total[3].
"</b>";
711 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.lang_statistics.html",
"Services/Language");
712 $this->tpl->addBlockFile(
"TABLE_STATISTICS",
"table_statistics",
"tpl.table.html");
713 $this->tpl->addBlockFile(
"TBL_CONTENT",
"tbl_content",
"tpl.obj_tbl_rows.html");
716 include_once
'Services/Table/classes/class.ilTableGUI.php';
718 $tbl->disable(
'title');
719 $tbl->disable(
'sort');
720 $tbl->disable(
'numinfo');
722 $tbl->setHeaderNames(array($this->lng->txt(
"module"),
723 $this->lng->txt(
"language_scope_global"),
724 $this->lng->txt(
"language_scope_local"),
725 $this->lng->txt(
"language_scope_unchanged")));
726 $tbl->setColumnWidth(array(
"25%",
"25%",
"25%",
"25%"));
727 $tbl->setLimit(count(
$data));
728 $tbl->setData(
$data);
745 function getPar($a_request_name, $a_default_value)
748 if (isset(
$_GET[$a_request_name]))
750 $param =
$_GET[$a_request_name];
751 $from_request =
true;
753 elseif (isset($_POST[$a_request_name]))
755 $param = $_POST[$a_request_name];
756 $from_request =
true;
758 elseif (isset($this->session[$a_request_name]))
760 $param = $this->session[$a_request_name];
761 $from_request =
false;
765 $param = $a_default_value;
766 $from_request =
false;
772 if (is_array($param))
774 foreach ($param as $key => $value)
786 $this->session[$a_request_name] = $param;
799 $tabs_gui->addTarget(
"edit",
800 $this->ctrl->getLinkTarget($this,
"view"),
801 array(
"",
"view",
"cancel",
"save"));
803 $tabs_gui->addTarget(
"export",
804 $this->ctrl->getLinkTarget($this,
"export"),
805 array(
"export",
"download"));
807 $tabs_gui->addTarget(
"import",
808 $this->ctrl->getLinkTarget($this,
"import"),
809 array(
"import",
"upload"));
811 $tabs_gui->addTarget(
"language_maintain",
812 $this->ctrl->getLinkTarget($this,
"maintain"),
815 $tabs_gui->addTarget(
"settings",
816 $this->ctrl->getLinkTarget($this,
"settings"),
819 $tabs_gui->addTarget(
"language_statistics",
820 $this->ctrl->getLinkTarget($this,
"statistics"),
821 array(
"statistics"));
834 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.adm_translate.html",
"Services/Language");
835 $this->tpl->setHeaderPageTitle($this->lng->txt(
"translation"));
836 $this->tpl->setTitle($this->lng->txt(
"translation").
" "
837 .$this->lng->txt(
"meta_l_".$this->object->key));
839 $this->lng->txt(
"obj_" . $this->object->getType()));
855 global $ilLocator,
$tpl;
857 $ilLocator->addItem($this->lng->txt(
"administration"),
858 $this->ctrl->getLinkTargetByClass(
"iladministrationgui",
"frameset"),
861 $ilLocator->addItem($this->lng->txt(
"languages"),
862 $this->ctrl->getLinkTargetByClass(
"ilobjlanguagefoldergui",
""));
864 $ilLocator->addItem($this->lng->txt(
"meta_l_". $this->object->getTitle()),
865 $this->ctrl->getLinkTarget($this,
"view"));
875 $this->tpl->setTitle($this->lng->txt(
"meta_l_".$this->object->getTitle()));
877 $this->tpl->setTitleIcon(
ilUtil::getImagePath(
"icon_".$this->object->getType().
"_b.gif"), $this->lng->txt(
"obj_" . $this->object->getType()));
899 return (
$_GET[
'view_mode'] ==
"translate");
917 if (self::_isPageTranslation()
918 or !$ilSetting->get(
"lang_translate_".$lng->getLangKey()))
925 $action =
"ilias.php"
926 .
"?ref_id=".ilobjLanguageAccess::_lookupLangFolderRefId()
927 .
"&baseClass=ilAdministrationGUI"
928 .
"&cmdClass=ilobjlanguageextgui"
929 .
"&view_mode=translate";
931 $tpl =
new ilTemplate(
"tpl.translation_link.html",
true,
true,
"Services/Language");
933 foreach($lng->getUsedModules() as $module => $dummy)
935 $tpl->setCurrentBlock(
"hidden");
936 $tpl->setVariable(
"NAME",
"page_modules[]");
938 $tpl->parseCurrentBlock();
941 foreach($lng->getUsedTopics() as $topic => $dummy)
943 $tpl->setCurrentBlock(
"hidden");
944 $tpl->setVariable(
"NAME",
"page_topics[]");
946 $tpl->parseCurrentBlock();
949 $tpl->setVariable(
"ACTION", $action);
950 $tpl->setVariable(
"TXT_TRANSLATE",$lng->txt(
"translation"));