4 define(
"ILIAS_LANGUAGE_MODULE",
"Services/Language");
6 require_once(
"classes/class.ilObjectGUI.php");
7 require_once(
"Services/Language/classes/class.ilObjLanguageAccess.php");
48 $lng->loadLanguageModule(
"administration");
49 $lng->loadLanguageModule(
"meta");
52 $ilCtrl->saveParameter($this,
"view_mode");
56 if (! $this->
id =
$_GET[
'obj_id'])
62 $this->
ilObjectGUI($a_data, $this->
id,
false,
true);
65 if (!is_array(
$_SESSION[get_class($this)]))
69 $this->session =&
$_SESSION[get_class($this)];
81 require_once(
"Services/Language/classes/class.ilObjLanguageExt.php");
93 $this->ilErr->raiseError($this->lng->txt(
"permission_denied"),$this->ilErr->MESSAGE);
97 $cmd = $this->ctrl->getCmd(
"view").
"Object";
118 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.lang_edit_items.html",
"Services/Language");
121 $compare = $this->
getPar(
'compare', $this->lng->getDefaultLanguage());
124 if ($compare == $this->object->key)
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");
140 $modules = $this->
getPar(
"page_modules", array());
141 $topics = $this->
getPar(
"page_topics", array());
143 if (!isset($compare_content))
146 $compare, $modules, $topics);
150 $this->object->key, $modules, $topics);
158 $offset = $this->
getPar(
'offset',
'0');
159 $limit = $ilUser->getPref(
"hits_per_page");
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();
166 if (!isset($compare_content))
169 $compare, $filter_modules);
172 switch ($filter_mode)
175 $translations = $this->
object->getChangedValues(
176 $filter_modules, $filter_pattern);
180 $translations = $this->
object->getUnchangedValues(
181 $filter_modules, $filter_pattern);
185 $translations = $this->
object->getCommentedValues(
186 $filter_modules, $filter_pattern);
190 $translations = $this->
object->getAllValues(
191 $filter_modules, $filter_pattern);
193 $translations = array_intersect_assoc($translations, $compare_content);
197 $translations = $this->
object->getAllValues(
198 $filter_modules, $filter_pattern);
200 $translations = array_diff_assoc($translations, $compare_content);
204 $former_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
205 if (!is_readable($former_file))
208 .
'<br />'. $this->lng->txt(
"language_former_file_description") ,
false);
209 $translations = array();
212 $global_file_obj = $this->
object->getGlobalLanguageFile();
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))
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();
225 $translations = $this->
object->getChangedValues(
226 $filter_modules, $filter_pattern);
228 $translations = array_intersect_key($translations, $global_changes);
233 $translations = $this->
object->getAllValues(
234 $filter_modules, $filter_pattern);
238 $this->tpl->setCurrentBlock(
"filter");
242 $options[
""] = $this->lng->txt(
"language_all_modules");
244 foreach ($modules as $mod)
246 $options[$mod] = $mod;
248 $this->tpl->setVariable(
"SELECT_MODULE",
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",
264 $this->tpl->setVariable(
"PATTERN_NAME",
"filter_pattern");
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();
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"));
283 $langlist = $this->lng->getInstalledLanguages();
284 foreach ($langlist as $lang_key)
286 $options[$lang_key] = $this->lng->txt(
"meta_l_".$lang_key);
288 $this->tpl->setVariable(
"SELECT_COMPARE",
290 $this->tpl->setVariable(
"CMD_COMPARE",
"view");
291 $this->tpl->parseCurrentBlock();
294 $sort_by = $this->
getPar(
'sort_by',
'translation');
295 $sort_order = $this->
getPar(
'sort_order',
'asc');
298 foreach($translations as
$name => $translation)
300 $keys = explode(
"#:#",
$name);
303 $data[
"module"] = $keys[0];
304 $data[
"topic"] = str_replace(
'_',
' ', $keys[1]);
306 $data[
"translation"] = $translation;
315 $list = array_slice($list, $offset, $limit);
319 include_once
'Services/Table/classes/class.ilTableGUI.php';
322 $tbl->disable(
'title');
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));
329 $tbl->setHeaderVars(array(
"module",
333 $this->ctrl->getParameterArray($this));
336 $tbl->setColumnWidth(array(
"10%",
341 $tbl->setOrderColumn($sort_by);
342 $tbl->setOrderDirection($sort_order);
343 $tbl->setLimit($limit);
344 $tbl->setOffset($offset);
345 $tbl->setMaxCount(count($translations));
350 $tpl->setCurrentBlock(
"tbl_form_header");
351 $tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
352 $tpl->parseCurrentBlock();
354 $tpl->setCurrentBlock(
"tbl_action_btn");
355 $tpl->setVariable(
"BTN_NAME",
'save');
356 $tpl->setVariable(
"BTN_VALUE",$this->lng->txt(
'save'));
357 $tpl->parseCurrentBlock();
359 $tpl->setCurrentBlock(
"tbl_action_row");
360 $tpl->setVariable(
"COLUMN_COUNTS",
"4");
361 $tpl->parseCurrentBlock();
364 $tpl->addBlockfile(
"TBL_CONTENT",
"tbl_content",
"tpl.lang_items_row.html",
"Services/Language");
365 foreach ($list as
$data)
367 if (strlen($data[
"translation"]) <= $this->inputsize)
369 $tpl->setCurrentBlock(
"input");
371 $tpl->setVariable(
"I_SIZE", $this->inputsize);
376 $tpl->setCurrentBlock(
"textarea");
377 $tpl->setVariable(
"T_ROWS", ceil(strlen($data[
"translation"]) / $this->inputsize));
378 $tpl->setVariable(
"T_SIZE", $this->inputsize);
381 $tpl->parseCurrentBlock();
384 $tpl->setCurrentBlock(
"row");
389 $tpl->parseCurrentBlock();
393 $tbl->setTemplate(
$tpl);
395 $this->tpl->setVariable(
"TRANSLATION_TABLE",
$tpl->get());
406 $save_array = array();
410 if (count($keys) == 2)
413 $value = preg_replace(
"/(\015\012)|(\015)|(\012)/",
"<br />",$value);
415 $save_array[
$key] = $value;
432 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.lang_file_import.html",
"Services/Language");
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"));
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"));
444 $this->tpl->setVariable(
"TXT_UPLOAD",$this->lng->txt(
"upload"));
445 $this->tpl->setVariable(
"CMD_UPLOAD",
"upload");
455 if (
$_POST[
'cmd'][
'upload'])
457 $file = $_FILES[
'userfile'][
'tmp_name'].
'x';
460 $_FILES[
'userfile'][
'name'],
463 $this->
object->importLanguageFile(
$file,
$_POST[
'mode_existing']);
464 ilUtil::sendSuccess(sprintf($this->lng->txt(
"language_file_imported"), $_FILES[
'userfile'][
'name']) ,
false);
486 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.lang_file_export.html",
"Services/Language");
488 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
489 $this->tpl->setVariable(
"TXT_HEADER",$this->lng->txt(
"language_export_file"));
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"));
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"' :
'');
500 $this->tpl->setVariable(
"TXT_DOWNLOAD",$this->lng->txt(
"download"));
501 $this->tpl->setVariable(
"CMD_DOWNLOAD",
"download");
511 $filename =
'ilias_' . $this->
object->key .
'_'
513 .
"-" . date(
'Y-m-d')
514 .
".lang.".$_POST[
"scope"];
516 $global_file_obj = $this->
object->getGlobalLanguageFile();
519 if (
$_POST[
"scope"] ==
'global')
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());
527 $local_file_obj->setParam(
"based_on", $global_file_obj->getParam(
'version'));
528 $local_file_obj->setAllValues($this->object->getChangedValues());
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());
548 switch (
$_POST[
"maintain"])
552 $lang_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang.local';
554 if ((is_file($lang_file) and is_writable($lang_file))
555 or (!file_exists($lang_file) and is_writable($this->object->getCustLangPath())))
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);
563 @rename($lang_file, $lang_file.
".bak");
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();
572 $this->
object->setLocal(
true);
583 $lang_file = $this->
object->getCustLangPath() .
'/ilias_' . $this->
object->key .
'.lang.local';
584 if (is_file($lang_file) and is_readable($lang_file))
586 $this->
object->importLanguageFile($lang_file,
'replace');
587 $this->
object->setLocal(
true);
598 $lang_file = $this->
object->getLangPath() .
'/ilias_' . $this->
object->key .
'.lang';
599 if (is_file($lang_file) and is_readable($lang_file))
601 $this->
object->importLanguageFile($lang_file,
'delete');
602 $this->
object->setLocal(
false);
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");
634 $translate_key =
"lang_translate_". $this->
object->key;
637 switch (
$_POST[
"translation"])
640 $ilSetting->set($translate_key,
true);
643 $ilSetting->set($translate_key,
false);
645 $translate = $ilSetting->get($translate_key,
false);
647 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.lang_settings.html",
"Services/Language");
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");
671 foreach($modules as $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];
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>";
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");
695 include_once
'Services/Table/classes/class.ilTableGUI.php';
697 $tbl->disable(
'title');
698 $tbl->disable(
'sort');
699 $tbl->disable(
'numinfo');
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);
724 function getPar($a_request_name, $a_default_value)
727 if (isset(
$_GET[$a_request_name]))
730 $from_request =
true;
735 $from_request =
true;
737 elseif (isset($this->session[$a_request_name]))
739 $param = $this->session[$a_request_name];
740 $from_request =
false;
744 $param = $a_default_value;
745 $from_request =
false;
765 $this->session[$a_request_name] =
$param;
778 $tabs_gui->addTarget(
"edit",
779 $this->ctrl->getLinkTarget($this,
"view"),
780 array(
"",
"view",
"cancel",
"save"));
782 $tabs_gui->addTarget(
"export",
783 $this->ctrl->getLinkTarget($this,
"export"),
784 array(
"export",
"download"));
786 $tabs_gui->addTarget(
"import",
787 $this->ctrl->getLinkTarget($this,
"import"),
788 array(
"import",
"upload"));
790 $tabs_gui->addTarget(
"language_maintain",
791 $this->ctrl->getLinkTarget($this,
"maintain"),
794 $tabs_gui->addTarget(
"settings",
795 $this->ctrl->getLinkTarget($this,
"settings"),
798 $tabs_gui->addTarget(
"language_statistics",
799 $this->ctrl->getLinkTarget($this,
"statistics"),
800 array(
"statistics"));
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));
818 $this->lng->txt(
"obj_" . $this->object->getType()));
834 global $ilLocator,
$tpl;
836 $ilLocator->addItem($this->lng->txt(
"administration"),
837 $this->ctrl->getLinkTargetByClass(
"iladministrationgui",
"frameset"),
840 $ilLocator->addItem($this->lng->txt(
"languages"),
841 $this->ctrl->getLinkTargetByClass(
"ilobjlanguagefoldergui",
""));
843 $ilLocator->addItem($this->lng->txt(
"meta_l_". $this->object->getTitle()),
844 $this->ctrl->getLinkTarget($this,
"view"));
854 $this->tpl->setTitle($this->lng->txt(
"meta_l_".$this->object->getTitle()));
856 $this->tpl->setTitleIcon(
ilUtil::getImagePath(
"icon_".$this->object->getType().
"_b.gif"), $this->lng->txt(
"obj_" . $this->object->getType()));
878 return (
$_GET[
'view_mode'] ==
"translate");
896 if (self::_isPageTranslation()
897 or !$ilSetting->get(
"lang_translate_".$lng->getLangKey()))
904 $action =
"ilias.php"
905 .
"?ref_id=".ilobjLanguageAccess::_lookupLangFolderRefId()
906 .
"&baseClass=ilAdministrationGUI"
907 .
"&cmdClass=ilobjlanguageextgui"
908 .
"&view_mode=translate";
910 $tpl =
new ilTemplate(
"tpl.translation_link.html",
true,
true,
"Services/Language");
912 foreach($lng->getUsedModules() as $module => $dummy)
914 $tpl->setCurrentBlock(
"hidden");
915 $tpl->setVariable(
"NAME",
"page_modules[]");
917 $tpl->parseCurrentBlock();
920 foreach($lng->getUsedTopics() as $topic => $dummy)
922 $tpl->setCurrentBlock(
"hidden");
923 $tpl->setVariable(
"NAME",
"page_topics[]");
925 $tpl->parseCurrentBlock();
928 $tpl->setVariable(
"ACTION", $action);
929 $tpl->setVariable(
"TXT_TRANSLATE",$lng->txt(
"translation"));