4 require_once
"./Services/Language/classes/class.ilObjLanguage.php";
20 public function __construct($a_id = 0, $a_call_by_reference =
false)
22 parent::__construct($a_id, $a_call_by_reference);
31 require_once
"./Services/Language/classes/class.ilLanguageFile.php";
43 if ($a_local ==
true) {
60 return $this->lng->txt($this->desc);
70 if (!is_dir(CLIENT_DATA_DIR .
'/lang_data')) {
73 return CLIENT_DATA_DIR .
'/lang_data';
93 return $this->cust_lang_path;
103 return self::_getRemarks($this->key);
114 public function getAllValues($a_modules = array(), $a_pattern =
'', $a_topics = array())
116 return self::_getValues($this->key, $a_modules, $a_topics, $a_pattern);
129 public function getChangedValues($a_modules = array(), $a_pattern =
'', $a_topics = array())
131 return self::_getValues($this->key, $a_modules, $a_topics, $a_pattern,
'changed');
146 return self::_getValues($this->key, $a_modules, $a_topics, $a_pattern,
'unchanged');
157 public function getAddedValues($a_modules = array(), $a_pattern =
'', $a_topics = array())
160 $global_values = $global_file_obj->getAllValues();
161 $local_values = self::_getValues($this->key, $a_modules, $a_topics, $a_pattern);
163 return array_diff_key($local_values, $global_values);
181 $global_comments = $global_file_obj->getAllComments();
182 $local_values = self::_getValues($this->key, $a_modules, $a_topics, $a_pattern);
184 return array_intersect_key($local_values, $global_comments);
202 $global_values = $global_file_obj->getAllValues();
203 $local_values = self::_getValues($this->key);
205 return array_merge($global_values, $local_values);
222 $global_comments = $global_file_obj->getAllComments();
225 $local_remarks = self::_getRemarks($this->key,
true);
227 return array_merge($global_comments, $local_remarks);
238 public function importLanguageFile($a_file, $a_mode_existing =
'keepnew')
241 $ilDB = $DIC->database();
246 require_once
"./Services/Language/classes/class.ilLanguageFile.php";
248 if (!$import_file_obj->read()) {
249 $ilErr->raiseError($import_file_obj->getErrorMessage(),
$ilErr->MESSAGE);
252 switch ($a_mode_existing) {
271 $ilDB->manipulate(
"DELETE FROM lng_modules WHERE lang_key = " .
272 $ilDB->quote($this->key,
"text"));
282 foreach ($import_file_obj->getAllValues() as
$key => $value) {
283 if (!isset($to_keep[$key])) {
284 $to_save[
$key] = $value;
287 self::_saveValues($this->key, $to_save, $import_file_obj->getAllComments());
300 $ilDB = $DIC->database();
302 $q =
"SELECT DISTINCT module FROM lng_data WHERE " .
303 " lang_key = " .
$ilDB->quote($a_lang_key,
"text") .
" order by module";
304 $set =
$ilDB->query($q);
308 $modules[] = $rec[
"module"];
322 public static function _getRemarks($a_lang_key, $a_all_changed =
false)
325 $ilDB = $DIC->database();
326 $lng = $DIC->language();
328 $q =
"SELECT module, identifier, remarks" 330 .
" WHERE lang_key = " .
$ilDB->quote($a_lang_key,
"text");
332 if ($a_all_changed) {
333 $q .=
" AND (remarks IS NOT NULL OR local_change IS NOT NULL)";
335 $q .=
" AND remarks IS NOT NULL";
342 $remarks[
$row[
"module"] .
$lng->separator .
$row[
"identifier"]] =
$row[
"remarks"];
361 $a_modules = array(),
367 $ilDB = $DIC->database();
368 $lng = $DIC->language();
370 $q =
"SELECT * FROM lng_data WHERE" .
371 " lang_key = " .
$ilDB->quote($a_lang_key,
"text") .
" ";
373 if (is_array($a_modules) && count($a_modules) > 0) {
374 $q .=
" AND " .
$ilDB->in(
"module", $a_modules,
false,
"text");
376 if (is_array($a_topics) && count($a_topics) > 0) {
377 $q .=
" AND " .
$ilDB->in(
"identifier", $a_topics,
false,
"text");
380 $q .=
" AND " .
$ilDB->like(
"value",
"text",
"%" . $a_pattern .
"%");
382 if ($a_state ==
"changed") {
383 $q .=
" AND NOT local_change IS NULL ";
385 if ($a_state ==
"unchanged") {
386 $q .=
" AND local_change IS NULL ";
388 $q .=
" ORDER BY module, identifier";
390 $set =
$ilDB->query($q);
394 $values[$rec[
"module"] .
$lng->separator . $rec[
"identifier"]] = $rec[
"value"];
410 public static function _saveValues($a_lang_key, $a_values = array(), $a_remarks = array())
413 $ilDB = $DIC->database();
414 $lng = $DIC->language();
416 if (!is_array($a_values)) {
419 $save_array = array();
420 $save_date = date(
"Y-m-d H:i:s", time());
423 require_once
"./Services/Language/classes/class.ilLanguageFile.php";
425 $global_values = $global_file_obj->getAllValues();
426 $global_comments = $global_file_obj->getAllComments();
429 foreach ($a_values as
$key => $value) {
431 if (count(
$keys) == 2) {
434 $save_array[
$module][$topic] = $value;
436 if ($global_values[
$key] != $value
437 or $global_comments[
$key] != $a_remarks[
$key]) {
438 $local_change = $save_date;
440 $local_change = null;
455 foreach ($save_array as
$module => $entries) {
456 $set =
$ilDB->query(sprintf(
457 "SELECT * FROM lng_modules " .
458 "WHERE lang_key = %s AND module = %s",
459 $ilDB->quote($a_lang_key,
"text"),
464 $arr = unserialize(
$row[
"lang_array"]);
465 if (is_array($arr)) {
466 $entries = array_merge($arr, $entries);
468 ilObjLanguage::replaceLangModule($a_lang_key,
$module, $entries);
472 require_once(
'class.ilCachedLanguage.php');
487 $ilDB = $DIC->database();
488 $lng = $DIC->language();
490 if (!is_array($a_values)) {
493 $delete_array = array();
496 foreach ($a_values as
$key => $value) {
498 if (count(
$keys) == 2) {
501 $delete_array[
$module][$topic] = $value;
508 foreach ($delete_array as
$module => $entries) {
509 $set =
$ilDB->query(sprintf(
510 "SELECT * FROM lng_modules " .
511 "WHERE lang_key = %s AND module = %s",
512 $ilDB->quote($a_lang_key,
"text"),
517 $arr = unserialize(
$row[
"lang_array"]);
518 if (is_array($arr)) {
519 $entries = array_diff_key($arr, $entries);
521 ilObjLanguage::replaceLangModule($a_lang_key,
$module, $entries);
getMergedRemarks()
Get the local remarks merged into the remarks of the global language file.
getMergedValues()
Get the local values merged into the values of the global language file.
getAllRemarks()
Get all remarks from the database.
static _getRemarks($a_lang_key, $a_all_changed=false)
Get all remarks of a language.
getCustLangPath()
Get the customized language files path.
getAllValues($a_modules=array(), $a_pattern='', $a_topics=array())
Get all values from the database.
static _deleteValues($a_lang_key, $a_values=array())
Delete a set of translation in the database.
getUnchangedValues($a_modules=array(), $a_pattern='', $a_topics=array())
Get only the unchanged values from the database which are equal to the original language file...
getDataPath()
Get the path for language data written by ILIAS.
isInstalled()
Check language object status, and return true if language is installed.
if($modEnd===false) $module
getChangedValues($a_modules=array(), $a_pattern='', $a_topics=array())
Get only the changed values from the database which differ from the original language file...
getGlobalLanguageFile()
Read and get the global language file as an object.
__construct($a_id=0, $a_call_by_reference=false)
Constructor.
static _deleteLangData($a_lang_key, $a_keep_local_change=false)
Delete languge data.
static _getValues( $a_lang_key, $a_modules=array(), $a_topics=array(), $a_pattern='', $a_state='')
Get the translations of specified topics.
static deleteLangEntry($a_module, $a_identifier, $a_lang_key)
Delete lang entry.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static _saveValues($a_lang_key, $a_values=array(), $a_remarks=array())
Save a set of translation in the database.
setLocal($a_local=true)
Set the local status of the language.
getLongDescription()
Get the full language description.
getAddedValues($a_modules=array(), $a_pattern='', $a_topics=array())
Get only the entries which don't exist in the global language file.
setDescription($a_desc)
set object description
static _getModules($a_lang_key)
Get all modules of a language.
update()
update object in db
getLangPath()
Get the language files path.
static replaceLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
getCommentedValues($a_modules=array(), $a_pattern='', $a_topics=array())
Get all values from the database for wich the global language file has a comment. ...
static _getGlobalLanguageFile($a_lang_key)
Read and get a global language file as a singleton object.