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 $ilDB->manipulate(sprintf(
"DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
548 $ilDB->quote($a_key,
"text"), $ilDB->quote($a_module,
"text")));
554 $ilDB->insert(
"lng_modules", array(
555 "lang_key" => array(
"text", $a_key),
556 "module" => array(
"text", $a_module),
557 "lang_array" => array(
"clob", serialize($a_array))
565 $a_lang_key, $a_value, $a_local_change = null, $a_remarks = null)
570 if (isset($a_remarks))
572 $a_remarks = substr($a_remarks, 0, 250);
574 if ($a_remarks ==
'')
581 $a_value = substr($a_value, 0, 4000);
591 'module' => array(
'text',$a_module),
592 'identifier' => array(
'text',$a_identifier),
593 'lang_key' => array(
'text',$a_lang_key)
596 'value' => array(
'text',$a_value),
597 'local_change' => array(
'timestamp',$a_local_change),
598 'remarks' => array(
'text', $a_remarks)
623 $a_lang_key, $a_value, $a_local_change = null, $a_remarks = null)
627 if (isset($a_remarks))
629 $a_remarks = substr($a_remarks, 0, 250);
631 if ($a_remarks ==
'')
638 $a_value = substr($a_value, 0, 4000);
645 $ilDB->manipulate(sprintf(
"UPDATE lng_data " .
646 "SET value = %s, local_change = %s, remarks = %s ".
647 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
648 $ilDB->quote($a_value,
"text"), $ilDB->quote($a_local_change,
"timestamp"),
649 $ilDB->quote($a_remarks,
"text"),
650 $ilDB->quote($a_module,
"text"), $ilDB->quote($a_identifier,
"text"),
651 $ilDB->quote($a_lang_key,
"text")));
662 $ilDB->manipulate(sprintf(
"DELETE FROM lng_data " .
663 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
664 $ilDB->quote($a_module,
"text"),
665 $ilDB->quote($a_identifier,
"text"),
666 $ilDB->quote($a_lang_key,
"text")));
682 $query =
"UPDATE usr_pref SET " .
683 "value = ".$ilDB->quote($this->lang_default,
"text").
" " .
684 "WHERE keyword = ".$ilDB->quote(
'language',
"text").
" ".
685 "AND value = ".$ilDB->quote($lang_key,
"text");
686 $ilDB->manipulate(
$query);
699 foreach ($content as
$key => $val)
701 if (trim($val) ==
"<!-- language file start -->")
703 return array_slice($content,
$key +1);
719 $ilDB->optimizeTable(
"lng_data");
734 include_once(
"./Services/Utilities/classes/class.ilStr.php");
738 if ($scope ==
'global')
744 $scopeExtension =
'.' . $scope;
749 if ($scope ==
"local")
751 $path = $this->cust_lang_path;
759 $this->ilias->raiseError(
"Directory not found: ".
$path, $this->ilias->error_obj->MESSAGE);
765 $lang_file =
"ilias_" . $this->key .
".lang" . $scopeExtension;
768 if (!is_file($lang_file))
770 $this->ilias->raiseError(
"File not found: ".$lang_file,$this->ilias->error_obj->MESSAGE);
774 $content = $this->
cut_header(file($lang_file));
775 if ($content ===
false)
777 $this->ilias->raiseError(
"Wrong Header in ".$lang_file,$this->ilias->error_obj->MESSAGE);
782 foreach ($content as
$key => $val)
784 $separated = explode($this->separator, trim($val));
785 $num = count($separated);
790 $this->ilias->raiseError(
"Wrong parameter count in ".$lang_file.
" in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);
794 $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);
811 $set = $ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up".
812 " ON ud.usr_id = up.usr_id ".
813 " WHERE up.value = ".$ilDB->quote($a_lang,
"text").
814 " AND up.keyword = ".$ilDB->quote(
"language",
"text"));
815 $rec = $ilDB->fetchAssoc($set);
818 if ($a_lang == $lng->lang_default)
820 $set2 = $ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up".
821 " ON (ud.usr_id = up.usr_id AND up.keyword = ".$ilDB->quote(
"language",
"text").
")".
822 " WHERE up.value IS NULL ");
823 $rec2 = $ilDB->fetchAssoc($set2);
826 return (
int) $rec[
"cnt"] + (int) $rec2[
"cnt"];