4 require_once
"./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)))
419 else if ($scope ==
'local')
421 $change_date = date(
"Y-m-d H:i:s",time());
422 $min_date = date(
"Y-m-d H:i:s", filemtime($lang_file));
426 foreach ($content as
$key => $val)
428 $separated = explode($this->separator,trim($val));
431 $pos = strpos($separated[2], $this->comment_separator);
436 $separated[2] = substr($separated[2] , 0 , $pos);
440 $local_value = $local_changes[$separated[0]][$separated[1]];
444 if ($local_value !=
"" and $local_value != $separated[2])
447 $lang_array[$separated[0]][$separated[1]] = $local_value;
451 if ($double_checker[$separated[0]][$separated[1]][$this->key])
453 $this->ilias->raiseError(
"Duplicate Language Entry: ".
454 $separated[0].
"-".$separated[1].
"-".$this->key,
455 $this->ilias->error_obj->MESSAGE);
458 $double_checker[$separated[0]][$separated[1]][
$this->key] =
true;
463 $this->key, $separated[2]);
465 $lang_array[$separated[0]][$separated[1]] = $separated[2];
468 else if ($scope ==
'local')
470 if ($local_value !=
"")
473 $lang_array[$separated[0]][$separated[1]] = $local_value;
479 $this->key, $separated[2], $change_date);
480 $lang_array[$separated[0]][$separated[1]] = $separated[2];
490 else if ($scope ==
'local')
492 $ld =
"installed_local";
496 $query =
"UPDATE object_data SET " .
497 "description = ".$ilDB->quote($ld,
"text").
", " .
498 "last_update = ".$ilDB->now().
" " .
499 "WHERE title = ".$ilDB->quote($this->key,
"text").
" " .
501 $ilDB->manipulate(
$query);
505 foreach($lang_array as $module => $lang_arr)
507 if ($scope ==
"local")
509 $q =
"SELECT * FROM lng_modules WHERE ".
510 " lang_key = ".$ilDB->quote($this->key,
"text").
511 " AND module = ".$ilDB->quote($module,
"text");
512 $set = $ilDB->query(
$q);
513 $row = $ilDB->fetchAssoc($set);
514 $arr2 = unserialize(
$row[
"lang_array"]);
517 $lang_arr = array_merge($arr2, $lang_arr);
534 $ilDB->manipulate(sprintf(
"DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
535 $ilDB->quote($a_key,
"text"), $ilDB->quote($a_module,
"text")));
541 $ilDB->insert(
"lng_modules", array(
542 "lang_key" => array(
"text", $a_key),
543 "module" => array(
"text", $a_module),
544 "lang_array" => array(
"clob", serialize($a_array))
552 $a_lang_key, $a_value, $a_local_change = null)
559 'module' => array(
'text',$a_module),
560 'identifier' => array(
'text',$a_identifier),
561 'lang_key' => array(
'text',$a_lang_key)
564 'value' => array(
'text',$a_value),
565 'local_change' => array(
'timestamp',$a_local_change)
590 $a_lang_key, $a_value, $a_local_change = null)
594 $ilDB->manipulate(sprintf(
"UPDATE lng_data " .
595 "SET value = %s, local_change = %s ".
596 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
597 $ilDB->quote($a_value,
"text"), $ilDB->quote($a_local_change,
"timestamp"),
598 $ilDB->quote($a_module,
"text"), $ilDB->quote($a_identifier,
"text"),
599 $ilDB->quote($a_lang_key,
"text")));
612 $query =
"UPDATE usr_pref SET " .
613 "value = ".$ilDB->quote($this->lang_default,
"text").
" " .
614 "WHERE keyword = ".$ilDB->quote(
'language',
"text").
" ".
615 "AND value = ".$ilDB->quote($lang_key,
"text");
616 $ilDB->manipulate(
$query);
629 foreach ($content as
$key => $val)
631 if (trim($val) ==
"<!-- language file start -->")
633 return array_slice($content,
$key +1);
649 $ilDB->optimizeTable(
"lng_data");
664 include_once(
"./Services/Utilities/classes/class.ilStr.php");
668 if ($scope ==
'global')
674 $scopeExtension =
'.' . $scope;
679 if ($scope ==
"local")
681 $path = $this->cust_lang_path;
689 $this->ilias->raiseError(
"Directory not found: ".$path, $this->ilias->error_obj->MESSAGE);
695 $lang_file =
"ilias_" . $this->key .
".lang" . $scopeExtension;
698 if (!is_file($lang_file))
700 $this->ilias->raiseError(
"File not found: ".$lang_file,$this->ilias->error_obj->MESSAGE);
704 if (!$content = $this->
cut_header(file($lang_file)))
706 $this->ilias->raiseError(
"Wrong Header in ".$lang_file,$this->ilias->error_obj->MESSAGE);
711 foreach ($content as
$key => $val)
713 $separated = explode($this->separator, trim($val));
714 $num = count($separated);
719 $this->ilias->raiseError(
"Wrong parameter count in ".$lang_file.
" in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);
723 $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);
740 $set = $ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up".
741 " ON ud.usr_id = up.usr_id ".
742 " WHERE up.value = ".$ilDB->quote($a_lang,
"text").
743 " AND up.keyword = ".$ilDB->quote(
"language",
"text"));
744 $rec = $ilDB->fetchAssoc($set);
747 if ($a_lang == $lng->lang_default)
749 $set2 = $ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up".
750 " ON (ud.usr_id = up.usr_id AND up.keyword = ".$ilDB->quote(
"language",
"text").
")".
751 " WHERE up.value IS NULL ");
752 $rec2 = $ilDB->fetchAssoc($set2);
755 return (
int) $rec[
"cnt"] + (int) $rec2[
"cnt"];