24 require_once
"./classes/class.ilObject.php";
65 $this->
ilObject($a_id,$a_call_by_reference);
70 $this->lang_default = $lng->lang_default;
71 $this->lang_user = $lng->lang_user;
72 $this->lang_path = $lng->lang_path;
73 $this->cust_lang_path = $lng->cust_lang_path;
74 $this->separator = $lng->separator;
75 $this->comment_separator = $lng->comment_separator;
103 if ($this->key == $this->lang_default)
114 if ($this->key == $this->lang_user)
132 if (substr($this->
getStatus(), 0, 9) ==
"installed")
150 if (substr($this->
getStatus(), 10) ==
"local")
170 if ($scope ==
'global')
176 $scopeExtension =
'.' . $scope;
183 if ($this->
check($scope))
188 $this->
flush(
'keep_local');
197 $newDesc =
'installed';
199 else if ($scope ==
'local')
201 $newDesc =
'installed_local';
220 if ((substr($this->status, 0, 9) ==
"installed") && ($this->key != $this->lang_default) && ($this->key != $this->lang_user))
242 $query =
"DELETE FROM lng_data WHERE lang_key=".
243 $ilDB->quote($this->key);
245 if ($a_mode ==
'keep_local')
247 $query .=
" AND local_change='0000-00-00 00:00:00'";
249 $ilDB->query($query);
251 if ($a_mode ==
'all')
253 $query =
"DELETE FROM lng_modules WHERE lang_key=".
254 $ilDB->quote($this->key);
255 $ilDB->query($query);
270 $query =
"SELECT * FROM lng_data WHERE"
271 .
" lang_key =".$ilDB->quote($this->key);
272 if ($a_min_date <>
"")
274 $query .=
" and local_change >= ".$ilDB->quote($a_min_date);
276 if ($a_max_date <>
"")
278 $query .=
" and local_change <= ".$ilDB->quote($a_max_date);
280 $result = $ilDB->query($query);
285 $changes[$row[
"module"]][$row[
"identifier"]] = $row[
"value"];
302 if ($scope ==
'global')
308 $scopeExtension =
'.' . $scope;
313 if ($scope ==
"local")
315 $path = $this->cust_lang_path;
321 $lang_file =
"ilias_" . $this->key .
".lang" . $scopeExtension;
326 $lang_array = array();
327 $lang_array[
"common"] = array();
330 if ($content = $this->
cut_header(file($lang_file)))
337 else if ($scope ==
'local')
339 $change_date = date(
"Y-m-d H:i:s",time());
340 $min_date = date(
"Y-m-d H:i:s", filemtime($lang_file));
344 foreach ($content as
$key => $val)
346 $separated = explode($this->separator,trim($val));
349 $pos = strpos($separated[2], $this->comment_separator);
354 $separated[2] = substr($separated[2] , 0 , $pos);
358 $local_value = $local_changes[$separated[0]][$separated[1]];
362 if ($local_value !=
"" and $local_value != $separated[2])
365 $lang_array[$separated[0]][$separated[1]] = $local_value;
369 if ($double_checker[$separated[0]][$separated[1]][$this->key])
371 $this->ilias->raiseError(
"Duplicate Language Entry: ".
372 $separated[0].
"-".$separated[1].
"-".$this->key,
373 $this->ilias->error_obj->MESSAGE);
376 $double_checker[$separated[0]][$separated[1]][
$this->key] =
true;
380 $query =
"REPLACE INTO lng_data " .
381 "(module, identifier, lang_key, value, local_change) " .
383 "(".$ilDB->quote($separated[0]).
",".
384 $ilDB->quote($separated[1]).
",".
385 $ilDB->quote($this->key).
",".
386 $ilDB->quote($separated[2]).
",".
387 $ilDB->quote(
"0000-00-00 00:00:00").
")";
388 $ilDB->query($query);
389 $lang_array[$separated[0]][$separated[1]] = $separated[2];
392 else if ($scope ==
'local')
394 if ($local_value !=
"")
397 $lang_array[$separated[0]][$separated[1]] = $local_value;
402 $query =
"UPDATE lng_data SET ".
403 "value = ".$ilDB->quote($separated[2]).
", " .
404 "local_change = ".$ilDB->quote($change_date).
" " .
405 "WHERE module = ".$ilDB->quote($separated[0]).
" " .
406 "AND identifier = ".$ilDB->quote($separated[1]).
" " .
407 "AND lang_key = ".$ilDB->quote($this->key);
408 $ilDB->query($query);
409 $lang_array[$separated[0]][$separated[1]] = $separated[2];
416 $query =
"UPDATE object_data SET " .
417 "description = 'installed', " .
418 "last_update = now() " .
419 "WHERE title = ".$ilDB->quote($this->key).
" " .
421 $ilDB->query($query);
423 else if ($scope ==
'local')
425 $query =
"UPDATE object_data SET " .
426 "description = 'installed_local', " .
427 "last_update = now() " .
428 "WHERE title = ".$ilDB->quote($this->key).
" " .
430 $ilDB->query($query);
434 foreach($lang_array as $module => $lang_arr)
436 if ($scope ==
"local")
438 $q =
"SELECT * FROM lng_modules WHERE ".
439 " lang_key = ".$ilDB->quote($this->key).
440 " AND module = ".$ilDB->quote($module);
441 $set = $ilDB->query($q);
443 $arr2 = unserialize($row[
"lang_array"]);
446 $lang_arr = array_merge($arr2, $lang_arr);
449 $query =
"REPLACE INTO lng_modules (lang_key, module, lang_array) VALUES ".
450 "(".$ilDB->quote($this->key).
", " .
451 " ".$ilDB->quote($module).
", " .
452 " ".$ilDB->quote(serialize($lang_arr)).
") ";
453 $ilDB->query($query);
467 $query =
"REPLACE INTO lng_modules (lang_key, module, lang_array) VALUES ".
468 "(".$ilDB->quote($a_key).
", " .
469 " ".$ilDB->quote($a_module).
", " .
470 " ".$ilDB->quote(serialize($a_array)).
") ";
471 $ilDB->query($query);
484 $query =
"UPDATE usr_pref SET " .
485 "value = ".$ilDB->quote($this->lang_default).
" " .
486 "WHERE keyword = 'language' " .
487 "AND value = ".$ilDB->quote($lang_key);
488 $this->ilias->db->query($query);
501 foreach ($content as
$key => $val)
503 if (trim($val) ==
"<!-- language file start -->")
505 return array_slice($content,
$key +1);
520 $query =
"OPTIMIZE TABLE lng_data";
521 $this->ilias->db->query($query);
539 if ($scope ==
'global')
545 $scopeExtension =
'.' . $scope;
550 if ($scope ==
"local")
552 $path = $this->cust_lang_path;
560 $this->ilias->raiseError(
"Directory not found: ".$path, $this->ilias->error_obj->MESSAGE);
566 $lang_file =
"ilias_" . $this->key .
".lang" . $scopeExtension;
569 if (!is_file($lang_file))
571 $this->ilias->raiseError(
"File not found: ".$lang_file,$this->ilias->error_obj->MESSAGE);
575 if (!$content = $this->
cut_header(file($lang_file)))
577 $this->ilias->raiseError(
"Wrong Header in ".$lang_file,$this->ilias->error_obj->MESSAGE);
582 foreach ($content as
$key => $val)
584 $separated = explode($this->separator, trim($val));
585 $num = count($separated);
590 $this->ilias->raiseError(
"Wrong parameter count in ".$lang_file.
" in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);