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: ".
 
  464                                                                         $separated[0].
"-".$separated[1].
"-".$this->key,
 
  465                                                                         $this->ilias->error_obj->MESSAGE);
 
  467                                                         $double_checker[$separated[0]][$separated[1]][
$this->key] = 
true;
 
  472                                                                 $this->key, $separated[2], $change_date, $separated[3]);
 
  474                                                         $lang_array[$separated[0]][$separated[1]] = $separated[2];
 
  477                                         else if ($scope == 
'local')
 
  481                                                 if ($local_value != 
"")
 
  484                                                         $lang_array[$separated[0]][$separated[1]] = $local_value;
 
  492                                                                 $this->key, $separated[2], $change_date, $separated[3]);
 
  494                                                         $lang_array[$separated[0]][$separated[1]] = $separated[2];
 
  504                                 else if ($scope == 
'local')
 
  506                                         $ld = 
"installed_local";
 
  510                                         $query = 
"UPDATE object_data SET " .
 
  511                                                         "description = ".$ilDB->quote($ld, 
"text").
", " .
 
  512                                                         "last_update = ".$ilDB->now().
" " .
 
  513                                                         "WHERE title = ".$ilDB->quote($this->key, 
"text").
" " .
 
  515                                         $ilDB->manipulate(
$query);
 
  519                         foreach($lang_array as $module => $lang_arr)
 
  521                                 if ($scope == 
"local")
 
  523                                         $q = 
"SELECT * FROM lng_modules WHERE ".
 
  524                                                 " lang_key = ".$ilDB->quote($this->key, 
"text").
 
  525                                                 " AND module = ".$ilDB->quote($module, 
"text");
 
  526                                         $set = $ilDB->query($q);
 
  527                                         $row = $ilDB->fetchAssoc($set);
 
  528                                         $arr2 = unserialize(
$row[
"lang_array"]);
 
  531                                                 $lang_arr = array_merge($arr2, $lang_arr);
 
  548                 $ilDB->manipulate(sprintf(
"DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
 
  549                         $ilDB->quote($a_key, 
"text"), $ilDB->quote($a_module, 
"text")));
 
  555                 $ilDB->insert(
"lng_modules", array(
 
  556                         "lang_key" => array(
"text", $a_key),
 
  557                         "module" => array(
"text", $a_module),
 
  558                         "lang_array" => array(
"clob", serialize($a_array))
 
  566                 $a_lang_key, $a_value, $a_local_change = null, $a_remarks = null)
 
  571                 if (isset($a_remarks))
 
  573                 $a_remarks = substr($a_remarks, 0, 250);
 
  575                 if ($a_remarks == 
'')
 
  582                 $a_value = substr($a_value, 0, 4000);
 
  592                                 'module'                => array(
'text',$a_module),
 
  593                                 'identifier'    => array(
'text',$a_identifier),
 
  594                                 'lang_key'              => array(
'text',$a_lang_key)
 
  597                                 'value'                 => array(
'text',$a_value),
 
  598                                 'local_change'  => array(
'timestamp',$a_local_change),
 
  599                                 'remarks'       => array(
'text', $a_remarks)
 
  624                 $a_lang_key, $a_value, $a_local_change = null, $a_remarks = null)
 
  628                 if (isset($a_remarks))
 
  630                 $a_remarks = substr($a_remarks, 0, 250);
 
  632                 if ($a_remarks == 
'')
 
  639                 $a_value = substr($a_value, 0, 4000);
 
  646                 $ilDB->manipulate(sprintf(
"UPDATE lng_data " .
 
  647                         "SET value = %s, local_change = %s, remarks = %s ".
 
  648                         "WHERE module = %s AND identifier = %s AND lang_key = %s ",
 
  649                         $ilDB->quote($a_value, 
"text"), $ilDB->quote($a_local_change, 
"timestamp"),
 
  650                         $ilDB->quote($a_remarks, 
"text"),
 
  651                         $ilDB->quote($a_module, 
"text"), $ilDB->quote($a_identifier, 
"text"),
 
  652                         $ilDB->quote($a_lang_key, 
"text")));
 
  663                 $ilDB->manipulate(sprintf(
"DELETE FROM lng_data " .
 
  664                         "WHERE module = %s AND identifier = %s AND lang_key = %s ",
 
  665                         $ilDB->quote($a_module, 
"text"),
 
  666                         $ilDB->quote($a_identifier, 
"text"),
 
  667                         $ilDB->quote($a_lang_key, 
"text")));
 
  683                 $query = 
"UPDATE usr_pref SET " .
 
  684                                 "value = ".$ilDB->quote($this->lang_default, 
"text").
" " .
 
  685                                 "WHERE keyword = ".$ilDB->quote(
'language', 
"text").
" ".
 
  686                                 "AND value = ".$ilDB->quote($lang_key, 
"text");
 
  687                 $ilDB->manipulate(
$query);
 
  700                 foreach ($content as 
$key => $val)
 
  702                         if (trim($val) == 
"<!-- language file start -->")
 
  704                                 return array_slice($content,
$key +1);
 
  720                 $ilDB->optimizeTable(
"lng_data");
 
  735                 include_once(
"./Services/Utilities/classes/class.ilStr.php");
 
  739                         if ($scope == 
'global')
 
  745                                 $scopeExtension = 
'.' . $scope;
 
  750                 if ($scope == 
"local")
 
  752                         $path = $this->cust_lang_path;
 
  760                         $this->ilias->raiseError(
"Directory not found: ".
$path, $this->ilias->error_obj->MESSAGE);
 
  766                 $lang_file = 
"ilias_" . $this->key . 
".lang" . $scopeExtension;
 
  769                 if (!is_file($lang_file))
 
  771                         $this->ilias->raiseError(
"File not found: ".$lang_file,$this->ilias->error_obj->MESSAGE);
 
  775                 if (!$content = $this->
cut_header(file($lang_file)))
 
  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"];