102 $this->lang_key = ($a_lang_key) ? $a_lang_key : $this->lang_default;
107 $txt = file($this->lang_path.
"/setup_lang_sel_multi.lang");
112 foreach ($txt as
$row)
116 $a = explode($this->separator,trim($row));
117 $this->text[trim($a[0])] = trim($a[1]);
123 $txt = file($this->lang_path.
"/setup_".$this->lang_key.
".lang");
128 foreach ($txt as
$row)
132 $a = explode($this->separator,trim($row));
133 $this->text[trim($a[0])] = trim($a[1]);
160 $translation = $this->text[$a_topic];
163 $pos = strpos($translation, $this->comment_separator);
168 $translation = substr($translation,0,$pos);
171 if ($translation ==
"")
173 $log->writeLanguageLog($a_topic,$this->lang_key);
174 return "-".$a_topic.
"-";
191 $d = dir($this->lang_path);
193 chdir ($this->lang_path);
196 while ($entry =
$d->read())
198 if (is_file($entry) && (ereg (
"(^setup_.{2}\.lang$)", $entry)))
220 if (empty($a_lang_keys))
222 $a_lang_keys = array();
225 if (empty($a_local_keys))
227 $a_local_keys = array();
241 if (in_array($lang_key, $a_local_keys))
254 if (!array_key_exists($lang_key,$db_langs))
256 if (in_array($lang_key, $a_local_keys))
258 $itype =
'installed_local';
262 $itype =
'installed';
264 $lid = $ilDB->nextId(
"object_data");
265 $query =
"INSERT INTO object_data ".
266 "(obj_id,type,title,description,owner,create_date,last_update) ".
269 $ilDB->quote($lid,
"integer").
",".
270 $ilDB->quote(
"lng",
"text").
",".
271 $ilDB->quote($lang_key,
"text").
",".
272 $ilDB->quote($itype,
"text").
",".
273 $ilDB->quote(
'-1',
"integer").
",".
277 $this->db->manipulate(
$query);
286 foreach ($db_langs as $key => $val)
288 if (!in_array($key,$err_lang))
290 if (in_array($key,$a_lang_keys))
292 if (in_array($key, $a_local_keys))
294 $ld =
'installed_local';
300 $query =
"UPDATE object_data SET " .
301 "description = ".$ilDB->quote($ld,
"text").
", " .
302 "last_update = ".$ilDB->now().
" " .
303 "WHERE obj_id = ".$ilDB->quote($val[
"obj_id"],
"integer").
" " .
304 "AND type = ".$ilDB->quote(
"lng",
"text");
305 $ilDB->manipulate(
$query);
311 if (substr($val[
"status"], 0, 9) ==
"installed")
313 $query =
"UPDATE object_data SET " .
314 "description = ".$ilDB->quote(
"not_installed",
"text").
", " .
315 "last_update = ".$ilDB->now().
" " .
316 "WHERE obj_id = ".$ilDB->quote($val[
"obj_id"],
"integer").
" " .
317 "AND type = ".$ilDB->quote(
"lng",
"text");
318 $ilDB->manipulate(
$query);
324 return ($err_lang) ? $err_lang :
true;
340 $query =
"SELECT * FROM object_data ".
341 "WHERE type = ".$ilDB->quote(
"lng",
"text").
" ".
342 "AND ".$ilDB->like(
"description",
"text",
'installed%');
343 $r = $ilDB->query(
$query);
345 while (
$row = $ilDB->fetchObject($r))
347 $arr[] =
$row->title;
364 $query =
"SELECT * FROM object_data ".
365 "WHERE type = ".$ilDB->quote(
"lng",
"text").
" ".
366 "AND description = ".$ilDB->quote(
'installed_local',
"text");
367 $r = $ilDB->query(
$query);
369 while (
$row = $ilDB->fetchObject($r))
371 $arr[] =
$row->title;
387 $query =
"SELECT * FROM object_data ".
388 "WHERE type = ".$ilDB->quote(
"lng",
"text");
389 $r = $ilDB->query(
$query);
391 while (
$row = $ilDB->fetchObject($r))
393 $arr[
$row->title][
"obj_id"] =
$row->obj_id;
394 $arr[
$row->title][
"status"] =
$row->description;
415 if ($scope ==
'global')
421 $scopeExtension =
'.' . $scope;
426 if ($scope ==
"local")
428 $path = $this->cust_lang_path;
435 $lang_file =
"ilias_" . $a_lang_key .
".lang" . $scopeExtension;
438 if (!is_file($lang_file))
445 if (!$content = $this->
cut_header(file($lang_file)))
452 foreach ($content as $key => $val)
454 $separated = explode($this->separator, trim($val));
455 $num = count($separated);
482 foreach ($content as $key => $val)
484 if (trim($val) ==
"<!-- language file start -->")
486 return array_slice($content,$key +1);
505 if ($a_mode ==
'all')
507 $ilDB->manipulate(
"DELETE FROM lng_modules WHERE lang_key = ".
508 $ilDB->quote($a_lang_key,
"text"));
521 if (!$a_keep_local_change)
523 $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = ".
524 $ilDB->quote($a_lang_key,
"text"));
528 $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = ".
529 $ilDB->quote($a_lang_key,
"text").
530 " AND local_change IS NULL");
545 if ($a_min_date ==
"")
547 $a_min_date =
"1980-01-01 00:00:00";
549 if ($a_max_date ==
"")
551 $a_max_date =
"2200-01-01 00:00:00";
554 $q = sprintf(
"SELECT * FROM lng_data WHERE lang_key = %s ".
555 "AND local_change >= %s AND local_change <= %s",
556 $ilDB->quote($a_lang_key,
"text"), $ilDB->quote($a_min_date,
"timestamp"),
557 $ilDB->quote($a_max_date,
"timestamp"));
563 $changes[
$row[
"module"]][
$row[
"identifier"]] = $row[
"value"];
581 $lang_array = array();
585 if ($scope ==
'global')
591 $scopeExtension =
'.' . $scope;
596 if ($scope ==
"local")
598 $path = $this->cust_lang_path;
604 $lang_file =
"ilias_" .
$lang_key .
".lang" . $scopeExtension;
609 $lang_array = array();
610 $lang_array[
"common"] = array();
613 if ($content = $this->
cut_header(file($lang_file)))
620 else if ($scope ==
'local')
622 $change_date = date(
"Y-m-d H:i:s",time());
623 $min_date = date(
"Y-m-d H:i:s", filemtime($lang_file));
627 foreach ($content as $key => $val)
629 $separated = explode($this->separator,trim($val));
632 $pos = strpos($separated[2], $this->comment_separator);
637 $separated[2] = substr($separated[2] , 0 , $pos);
641 $local_value = $local_changes[$separated[0]][$separated[1]];
645 if ($local_value !=
"" and $local_value != $separated[2])
648 $lang_array[$separated[0]][$separated[1]] = $local_value;
657 $lang_array[$separated[0]][$separated[1]] = $separated[2];
660 else if ($scope ==
'local')
662 if ($local_value !=
"")
665 $lang_array[$separated[0]][$separated[1]] = $local_value;
672 $lang_array[$separated[0]][$separated[1]] = $separated[2];
678 foreach($lang_array as $module => $lang_arr)
680 if ($scope ==
"local")
682 $q =
"SELECT * FROM lng_modules WHERE ".
683 " lang_key = ".$ilDB->quote($this->key,
"text").
684 " AND module = ".$ilDB->quote($module,
"text");
685 $set = $ilDB->query($q);
686 $row = $ilDB->fetchAssoc($set);
687 $arr2 = unserialize(
$row[
"lang_array"]);
690 $lang_arr = array_merge($arr2, $lang_arr);
707 $ilDB->manipulate(sprintf(
"DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
708 $ilDB->quote($a_key,
"text"), $ilDB->quote($a_module,
"text")));
713 $ilDB->insert(
"lng_modules", array(
714 "lang_key" => array(
"text", $a_key),
715 "module" => array(
"text", $a_module),
716 "lang_array" => array(
"clob", serialize($a_array))
724 $a_lang_key, $a_value, $a_local_change = null)
728 $ilDB->manipulate(sprintf(
"DELETE FROM lng_data WHERE module = %s AND ".
729 "identifier = %s AND lang_key = %s",
730 $ilDB->quote($a_module,
"text"), $ilDB->quote($a_identifier,
"text"),
731 $ilDB->quote($a_lang_key,
"text")));
735 $ilDB->manipulate(sprintf(
"INSERT INTO lng_data " .
736 "(module, identifier, lang_key, value, local_change) " .
737 "VALUES (%s,%s,%s,%s,%s)",
738 $ilDB->quote($a_module,
"text"), $ilDB->quote($a_identifier,
"text"),
739 $ilDB->quote($a_lang_key,
"text"), $ilDB->quote($a_value,
"text"),
740 $ilDB->quote($a_local_change,
"timestamp")));
747 $a_lang_key, $a_value, $a_local_change = null)
751 $ilDB->manipulate(sprintf(
"UPDATE lng_data " .
752 "SET value = %s, local_change = %s ".
753 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
754 $ilDB->quote($a_value,
"text"), $ilDB->quote($a_local_change,
"timestamp"),
755 $ilDB->quote($a_module,
"text"), $ilDB->quote($a_identifier,
"text"),
756 $ilDB->quote($a_lang_key,
"text")));
766 $local_langs = array();
767 if (is_dir($this->cust_lang_path))
769 $d = dir($this->cust_lang_path);
771 chdir ($this->cust_lang_path);
774 while ($entry =
$d->read())
776 if (is_file($entry) && (ereg (
"(^ilias_.{2}\.lang.local$)", $entry)))
793 $d = dir($this->lang_path);
795 chdir ($this->lang_path);
798 while ($entry =
$d->read())
800 if (is_file($entry) && (ereg (
"(^ilias_.{2}\.lang$)", $entry)))
821 if (empty($a_db_handler) or !is_object($a_db_handler))
826 $this->db =& $a_db_handler;