4require_once 
"./Services/Object/classes/class.ilObject.php";
 
   45                $this->
ilObject($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;
 
   66                foreach ($languages as 
$lang)
 
   69                        if ($langObj->isInstalled())
 
   71                                $objects[] = $langObj;
 
  107                if ($this->key == $this->lang_default)
 
  118                if ($this->key == $this->lang_user)
 
  136                if (substr($this->
getStatus(), 0, 9) == 
"installed")
 
  154                if (substr($this->
getStatus(), 10) == 
"local")
 
  174                        if ($scope == 
'global')
 
  180                                $scopeExtension = 
'.' . $scope;
 
  187                        if ($this->
check($scope))
 
  192                                        $this->
flush(
'keep_local');
 
  201                                        $newDesc = 
'installed';
 
  203                                else if ($scope == 
'local')
 
  205                                        $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');
 
  257                                        if ($this->
check(
'local'))
 
  278                $refreshed = array();
 
  280                foreach ($languages as 
$lang)
 
  283                        if ($langObj->refresh())
 
  285                                $refreshed[] = $langObj->getKey();
 
  300                global $ilPluginAdmin;
 
  303                include_once(
"./Services/Component/classes/class.ilPluginSlot.php");
 
  305                foreach ($slots as $slot)
 
  307                        $act_plugins = $ilPluginAdmin->getActivePluginsForSlot($slot[
"component_type"],
 
  308                                $slot[
"component_name"], $slot[
"slot_id"]);
 
  309                        foreach ($act_plugins as $plugin)
 
  311                                include_once(
"./Services/Component/classes/class.ilPlugin.php");
 
  313                                        $slot[
"component_name"], $slot[
"slot_id"], $plugin);
 
  316                                        $pl->updateLanguages($a_lang_keys);
 
  331                if (!$a_keep_local_change)
 
  333                        $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = ".
 
  334                                $ilDB->quote($a_lang_key, 
"text"));
 
  338                        $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = ".
 
  339                                $ilDB->quote($a_lang_key, 
"text").
 
  340                                " AND local_change IS NULL");
 
  354                if ($a_mode == 
'all')
 
  356                        $ilDB->manipulate(
"DELETE FROM lng_modules WHERE lang_key = ".
 
  357                                $ilDB->quote($this->key, 
"text"));
 
  372                if ($a_min_date == 
"")
 
  374                        $a_min_date = 
"1980-01-01 00:00:00";
 
  376                if ($a_max_date == 
"")
 
  378                        $a_max_date = 
"2200-01-01 00:00:00";
 
  381                $q = sprintf(
"SELECT * FROM lng_data WHERE lang_key = %s ".
 
  382                        "AND local_change >= %s AND local_change <= %s",
 
  383                        $ilDB->quote($this->key, 
"text"), 
$ilDB->quote($a_min_date, 
"timestamp"),
 
  384                        $ilDB->quote($a_max_date, 
"timestamp"));
 
  390                        $changes[
$row[
"module"]][
$row[
"identifier"]] = 
$row[
"value"];
 
  405                $q = sprintf(
"SELECT MAX(local_change) last_change FROM lng_data ".
 
  406                                        "WHERE lang_key = %s AND local_change IS NOT NULL",
 
  407                        $ilDB->quote($a_key, 
"text"));
 
  412                        return $row[
'last_change'];
 
  427        static function _getLocalChangesByModule($a_key, $a_module)
 
  433                $result = 
$ilDB->queryF(
"SELECT * FROM lng_data WHERE lang_key = %s AND module = %s AND local_change IS NOT NULL",
 
  435                        array(
'text', 
'text'),
 
  436                        array($a_key, $a_module));
 
  440                        $changes[
$row[
'identifier']] = 
$row[
'value'];
 
  457                        if ($scope == 
'global')
 
  463                                $scopeExtension = 
'.' . $scope;
 
  468                if ($scope == 
"local")
 
  470                        $path = $this->cust_lang_path;
 
  473                $lang_file = 
$path . 
"/ilias_" . $this->key . 
".lang" . $scopeExtension;
 
  474                if (is_file($lang_file))
 
  477                        $lang_array = array();
 
  478                        $lang_array[
"common"] = array();
 
  481                        if ($content = $this->
cut_header(file($lang_file)))
 
  490                                else if ($scope == 
'local')
 
  495                                        $change_date = date(
"Y-m-d H:i:s",time());
 
  496                                        $min_date = date(
"Y-m-d H:i:s", filemtime($lang_file));
 
  500                                foreach ($content as 
$key => $val)
 
  507                                        $separated = explode($this->separator,trim($val));
 
  508                                        $pos = strpos($separated[2], $this->comment_separator);
 
  511                                                $separated[3] = substr($separated[2], $pos + strlen($this->comment_separator));
 
  512                                                $separated[2] = substr($separated[2] , 0 , $pos);
 
  516                                        $local_value = $local_changes[$separated[0]][$separated[1]];
 
  522                                                if ($local_value != 
"" and $local_value != $separated[2])
 
  525                                                        $lang_array[$separated[0]][$separated[1]] = $local_value;
 
  530                                                        if ($double_checker[$separated[0]][$separated[1]][$this->key])
 
  532                                                                $this->
ilias->raiseError(
"Duplicate Language Entry in $lang_file:\n$val",
 
  533                                                                        $this->
ilias->error_obj->MESSAGE);
 
  535                                                        $double_checker[$separated[0]][$separated[1]][
$this->key] = 
true;
 
  540                                                                $this->key, $separated[2], $change_date, $separated[3]);
 
  542                                                        $lang_array[$separated[0]][$separated[1]] = $separated[2];
 
  545                                        else if ($scope == 
'local')
 
  549                                                if ($local_value != 
"")
 
  552                                                        $lang_array[$separated[0]][$separated[1]] = $local_value;
 
  560                                                                $this->key, $separated[2], $change_date, $separated[3]);
 
  562                                                        $lang_array[$separated[0]][$separated[1]] = $separated[2];
 
  572                                else if ($scope == 
'local')
 
  574                                        $ld = 
"installed_local";
 
  578                                        $query = 
"UPDATE object_data SET " .
 
  579                                                        "description = ".$ilDB->quote($ld, 
"text").
", " .
 
  580                                                        "last_update = ".$ilDB->now().
" " .
 
  581                                                        "WHERE title = ".$ilDB->quote($this->key, 
"text").
" " .
 
  587                        foreach($lang_array as $module => $lang_arr)
 
  589                                if ($scope == 
"local")
 
  591                                        $q = 
"SELECT * FROM lng_modules WHERE ".
 
  592                                                " lang_key = ".$ilDB->quote($this->key, 
"text").
 
  593                                                " AND module = ".$ilDB->quote($module, 
"text");
 
  594                                        $set = 
$ilDB->query($q);
 
  596                                        $arr2 = unserialize(
$row[
"lang_array"]);
 
  599                                                $lang_arr = array_merge($arr2, $lang_arr);
 
  602                                ilObjLanguage::replaceLangModule($this->key, $module, $lang_arr);
 
  610        static final function replaceLangModule($a_key, $a_module, $a_array)
 
  614                ilGlobalCache::flushAll();
 
  616                $ilDB->manipulate(sprintf(
"DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
 
  617                        $ilDB->quote($a_key, 
"text"), 
$ilDB->quote($a_module, 
"text")));
 
  623        $ilDB->insert(
"lng_modules", array(
 
  624                        "lang_key" => array(
"text", $a_key),
 
  625                        "module" => array(
"text", $a_module),
 
  626                        "lang_array" => array(
"clob", serialize((array) $a_array))
 
  631                $result = 
$ilDB->queryF(
"SELECT lang_array FROM lng_modules WHERE lang_key = %s AND module = %s",
 
  632                        array(
'text',
'text'), array($a_key, $a_module));
 
  635                $unserialied = unserialize(
$row[
'lang_array']);
 
  636                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");
 
  784                foreach ($content as 
$key => $val)
 
  786                        if (trim($val) == 
"<!-- language file start -->")
 
  789                                return array_slice($content,
$key +1);
 
  805                $ilDB->optimizeTable(
"lng_data");
 
  820                include_once(
"./Services/Utilities/classes/class.ilStr.php");
 
  824                        if ($scope == 
'global')
 
  830                                $scopeExtension = 
'.' . $scope;
 
  835                if ($scope == 
"local")
 
  837                        $path = $this->cust_lang_path;
 
  845                        $this->
ilias->raiseError(
"Directory not found: ".
$path, $this->
ilias->error_obj->MESSAGE);
 
  851                $lang_file = 
"ilias_" . $this->key . 
".lang" . $scopeExtension;
 
  854                if (!is_file($lang_file))
 
  856                        $this->
ilias->raiseError(
"File not found: ".$lang_file,$this->
ilias->error_obj->MESSAGE);
 
  860                $content = $this->
cut_header(file($lang_file));
 
  861                if ($content === 
false)
 
  863                        $this->
ilias->raiseError(
"Wrong Header in ".$lang_file,$this->
ilias->error_obj->MESSAGE);
 
  868                foreach ($content as 
$key => $val)
 
  870                        $separated = explode($this->separator, trim($val));
 
  871                        $num = count($separated);
 
  876                                $this->
ilias->raiseError(
"Wrong parameter count in ".$lang_file.
" in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);
 
  880                                $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);
 
  897                $set = 
$ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up".
 
  898                        " ON ud.usr_id = up.usr_id ".
 
  899                        " WHERE up.value = ".
$ilDB->quote($a_lang, 
"text").
 
  900                        " AND up.keyword = ".$ilDB->quote(
"language", 
"text"));
 
  901                $rec = 
$ilDB->fetchAssoc($set);
 
  904                if ($a_lang == 
$lng->lang_default)
 
  906                        $set2 = 
$ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up".
 
  907                                " ON (ud.usr_id = up.usr_id AND up.keyword = ".
$ilDB->quote(
"language", 
"text").
")".
 
  908                                " WHERE up.value IS NULL ");
 
  909                        $rec2 = 
$ilDB->fetchAssoc($set2);
 
  912                return (
int) $rec[
"cnt"] + (int) $rec2[
"cnt"];
 
static refreshPlugins($a_lang_keys=null)
static _deleteLangData($a_lang_key, $a_keep_local_change=false)
Delete languge data.
ilObjLanguage($a_id=0, $a_call_by_reference=false)
Constructor.
static deleteLangEntry($a_module, $a_identifier, $a_lang_key)
Delete lang entry.
static refreshAll()
Refresh all installed languages.
isInstalled()
Check language object status, and return true if language is installed.
uninstall()
uninstall current language
getStatus()
get language status
isLocal()
Check language object status, and return true if a local language file is installed.
static getInstalledLanguages()
Get the language objects of the installed languages.
static countUsers($a_lang)
Count number of users that use a language.
resetUserLanguage($lang_key)
search ILIAS for users which have selected '$lang_key' as their prefered language and reset them to d...
install($scope='')
install current language
isSystemLanguage()
check if language is system language
isUserLanguage()
check if language is system language
flush($a_mode='all')
remove language data from database
static updateLangEntry($a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
insert($scope='')
insert language data from file into database
cut_header($content)
remove lang-file haeder information from '$content' This function seeks for a special keyword where t...
refresh()
refresh current language
getLocalChanges($a_min_date="", $a_max_date="")
get locally changed language entries
optimizeData()
optimizes the db-table langdata
check($scope='')
Validate the logical structure of a lang file.
_getLastLocalChange($a_key)
get the date of the last local change
static replaceLangEntry($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.
update()
update object in db
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
setTitle($a_title)
set object title
ilObject($a_id=0, $a_reference=true)
Constructor @access public.
setDescription($a_desc)
set object description
static getAllSlots()
Get all plugin slots.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
static isUtf8($a_str)
Check whether string is utf-8.
redirection script todo: (a better solution should control the processing via a xml file)