4 require_once
"./Services/Object/classes/class.ilObject.php";
45 $this->
ilObject($a_id,$a_call_by_reference);
50 $this->lang_default = $lng->lang_default;
51 $this->lang_user = $lng->lang_user;
52 $this->lang_path = $lng->lang_path;
53 $this->cust_lang_path = $lng->cust_lang_path;
54 $this->separator = $lng->separator;
55 $this->comment_separator = $lng->comment_separator;
83 if ($this->key == $this->lang_default)
94 if ($this->key == $this->lang_user)
112 if (substr($this->
getStatus(), 0, 9) ==
"installed")
130 if (substr($this->
getStatus(), 10) ==
"local")
150 if ($scope ==
'global')
156 $scopeExtension =
'.' . $scope;
163 if ($this->
check($scope))
168 $this->
flush(
'keep_local');
177 $newDesc =
'installed';
179 else if ($scope ==
'local')
181 $newDesc =
'installed_local';
200 if ((substr($this->status, 0, 9) ==
"installed") && ($this->key != $this->lang_default) && ($this->key != $this->lang_user))
218 global $ilPluginAdmin;
222 foreach ($languages as
$lang)
226 if ($langObj->isInstalled() ==
true)
228 if ($langObj->check())
230 $langObj->flush(
'keep_local');
232 $langObj->setTitle($langObj->getKey());
233 $langObj->setDescription($langObj->getStatus());
235 $langObj->optimizeData();
237 if ($langObj->isLocal() ==
true)
239 if ($langObj->check(
'local'))
241 $langObj->insert(
'local');
242 $langObj->setTitle($langObj->getKey());
243 $langObj->setDescription($langObj->getStatus());
245 $langObj->optimizeData();
255 include_once(
"./Services/Component/classes/class.ilPluginSlot.php");
257 foreach ($slots as $slot)
259 $act_plugins = $ilPluginAdmin->getActivePluginsForSlot($slot[
"component_type"],
260 $slot[
"component_name"], $slot[
"slot_id"]);
261 foreach ($act_plugins as $plugin)
263 include_once(
"./Services/Component/classes/class.ilPlugin.php");
265 $slot[
"component_name"], $slot[
"slot_id"], $plugin);
268 $pl->updateLanguages();
283 if (!$a_keep_local_change)
285 $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = ".
286 $ilDB->quote($a_lang_key,
"text"));
290 $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = ".
291 $ilDB->quote($a_lang_key,
"text").
292 " AND local_change IS NULL");
306 if ($a_mode ==
'all')
308 $ilDB->manipulate(
"DELETE FROM lng_modules WHERE lang_key = ".
309 $ilDB->quote($this->key,
"text"));
324 if ($a_min_date ==
"")
326 $a_min_date =
"1980-01-01 00:00:00";
328 if ($a_max_date ==
"")
330 $a_max_date =
"2200-01-01 00:00:00";
333 $q = sprintf(
"SELECT * FROM lng_data WHERE lang_key = %s ".
334 "AND local_change >= %s AND local_change <= %s",
335 $ilDB->quote($this->key,
"text"), $ilDB->quote($a_min_date,
"timestamp"),
336 $ilDB->quote($a_max_date,
"timestamp"));
342 $changes[
$row[
"module"]][
$row[
"identifier"]] = $row[
"value"];
357 $q = sprintf(
"SELECT MAX(local_change) last_change FROM lng_data ".
358 "WHERE lang_key = %s AND local_change IS NOT NULL",
359 $ilDB->quote($a_key,
"text"));
364 return $row[
'last_change'];
384 if ($scope ==
'global')
390 $scopeExtension =
'.' . $scope;
395 if ($scope ==
"local")
397 $path = $this->cust_lang_path;
403 $lang_file =
"ilias_" . $this->key .
".lang" . $scopeExtension;
408 $lang_array = array();
409 $lang_array[
"common"] = array();
412 if ($content = $this->
cut_header(file($lang_file)))
421 else if ($scope ==
'local')
426 $change_date = date(
"Y-m-d H:i:s",time());
427 $min_date = date(
"Y-m-d H:i:s", filemtime($lang_file));
431 foreach ($content as
$key => $val)
438 $separated = explode($this->separator,trim($val));
439 $pos = strpos($separated[2], $this->comment_separator);
442 $separated[3] = substr($separated[2], $pos + strlen($this->comment_separator));
443 $separated[2] = substr($separated[2] , 0 , $pos);
447 $local_value = $local_changes[$separated[0]][$separated[1]];
453 if ($local_value !=
"" and $local_value != $separated[2])
456 $lang_array[$separated[0]][$separated[1]] = $local_value;
461 if ($double_checker[$separated[0]][$separated[1]][$this->key])
463 $this->ilias->raiseError(
"Duplicate Language Entry in $lang_file:\n$val",
464 $this->ilias->error_obj->MESSAGE);
466 $double_checker[$separated[0]][$separated[1]][
$this->key] =
true;
471 $this->key, $separated[2], $change_date, $separated[3]);
473 $lang_array[$separated[0]][$separated[1]] = $separated[2];
476 else if ($scope ==
'local')
480 if ($local_value !=
"")
483 $lang_array[$separated[0]][$separated[1]] = $local_value;
491 $this->key, $separated[2], $change_date, $separated[3]);
493 $lang_array[$separated[0]][$separated[1]] = $separated[2];
503 else if ($scope ==
'local')
505 $ld =
"installed_local";
509 $query =
"UPDATE object_data SET " .
510 "description = ".$ilDB->quote($ld,
"text").
", " .
511 "last_update = ".$ilDB->now().
" " .
512 "WHERE title = ".$ilDB->quote($this->key,
"text").
" " .
514 $ilDB->manipulate(
$query);
518 foreach($lang_array as $module => $lang_arr)
520 if ($scope ==
"local")
522 $q =
"SELECT * FROM lng_modules WHERE ".
523 " lang_key = ".$ilDB->quote($this->key,
"text").
524 " AND module = ".$ilDB->quote($module,
"text");
525 $set = $ilDB->query($q);
526 $row = $ilDB->fetchAssoc($set);
527 $arr2 = unserialize(
$row[
"lang_array"]);
530 $lang_arr = array_merge($arr2, $lang_arr);
547 ilGlobalCache::flushAll();
549 $ilDB->manipulate(sprintf(
"DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
550 $ilDB->quote($a_key,
"text"), $ilDB->quote($a_module,
"text")));
556 $ilDB->insert(
"lng_modules", array(
557 "lang_key" => array(
"text", $a_key),
558 "module" => array(
"text", $a_module),
559 "lang_array" => array(
"clob", serialize($a_array))
567 $a_lang_key, $a_value, $a_local_change = null, $a_remarks = null)
571 ilGlobalCache::flushAll();
573 if (isset($a_remarks))
575 $a_remarks = substr($a_remarks, 0, 250);
577 if ($a_remarks ==
'')
584 $a_value = substr($a_value, 0, 4000);
594 'module' => array(
'text',$a_module),
595 'identifier' => array(
'text',$a_identifier),
596 'lang_key' => array(
'text',$a_lang_key)
599 'value' => array(
'text',$a_value),
600 'local_change' => array(
'timestamp',$a_local_change),
601 'remarks' => array(
'text', $a_remarks)
626 $a_lang_key, $a_value, $a_local_change = null, $a_remarks = null)
630 if (isset($a_remarks))
632 $a_remarks = substr($a_remarks, 0, 250);
634 if ($a_remarks ==
'')
641 $a_value = substr($a_value, 0, 4000);
648 $ilDB->manipulate(sprintf(
"UPDATE lng_data " .
649 "SET value = %s, local_change = %s, remarks = %s ".
650 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
651 $ilDB->quote($a_value,
"text"), $ilDB->quote($a_local_change,
"timestamp"),
652 $ilDB->quote($a_remarks,
"text"),
653 $ilDB->quote($a_module,
"text"), $ilDB->quote($a_identifier,
"text"),
654 $ilDB->quote($a_lang_key,
"text")));
665 $ilDB->manipulate(sprintf(
"DELETE FROM lng_data " .
666 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
667 $ilDB->quote($a_module,
"text"),
668 $ilDB->quote($a_identifier,
"text"),
669 $ilDB->quote($a_lang_key,
"text")));
685 $query =
"UPDATE usr_pref SET " .
686 "value = ".$ilDB->quote($this->lang_default,
"text").
" " .
687 "WHERE keyword = ".$ilDB->quote(
'language',
"text").
" ".
688 "AND value = ".$ilDB->quote($lang_key,
"text");
689 $ilDB->manipulate(
$query);
702 foreach ($content as
$key => $val)
704 if (trim($val) ==
"<!-- language file start -->")
706 return array_slice($content,
$key +1);
722 $ilDB->optimizeTable(
"lng_data");
737 include_once(
"./Services/Utilities/classes/class.ilStr.php");
741 if ($scope ==
'global')
747 $scopeExtension =
'.' . $scope;
752 if ($scope ==
"local")
754 $path = $this->cust_lang_path;
762 $this->ilias->raiseError(
"Directory not found: ".
$path, $this->ilias->error_obj->MESSAGE);
768 $lang_file =
"ilias_" . $this->key .
".lang" . $scopeExtension;
771 if (!is_file($lang_file))
773 $this->ilias->raiseError(
"File not found: ".$lang_file,$this->ilias->error_obj->MESSAGE);
777 $content = $this->
cut_header(file($lang_file));
778 if ($content ===
false)
780 $this->ilias->raiseError(
"Wrong Header in ".$lang_file,$this->ilias->error_obj->MESSAGE);
785 foreach ($content as
$key => $val)
787 $separated = explode($this->separator, trim($val));
788 $num = count($separated);
793 $this->ilias->raiseError(
"Wrong parameter count in ".$lang_file.
" in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);
797 $this->ilias->raiseError(
"Non UTF8 character found in ".$lang_file.
" in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);
814 $set = $ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up".
815 " ON ud.usr_id = up.usr_id ".
816 " WHERE up.value = ".$ilDB->quote($a_lang,
"text").
817 " AND up.keyword = ".$ilDB->quote(
"language",
"text"));
818 $rec = $ilDB->fetchAssoc($set);
821 if ($a_lang == $lng->lang_default)
823 $set2 = $ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up".
824 " ON (ud.usr_id = up.usr_id AND up.keyword = ".$ilDB->quote(
"language",
"text").
")".
825 " WHERE up.value IS NULL ");
826 $rec2 = $ilDB->fetchAssoc($set2);
829 return (
int) $rec[
"cnt"] + (int) $rec2[
"cnt"];