4 require_once
"./Services/Object/classes/class.ilObject.php";
45 parent::__construct($a_id,$a_call_by_reference);
50 $this->lang_default = $lng->lang_default;
51 $this->lang_user = $lng->lang_user;
52 $this->lang_path = $lng->lang_path;
53 $this->cust_lang_path = $lng->cust_lang_path;
54 $this->separator = $lng->separator;
55 $this->comment_separator = $lng->comment_separator;
70 if ($langObj->isInstalled())
72 $objects[] = $langObj;
108 if ($this->key == $this->lang_default)
119 if ($this->key == $this->lang_user)
137 if (substr($this->
getStatus(), 0, 9) ==
"installed")
155 if (substr($this->
getStatus(), 10) ==
"local")
175 if ($scope ==
'global')
181 $scopeExtension =
'.' . $scope;
188 if ($this->
check($scope))
193 $this->
flush(
'keep_local');
202 $newDesc =
'installed';
204 else if ($scope ==
'local')
206 $newDesc =
'installed_local';
224 if ((substr($this->status, 0, 9) ==
"installed") && ($this->key != $this->lang_default) && ($this->key != $this->lang_user))
248 $this->
flush(
'keep_local');
256 if ($this->
check(
'local'))
276 $refreshed =
array();
281 if ($langObj->refresh())
283 $refreshed[] = $langObj->getKey();
288 self::refreshPlugins($refreshed);
298 global $ilPluginAdmin;
301 include_once(
"./Services/Component/classes/class.ilPluginSlot.php");
303 foreach ($slots as $slot)
305 $act_plugins = $ilPluginAdmin->getActivePluginsForSlot($slot[
"component_type"],
306 $slot[
"component_name"], $slot[
"slot_id"]);
307 foreach ($act_plugins as $plugin)
309 include_once(
"./Services/Component/classes/class.ilPlugin.php");
311 $slot[
"component_name"], $slot[
"slot_id"], $plugin);
314 $pl->updateLanguages($a_lang_keys);
329 if (!$a_keep_local_change)
331 $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = ".
332 $ilDB->quote($a_lang_key,
"text"));
336 $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = ".
337 $ilDB->quote($a_lang_key,
"text").
338 " AND local_change IS NULL");
352 if ($a_mode ==
'all')
354 $ilDB->manipulate(
"DELETE FROM lng_modules WHERE lang_key = ".
355 $ilDB->quote($this->key,
"text"));
370 if ($a_min_date ==
"")
372 $a_min_date =
"1980-01-01 00:00:00";
374 if ($a_max_date ==
"")
376 $a_max_date =
"2200-01-01 00:00:00";
379 $q = sprintf(
"SELECT * FROM lng_data WHERE lang_key = %s ".
380 "AND local_change >= %s AND local_change <= %s",
381 $ilDB->quote($this->key,
"text"), $ilDB->quote($a_min_date,
"timestamp"),
382 $ilDB->quote($a_max_date,
"timestamp"));
388 $changes[
$row[
"module"]][
$row[
"identifier"]] = $row[
"value"];
403 $q = sprintf(
"SELECT MAX(local_change) last_change FROM lng_data ".
404 "WHERE lang_key = %s AND local_change IS NOT NULL",
405 $ilDB->quote($a_key,
"text"));
410 return $row[
'last_change'];
425 static function _getLocalChangesByModule($a_key, $a_module)
431 $result = $ilDB->queryF(
"SELECT * FROM lng_data WHERE lang_key = %s AND module = %s AND local_change IS NOT NULL",
433 array(
'text',
'text'),
434 array($a_key, $a_module));
438 $changes[
$row[
'identifier']] = $row[
'value'];
455 if ($scope ==
'global')
461 $scopeExtension =
'.' . $scope;
466 if ($scope ==
"local")
468 $path = $this->cust_lang_path;
471 $lang_file =
$path .
"/ilias_" . $this->key .
".lang" . $scopeExtension;
472 if (is_file($lang_file))
475 $lang_array =
array();
476 $lang_array[
"common"] =
array();
488 else if ($scope ==
'local')
493 $change_date =
date(
"Y-m-d H:i:s",
time());
494 $min_date =
date(
"Y-m-d H:i:s", filemtime($lang_file));
498 foreach ($content as $key => $val)
505 $separated = explode($this->separator,trim($val));
506 $pos = strpos($separated[2], $this->comment_separator);
509 $separated[3] = substr($separated[2], $pos + strlen($this->comment_separator));
510 $separated[2] = substr($separated[2] , 0 , $pos);
514 $local_value = $local_changes[$separated[0]][$separated[1]];
520 if ($local_value !=
"" and $local_value != $separated[2])
523 $lang_array[$separated[0]][$separated[1]] = $local_value;
528 if ($double_checker[$separated[0]][$separated[1]][$this->key])
530 $this->
ilias->raiseError(
"Duplicate Language Entry in $lang_file:\n$val",
531 $this->
ilias->error_obj->MESSAGE);
533 $double_checker[$separated[0]][$separated[1]][
$this->key] =
true;
538 $this->key, $separated[2], $change_date, $separated[3]);
540 $lang_array[$separated[0]][$separated[1]] = $separated[2];
543 else if ($scope ==
'local')
547 if ($local_value !=
"")
550 $lang_array[$separated[0]][$separated[1]] = $local_value;
558 $this->key, $separated[2], $change_date, $separated[3]);
560 $lang_array[$separated[0]][$separated[1]] = $separated[2];
570 else if ($scope ==
'local')
572 $ld =
"installed_local";
576 $query =
"UPDATE object_data SET " .
577 "description = ".$ilDB->quote(
$ld,
"text").
", " .
578 "last_update = ".$ilDB->now().
" " .
579 "WHERE title = ".$ilDB->quote($this->key,
"text").
" " .
581 $ilDB->manipulate(
$query);
585 foreach($lang_array as $module => $lang_arr)
587 if ($scope ==
"local")
589 $q =
"SELECT * FROM lng_modules WHERE ".
590 " lang_key = ".$ilDB->quote($this->key,
"text").
591 " AND module = ".$ilDB->quote($module,
"text");
592 $set = $ilDB->query($q);
593 $row = $ilDB->fetchAssoc($set);
594 $arr2 = unserialize(
$row[
"lang_array"]);
597 $lang_arr = array_merge($arr2, $lang_arr);
600 ilObjLanguage::replaceLangModule($this->key, $module, $lang_arr);
608 static final function replaceLangModule($a_key, $a_module, $a_array)
611 $ilDB = $DIC->database();
613 ilGlobalCache::flushAll();
615 $ilDB->manipulate(sprintf(
"DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
616 $ilDB->quote($a_key,
"text"),
$ilDB->quote($a_module,
"text")));
623 "lang_key" =>
array(
"text", $a_key),
624 "module" =>
array(
"text", $a_module),
625 "lang_array" =>
array(
"clob", serialize((
array) $a_array))
630 $result =
$ilDB->queryF(
"SELECT lang_array FROM lng_modules WHERE lang_key = %s AND module = %s",
631 array(
'text',
'text'),
array($a_key, $a_module));
634 $unserialied = unserialize(
$row[
'lang_array']);
635 if (!is_array($unserialied))
639 $ilErr->raiseError(
"Data for module '" . $a_module .
"' of language '" . $a_key .
"' is not correctly saved. ".
640 "Please check the collation of your database tables lng_data and lng_modules. It must be utf8_unicode_ci.",
649 $a_lang_key, $a_value, $a_local_change = null, $a_remarks = null)
653 ilGlobalCache::flushAll();
655 if (isset($a_remarks))
657 $a_remarks = substr($a_remarks, 0, 250);
659 if ($a_remarks ==
'')
666 $a_value = substr($a_value, 0, 4000);
676 'module' =>
array(
'text',$a_module),
677 'identifier' =>
array(
'text',$a_identifier),
678 'lang_key' =>
array(
'text',$a_lang_key)
681 'value' =>
array(
'text',$a_value),
682 'local_change' =>
array(
'timestamp',$a_local_change),
683 'remarks' =>
array(
'text', $a_remarks)
708 $a_lang_key, $a_value, $a_local_change = null, $a_remarks = null)
712 if (isset($a_remarks))
714 $a_remarks = substr($a_remarks, 0, 250);
716 if ($a_remarks ==
'')
723 $a_value = substr($a_value, 0, 4000);
730 $ilDB->manipulate(sprintf(
"UPDATE lng_data " .
731 "SET value = %s, local_change = %s, remarks = %s ".
732 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
733 $ilDB->quote($a_value,
"text"), $ilDB->quote($a_local_change,
"timestamp"),
734 $ilDB->quote($a_remarks,
"text"),
735 $ilDB->quote($a_module,
"text"), $ilDB->quote($a_identifier,
"text"),
736 $ilDB->quote($a_lang_key,
"text")));
747 $ilDB->manipulate(sprintf(
"DELETE FROM lng_data " .
748 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
749 $ilDB->quote($a_module,
"text"),
750 $ilDB->quote($a_identifier,
"text"),
751 $ilDB->quote($a_lang_key,
"text")));
767 $query =
"UPDATE usr_pref SET " .
768 "value = ".$ilDB->quote($this->lang_default,
"text").
" " .
769 "WHERE keyword = ".$ilDB->quote(
'language',
"text").
" ".
770 "AND value = ".$ilDB->quote($lang_key,
"text");
771 $ilDB->manipulate(
$query);
784 foreach ($content as $key => $val)
786 if (trim($val) ==
"<!-- language file start -->")
789 return array_slice($content,$key +1);
819 include_once(
"./Services/Utilities/classes/class.ilStr.php");
823 if ($scope ==
'global')
829 $scopeExtension =
'.' . $scope;
834 if ($scope ==
"local")
836 $path = $this->cust_lang_path;
844 $this->
ilias->raiseError(
"Directory not found: ".
$path, $this->
ilias->error_obj->MESSAGE);
850 $lang_file =
"ilias_" . $this->key .
".lang" . $scopeExtension;
853 if (!is_file($lang_file))
855 $this->
ilias->raiseError(
"File not found: ".$lang_file,$this->
ilias->error_obj->MESSAGE);
860 if ($content ===
false)
862 $this->
ilias->raiseError(
"Wrong Header in ".$lang_file,$this->
ilias->error_obj->MESSAGE);
867 foreach ($content as $key => $val)
869 $separated = explode($this->separator, trim($val));
870 $num = count($separated);
875 $this->
ilias->raiseError(
"Wrong parameter count in ".$lang_file.
" in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);
879 $this->
ilias->raiseError(
"Non UTF8 character found in ".$lang_file.
" in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);
896 $set = $ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up".
897 " ON ud.usr_id = up.usr_id ".
898 " WHERE up.value = ".$ilDB->quote($a_lang,
"text").
899 " AND up.keyword = ".$ilDB->quote(
"language",
"text"));
900 $rec = $ilDB->fetchAssoc($set);
903 if ($a_lang == $lng->lang_default)
905 $set2 = $ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up".
906 " ON (ud.usr_id = up.usr_id AND up.keyword = ".$ilDB->quote(
"language",
"text").
")".
907 " WHERE up.value IS NULL ");
908 $rec2 = $ilDB->fetchAssoc($set2);
911 return (
int) $rec[
"cnt"] + (int) $rec2[
"cnt"];
optimizeData()
optimizes the db-table langdata
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
static replaceLangEntry($a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
isUserLanguage()
check if language is system language
static updateLangEntry($a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
Class ilObject Basic functions for all objects.
static getInstalledLanguages()
Get the language objects of the installed languages.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
static countUsers($a_lang)
Count number of users that use a language.
isInstalled()
Check language object status, and return true if language is installed.
insert($scope='')
insert language data from file into database
__construct($a_id=0, $a_call_by_reference=false)
Constructor.
setTitle($a_title)
set object title
getStatus()
get language status
uninstall()
uninstall current language
check($scope='')
Validate the logical structure of a lang file.
static _deleteLangData($a_lang_key, $a_keep_local_change=false)
Delete languge data.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
getLocalChanges($a_min_date="", $a_max_date="")
get locally changed language entries
isSystemLanguage()
check if language is system language
static deleteLangEntry($a_module, $a_identifier, $a_lang_key)
Delete lang entry.
refresh()
refresh current language
resetUserLanguage($lang_key)
search ILIAS for users which have selected '$lang_key' as their prefered language and reset them to d...
redirection script todo: (a better solution should control the processing via a xml file) ...
Reload workbook from saved file
install($scope='')
install current language
Create styles array
The data for the language used.
flush($a_mode='all')
remove language data from database
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
static refreshAll()
Refresh all installed languages.
isLocal()
Check language object status, and return true if a local language file is installed.
setDescription($a_desc)
set object description
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
update()
update object in db
static _getLastLocalChange($a_key)
get the date of the last local change
static refreshPlugins($a_lang_keys=null)
static getAllSlots()
Get all plugin slots.
static cut_header($content)
remove lang-file haeder information from '$content' This function seeks for a special keyword where t...
static isUtf8($a_str)
Check whether string is utf-8.