102 $this->lang_key = ($a_lang_key) ? $a_lang_key : $this->lang_default;
108 $txt = file($this->lang_path.
"/setup_lang_sel_multi.lang");
113 foreach ($txt as
$row)
117 $a = explode($this->separator,trim($row));
118 $this->text[trim($a[0])] = trim($a[1]);
124 $txt = file($this->lang_path.
"/setup_".$this->lang_key.
".lang");
129 foreach ($txt as
$row)
133 $a = explode($this->separator,trim($row));
134 $this->text[trim($a[0])] = trim($a[1]);
161 $translation = $this->text[$a_topic];
164 $pos = strpos($translation, $this->comment_separator);
169 $translation = substr($translation,0,
$pos);
172 if ($translation ==
"")
174 $log->writeLanguageLog($a_topic,$this->lang_key);
175 return "-".$a_topic.
"-";
192 $d = dir($this->lang_path);
194 chdir ($this->lang_path);
197 while ($entry =
$d->read())
199 if (is_file($entry) && (ereg (
"(^setup_.{2}\.lang$)", $entry)))
221 if (empty($a_lang_keys))
223 $a_lang_keys = array();
226 if (empty($a_local_keys))
228 $a_local_keys = array();
242 if (in_array($lang_key, $a_local_keys))
255 if (!array_key_exists($lang_key,$db_langs))
257 if (in_array($lang_key, $a_local_keys))
259 $itype =
'installed_local';
263 $itype =
'installed';
265 $lid = $ilDB->nextId(
"object_data");
266 $query =
"INSERT INTO object_data ".
267 "(obj_id,type,title,description,owner,create_date,last_update) ".
270 $ilDB->quote($lid,
"integer").
",".
271 $ilDB->quote(
"lng",
"text").
",".
272 $ilDB->quote($lang_key,
"text").
",".
273 $ilDB->quote($itype,
"text").
",".
274 $ilDB->quote(
'-1',
"integer").
",".
278 $this->db->manipulate(
$query);
287 foreach ($db_langs as $key => $val)
289 if (!in_array($key,$err_lang))
291 if (in_array($key,$a_lang_keys))
293 if (in_array($key, $a_local_keys))
295 $ld =
'installed_local';
301 $query =
"UPDATE object_data SET " .
302 "description = ".$ilDB->quote($ld,
"text").
", " .
303 "last_update = ".$ilDB->now().
" " .
304 "WHERE obj_id = ".$ilDB->quote($val[
"obj_id"],
"integer").
" " .
305 "AND type = ".$ilDB->quote(
"lng",
"text");
306 $ilDB->manipulate(
$query);
312 if (substr($val[
"status"], 0, 9) ==
"installed")
314 $query =
"UPDATE object_data SET " .
315 "description = ".$ilDB->quote(
"not_installed",
"text").
", " .
316 "last_update = ".$ilDB->now().
" " .
317 "WHERE obj_id = ".$ilDB->quote($val[
"obj_id"],
"integer").
" " .
318 "AND type = ".$ilDB->quote(
"lng",
"text");
319 $ilDB->manipulate(
$query);
325 return ($err_lang) ? $err_lang :
true;
341 $query =
"SELECT * FROM object_data ".
342 "WHERE type = ".$ilDB->quote(
"lng",
"text").
" ".
343 "AND ".$ilDB->like(
"description",
"text",
'installed%');
344 $r = $ilDB->query(
$query);
346 while (
$row = $ilDB->fetchObject($r))
348 $arr[] =
$row->title;
365 $query =
"SELECT * FROM object_data ".
366 "WHERE type = ".$ilDB->quote(
"lng",
"text").
" ".
367 "AND description = ".$ilDB->quote(
'installed_local',
"text");
368 $r = $ilDB->query(
$query);
370 while (
$row = $ilDB->fetchObject($r))
372 $arr[] =
$row->title;
388 $query =
"SELECT * FROM object_data ".
389 "WHERE type = ".$ilDB->quote(
"lng",
"text");
390 $r = $ilDB->query(
$query);
392 while (
$row = $ilDB->fetchObject($r))
394 $arr[
$row->title][
"obj_id"] =
$row->obj_id;
395 $arr[
$row->title][
"status"] =
$row->description;
416 if ($scope ==
'global')
422 $scopeExtension =
'.' . $scope;
427 if ($scope ==
"local")
429 $path = $this->cust_lang_path;
436 $lang_file =
"ilias_" . $a_lang_key .
".lang" . $scopeExtension;
439 if (!is_file($lang_file))
446 if (!$content = $this->
cut_header(file($lang_file)))
453 foreach ($content as $key => $val)
455 $separated = explode($this->separator, trim($val));
456 $num = count($separated);
483 foreach ($content as $key => $val)
485 if (trim($val) ==
"<!-- language file start -->")
487 return array_slice($content,$key +1);
506 if ($a_mode ==
'all')
508 $ilDB->manipulate(
"DELETE FROM lng_modules WHERE lang_key = ".
509 $ilDB->quote($a_lang_key,
"text"));
522 if (!$a_keep_local_change)
524 $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = ".
525 $ilDB->quote($a_lang_key,
"text"));
529 $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = ".
530 $ilDB->quote($a_lang_key,
"text").
531 " AND local_change IS NULL");
546 if ($a_min_date ==
"")
548 $a_min_date =
"1980-01-01 00:00:00";
550 if ($a_max_date ==
"")
552 $a_max_date =
"2200-01-01 00:00:00";
555 $q = sprintf(
"SELECT * FROM lng_data WHERE lang_key = %s ".
556 "AND local_change >= %s AND local_change <= %s",
557 $ilDB->quote($a_lang_key,
"text"),
$ilDB->quote($a_min_date,
"timestamp"),
558 $ilDB->quote($a_max_date,
"timestamp"));
559 $result =
$ilDB->query($q);
564 $changes[
$row[
"module"]][
$row[
"identifier"]] = $row[
"value"];
582 $lang_array = array();
586 if ($scope ==
'global')
592 $scopeExtension =
'.' . $scope;
597 if ($scope ==
"local")
599 $path = $this->cust_lang_path;
605 $lang_file =
"ilias_" .
$lang_key .
".lang" . $scopeExtension;
610 $lang_array = array();
611 $lang_array[
"common"] = array();
614 if ($content = $this->
cut_header(file($lang_file)))
621 else if ($scope ==
'local')
623 $change_date = date(
"Y-m-d H:i:s",time());
624 $min_date = date(
"Y-m-d H:i:s", filemtime($lang_file));
628 foreach ($content as $key => $val)
630 $separated = explode($this->separator,trim($val));
633 $pos = strpos($separated[2], $this->comment_separator);
638 $separated[2] = substr($separated[2] , 0 ,
$pos);
642 $local_value = $local_changes[$separated[0]][$separated[1]];
646 if ($local_value !=
"" and $local_value != $separated[2])
649 $lang_array[$separated[0]][$separated[1]] = $local_value;
658 $lang_array[$separated[0]][$separated[1]] = $separated[2];
661 else if ($scope ==
'local')
663 if ($local_value !=
"")
666 $lang_array[$separated[0]][$separated[1]] = $local_value;
673 $lang_array[$separated[0]][$separated[1]] = $separated[2];
679 foreach($lang_array as $module => $lang_arr)
681 if ($scope ==
"local")
683 $q =
"SELECT * FROM lng_modules WHERE ".
684 " lang_key = ".$ilDB->quote($this->key,
"text").
685 " AND module = ".$ilDB->quote($module,
"text");
686 $set =
$ilDB->query($q);
688 $arr2 = unserialize(
$row[
"lang_array"]);
691 $lang_arr = array_merge($arr2, $lang_arr);
708 $ilDB->manipulate(sprintf(
"DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
709 $ilDB->quote($a_key,
"text"), $ilDB->quote($a_module,
"text")));
714 $ilDB->insert(
"lng_modules", array(
715 "lang_key" => array(
"text", $a_key),
716 "module" => array(
"text", $a_module),
717 "lang_array" => array(
"clob", serialize($a_array))
725 $a_lang_key, $a_value, $a_local_change = null)
729 $ilDB->manipulate(sprintf(
"DELETE FROM lng_data WHERE module = %s AND ".
730 "identifier = %s AND lang_key = %s",
731 $ilDB->quote($a_module,
"text"), $ilDB->quote($a_identifier,
"text"),
732 $ilDB->quote($a_lang_key,
"text")));
736 $ilDB->manipulate(sprintf(
"INSERT INTO lng_data " .
737 "(module, identifier, lang_key, value, local_change) " .
738 "VALUES (%s,%s,%s,%s,%s)",
739 $ilDB->quote($a_module,
"text"), $ilDB->quote($a_identifier,
"text"),
740 $ilDB->quote($a_lang_key,
"text"), $ilDB->quote($a_value,
"text"),
741 $ilDB->quote($a_local_change,
"timestamp")));
748 $a_lang_key, $a_value, $a_local_change = null)
752 $ilDB->manipulate(sprintf(
"UPDATE lng_data " .
753 "SET value = %s, local_change = %s ".
754 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
755 $ilDB->quote($a_value,
"text"), $ilDB->quote($a_local_change,
"timestamp"),
756 $ilDB->quote($a_module,
"text"), $ilDB->quote($a_identifier,
"text"),
757 $ilDB->quote($a_lang_key,
"text")));
767 $local_langs = array();
768 if (is_dir($this->cust_lang_path))
770 $d = dir($this->cust_lang_path);
772 chdir ($this->cust_lang_path);
775 while ($entry =
$d->read())
777 if (is_file($entry) && (ereg (
"(^ilias_.{2}\.lang.local$)", $entry)))
794 $d = dir($this->lang_path);
796 chdir ($this->lang_path);
799 while ($entry =
$d->read())
801 if (is_file($entry) && (ereg (
"(^ilias_.{2}\.lang$)", $entry)))
822 if (empty($a_db_handler) or !is_object($a_db_handler))
827 $this->db =& $a_db_handler;