24 require_once
"./Services/Language/classes/class.ilObjLanguage.php";
51 require_once
"./Services/Language/classes/class.ilLanguageFile.php";
84 return $this->lng->txt($this->desc);
104 return $this->cust_lang_path;
130 return self::_getValues($this->key, $a_modules, NULL, $a_pattern,
'changed');
144 return self::_getValues($this->key, $a_modules, NULL, $a_pattern,
'unchanged');
159 $global_values = $global_file_obj->getAllValues();
162 $commented = array();
163 foreach ($local_values as
$key => $value)
165 if ($global_comments[
$key] !=
"")
167 $commented[
$key] = $value;
185 require_once
"./Services/Language/classes/class.ilLanguageFile.php";
187 if (!$import_file_obj->read())
189 $ilErr->raiseError($import_file_obj->getErrorMessage(),$ilErr->MESSAGE);
192 switch($a_mode_existing)
211 $query =
"DELETE FROM lng_data WHERE lang_key='".$this->key.
"'";
212 $ilDB->query($query);
213 $query =
"DELETE FROM lng_modules WHERE lang_key='".$this->key.
"'";
214 $ilDB->query($query);
224 foreach ($import_file_obj->getAllValues() as
$key => $value)
226 if (!isset($to_keep[$key]))
228 $to_save[
$key] = $value;
245 $q =
"SELECT DISTINCT module FROM lng_data WHERE ".
246 " lang_key = ".$ilDB->quote($a_lang_key).
248 $set = $ilDB->query($q);
252 $modules[] = $rec[
"module"];
269 $a_modules = array(), $a_topics = array(),
270 $a_pattern =
'', $a_state =
'')
274 if (is_array($a_modules))
276 for ($i = 0; $i < count($a_modules); $i++)
278 $a_modules[$i] = $ilDB->quote($a_modules[$i]);
280 $modules_list = implode(
',', $a_modules);
282 if (is_array($a_topics))
284 for ($i = 0; $i < count($a_topics); $i++)
286 $a_topics[$i] = $ilDB->quote($a_topics[$i]);
288 $topics_list = implode(
',', $a_topics);
291 $q =
"SELECT * FROM lng_data WHERE".
292 " lang_key =".$ilDB->quote($a_lang_key);
295 $q .=
" AND module in (". $modules_list.
")";
299 $q .=
" AND identifier in (". $topics_list.
")";
303 $q .=
" AND value like ". $ilDB->quote(
"%".$a_pattern.
"%");
305 if ($a_state ==
"changed")
307 $q .=
" AND local_change <> '0000-00-00 00:00:00'";
309 if ($a_state ==
"unchanged")
311 $q .=
" AND local_change = '0000-00-00 00:00:00'";
313 $q .=
" ORDER BY module, identifier";
314 $set = $ilDB->query($q);
319 $values[$rec[
"module"].$lng->separator.$rec[
"identifier"]] = $rec[
"value"];
331 public static function _saveValues($a_lang_key, $a_values = array())
335 if (!is_array($a_values))
339 $save_array = array();
340 $save_date = date(
"Y-m-d H:i:s", time());
343 require_once
"./Services/Language/classes/class.ilLanguageFile.php";
345 $global_values = $global_file_obj->getAllValues();
348 foreach ($a_values as
$key => $value)
350 $keys = explode($lng->separator,
$key);
351 if (count($keys) == 2)
355 $save_array[$module][$topic] = $value;
356 $local_change = $global_values[
$key] == $value ?
357 "0000-00-00 00:00:00" : $save_date;
359 $q =
"REPLACE INTO lng_data(lang_key, module, identifier, value, local_change)"
361 . $ilDB->quote($a_lang_key).
","
362 . $ilDB->quote($module).
","
363 . $ilDB->quote($topic).
","
364 . $ilDB->quote($value).
","
365 . $ilDB->quote($local_change).
")";
371 foreach ($save_array as $module => $entries)
373 $q =
"SELECT * FROM lng_modules WHERE ".
374 " lang_key = ".$ilDB->quote($a_lang_key).
375 " AND module = ".$ilDB->quote($module);
376 $set = $ilDB->query($q);
378 $arr = unserialize($row[
"lang_array"]);
381 $entries = array_merge($arr, $entries);
383 $q =
"REPLACE INTO lng_modules (lang_key, module, lang_array) VALUES ".
384 "(".$ilDB->quote($a_lang_key).
", " .
385 " ".$ilDB->quote($module).
", " .
386 " ".$ilDB->quote(serialize($entries)).
") ";