4require_once 
"./Services/Object/classes/class.ilObject.php";
 
   40    public function __construct($a_id = 0, $a_call_by_reference = 
false)
 
   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;
 
   67        foreach ($languages as 
$lang) {
 
   69            if ($langObj->isInstalled()) {
 
   70                $objects[] = $langObj;
 
  104        if ($this->key == $this->lang_default) {
 
  116        if ($this->key == $this->lang_user) {
 
  131        if (substr($this->
getStatus(), 0, 9) == 
"installed") {
 
  146        if (substr($this->
getStatus(), 10) == 
"local") {
 
  161        if (!empty($scope)) {
 
  162            if ($scope == 
'global') {
 
  165                $scopeExtension = 
'.' . $scope;
 
  171            if ($this->
check($scope)) {
 
  174                    $this->
flush(
'keep_local');
 
  182                    $newDesc = 
'installed';
 
  183                } elseif ($scope == 
'local') {
 
  184                    $newDesc = 
'installed_local';
 
  202        if ((substr($this->status, 0, 9) == 
"installed") && ($this->key != $this->lang_default) && ($this->key != $this->lang_user)) {
 
  222            if ($this->
check()) {
 
  223                $this->
flush(
'keep_local');
 
  229                if ($this->
isLocal() == 
true) {
 
  230                    if ($this->
check(
'local')) {
 
  249        $refreshed = array();
 
  251        foreach ($languages as 
$lang) {
 
  253            if ($langObj->refresh()) {
 
  254                $refreshed[] = $langObj->getKey();
 
  269        global $ilPluginAdmin;
 
  272        include_once(
"./Services/Component/classes/class.ilPluginSlot.php");
 
  274        foreach ($slots as $slot) {
 
  275            $act_plugins = $ilPluginAdmin->getActivePluginsForSlot(
 
  276                $slot[
"component_type"],
 
  277                $slot[
"component_name"],
 
  280            foreach ($act_plugins as $plugin) {
 
  281                include_once(
"./Services/Component/classes/class.ilPlugin.php");
 
  283                    $slot[
"component_type"],
 
  284                    $slot[
"component_name"],
 
  288                if (is_object($pl)) {
 
  289                    $pl->updateLanguages($a_lang_keys);
 
  304        if (!$a_keep_local_change) {
 
  305            $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = " .
 
  306                $ilDB->quote($a_lang_key, 
"text"));
 
  308            $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = " .
 
  309                $ilDB->quote($a_lang_key, 
"text") .
 
  310                " AND local_change IS NULL");
 
  318    public function flush($a_mode = 
'all')
 
  324        if ($a_mode == 
'all') {
 
  325            $ilDB->manipulate(
"DELETE FROM lng_modules WHERE lang_key = " .
 
  326                $ilDB->quote($this->key, 
"text"));
 
  341        if ($a_min_date == 
"") {
 
  342            $a_min_date = 
"1980-01-01 00:00:00";
 
  344        if ($a_max_date == 
"") {
 
  345            $a_max_date = 
"2200-01-01 00:00:00";
 
  349            "SELECT * FROM lng_data WHERE lang_key = %s " .
 
  350            "AND local_change >= %s AND local_change <= %s",
 
  351            $ilDB->quote($this->key, 
"text"),
 
  352            $ilDB->quote($a_min_date, 
"timestamp"),
 
  353            $ilDB->quote($a_max_date, 
"timestamp")
 
  359            $changes[
$row[
"module"]][
$row[
"identifier"]] = 
$row[
"value"];
 
  375            "SELECT MAX(local_change) last_change FROM lng_data " .
 
  376                    "WHERE lang_key = %s AND local_change IS NOT NULL",
 
  377            $ilDB->quote($a_key, 
"text")
 
  382            return $row[
'last_change'];
 
  395    public static function _getLocalChangesByModule($a_key, $a_module)
 
  402            "SELECT * FROM lng_data WHERE lang_key = %s AND module = %s AND local_change IS NOT NULL",
 
  403            array(
'text', 
'text'),
 
  404            array($a_key, $a_module)
 
  408            $changes[
$row[
'identifier']] = 
$row[
'value'];
 
  423        if (!empty($scope)) {
 
  424            if ($scope == 
'global') {
 
  427                $scopeExtension = 
'.' . $scope;
 
  432        if ($scope == 
"local") {
 
  433            $path = $this->cust_lang_path;
 
  436        $lang_file = 
$path . 
"/ilias_" . $this->key . 
".lang" . $scopeExtension;
 
  438        if (is_file($lang_file)) {
 
  440            $lang_array = array();
 
  441            $lang_array[
"common"] = array();
 
  444            if ($content = $this->
cut_header(file($lang_file))) {
 
  450                } elseif ($scope == 
'local') {
 
  454                    $change_date = 
date(
"Y-m-d H:i:s", time());
 
  455                    $min_date = 
date(
"Y-m-d H:i:s", filemtime($lang_file));
 
  459                foreach ($content as 
$key => $val) {
 
  465                    $separated = explode($this->separator, trim($val));
 
  466                    $pos = strpos($separated[2], $this->comment_separator);
 
  467                    if ($pos !== 
false) {
 
  468                        $separated[3] = substr($separated[2], $pos + strlen($this->comment_separator));
 
  469                        $separated[2] = substr($separated[2], 0, $pos);
 
  473                    $local_value = $local_changes[$separated[0]][$separated[1]];
 
  478                        if ($local_value != 
"" and $local_value != $separated[2]) {
 
  480                            $lang_array[$separated[0]][$separated[1]] = $local_value;
 
  483                            if ($double_checker[$separated[0]][$separated[1]][$this->key]) {
 
  484                                $this->
ilias->raiseError(
 
  485                                    "Duplicate Language Entry in $lang_file:\n$val",
 
  486                                    $this->
ilias->error_obj->MESSAGE
 
  489                            $double_checker[$separated[0]][$separated[1]][
$this->key] = 
true;
 
  502                            $lang_array[$separated[0]][$separated[1]] = $separated[2];
 
  504                    } elseif ($scope == 
'local') {
 
  507                        if ($local_value != 
"") {
 
  509                            $lang_array[$separated[0]][$separated[1]] = $local_value;
 
  523                            $lang_array[$separated[0]][$separated[1]] = $separated[2];
 
  531                } elseif ($scope == 
'local') {
 
  532                    $ld = 
"installed_local";
 
  535                    $query = 
"UPDATE object_data SET " .
 
  536                            "description = " . 
$ilDB->quote($ld, 
"text") . 
", " .
 
  537                            "last_update = " . 
$ilDB->now() . 
" " .
 
  538                            "WHERE title = " . 
$ilDB->quote($this->key, 
"text") . 
" " .
 
  544            foreach ($lang_array as 
$module => $lang_arr) {
 
  545                if ($scope == 
"local") {
 
  546                    $q = 
"SELECT * FROM lng_modules WHERE " .
 
  547                        " lang_key = " . 
$ilDB->quote($this->key, 
"text") .
 
  549                    $set = 
$ilDB->query($q);
 
  551                    $arr2 = unserialize(
$row[
"lang_array"]);
 
  552                    if (is_array($arr2)) {
 
  553                        $lang_arr = array_merge($arr2, $lang_arr);
 
  556                ilObjLanguage::replaceLangModule($this->key, 
$module, $lang_arr);
 
  564    final public static function replaceLangModule($a_key, $a_module, $a_array)
 
  569        ilGlobalCache::flushAll();
 
  572            "DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
 
  573            $ilDB->quote($a_key, 
"text"),
 
  574            $ilDB->quote($a_module, 
"text")
 
  581        $ilDB->insert(
"lng_modules", array(
 
  582            "lang_key" => array(
"text", $a_key),
 
  583            "module" => array(
"text", $a_module),
 
  584            "lang_array" => array(
"clob", serialize((array) $a_array))
 
  590            "SELECT lang_array FROM lng_modules WHERE lang_key = %s AND module = %s",
 
  591            array(
'text',
'text'),
 
  592            array($a_key, $a_module)
 
  596        $unserialied = unserialize(
$row[
'lang_array']);
 
  597        if (!is_array($unserialied)) {
 
  601                "Data for module '" . $a_module . 
"' of  language '" . $a_key . 
"' is not correctly saved. " .
 
  602                "Please check the collation of your database tables lng_data and lng_modules. It must be utf8_unicode_ci.",
 
  616        $a_local_change = 
null,
 
  621        ilGlobalCache::flushAll();
 
  623        if (isset($a_remarks)) {
 
  624            $a_remarks = substr($a_remarks, 0, 250);
 
  626        if ($a_remarks == 
'') {
 
  630        if (isset($a_value)) {
 
  631            $a_value = substr($a_value, 0, 4000);
 
  633        if ($a_value == 
'') {
 
  640                'module'                => array(
'text',$a_module),
 
  641                'identifier'    => array(
'text',$a_identifier),
 
  642                'lang_key'              => array(
'text',$a_lang_key)
 
  645                'value'                 => array(
'text',$a_value),
 
  646                'local_change'  => array(
'timestamp',$a_local_change),
 
  647                'remarks'       => array(
'text', $a_remarks)
 
  676        $a_local_change = 
null,
 
  681        if (isset($a_remarks)) {
 
  682            $a_remarks = substr($a_remarks, 0, 250);
 
  684        if ($a_remarks == 
'') {
 
  688        if (isset($a_value)) {
 
  689            $a_value = substr($a_value, 0, 4000);
 
  691        if ($a_value == 
'') {
 
  697            "SET value = %s, local_change = %s, remarks = %s " .
 
  698            "WHERE module = %s AND identifier = %s AND lang_key = %s ",
 
  699            $ilDB->quote($a_value, 
"text"),
 
  700            $ilDB->quote($a_local_change, 
"timestamp"),
 
  701            $ilDB->quote($a_remarks, 
"text"),
 
  702            $ilDB->quote($a_module, 
"text"),
 
  703            $ilDB->quote($a_identifier, 
"text"),
 
  704            $ilDB->quote($a_lang_key, 
"text")
 
  717            "DELETE FROM lng_data " .
 
  718            "WHERE module = %s AND identifier = %s AND lang_key = %s ",
 
  719            $ilDB->quote($a_module, 
"text"),
 
  720            $ilDB->quote($a_identifier, 
"text"),
 
  721            $ilDB->quote($a_lang_key, 
"text")
 
  738        $query = 
"UPDATE usr_pref SET " .
 
  739                "value = " . 
$ilDB->quote($this->lang_default, 
"text") . 
" " .
 
  740                "WHERE keyword = " . 
$ilDB->quote(
'language', 
"text") . 
" " .
 
  741                "AND value = " . 
$ilDB->quote($lang_key, 
"text");
 
  755        foreach ($content as 
$key => $val) {
 
  756            if (trim($val) == 
"<!-- language file start -->") {
 
  757                return array_slice($content, 
$key +1);
 
  787        include_once(
"./Services/Utilities/classes/class.ilStr.php");
 
  789        if (!empty($scope)) {
 
  790            if ($scope == 
'global') {
 
  793                $scopeExtension = 
'.' . $scope;
 
  798        if ($scope == 
"local") {
 
  799            $path = $this->cust_lang_path;
 
  805        if (!is_dir(
$path)) {
 
  806            $this->
ilias->raiseError(
"Directory not found: " . 
$path, $this->
ilias->error_obj->MESSAGE);
 
  812        $lang_file = 
"ilias_" . $this->key . 
".lang" . $scopeExtension;
 
  815        if (!is_file($lang_file)) {
 
  816            $this->
ilias->raiseError(
"File not found: " . $lang_file, $this->
ilias->error_obj->MESSAGE);
 
  820        $content = $this->
cut_header(file($lang_file));
 
  821        if ($content === 
false) {
 
  822            $this->
ilias->raiseError(
"Wrong Header in " . $lang_file, $this->
ilias->error_obj->MESSAGE);
 
  827        foreach ($content as 
$key => $val) {
 
  828            $separated = explode($this->separator, trim($val));
 
  829            $num = count($separated);
 
  833                $this->
ilias->raiseError(
"Wrong parameter count in " . $lang_file . 
" in line $line (Value: $val)! Please check your language file!", $this->
ilias->error_obj->MESSAGE);
 
  836                $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);
 
  853        $set = 
$ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up" .
 
  854            " ON ud.usr_id = up.usr_id " .
 
  855            " WHERE up.value = " . 
$ilDB->quote($a_lang, 
"text") .
 
  856            " AND up.keyword = " . 
$ilDB->quote(
"language", 
"text"));
 
  857        $rec = 
$ilDB->fetchAssoc($set);
 
  860        if ($a_lang == 
$lng->lang_default) {
 
  861            $set2 = 
$ilDB->query(
"SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up" .
 
  862                " ON (ud.usr_id = up.usr_id AND up.keyword = " . 
$ilDB->quote(
"language", 
"text") . 
")" .
 
  863                " WHERE up.value IS NULL ");
 
  864            $rec2 = 
$ilDB->fetchAssoc($set2);
 
  867        return (
int) $rec[
"cnt"] + (int) $rec2[
"cnt"];
 
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
static refreshPlugins($a_lang_keys=null)
static _deleteLangData($a_lang_key, $a_keep_local_change=false)
Delete languge data.
static updateLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
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
insert($scope='')
insert language data from file into database
static cut_header($content)
remove lang-file haeder information from '$content' This function seeks for a special keyword where t...
static replaceLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
__construct($a_id=0, $a_call_by_reference=false)
Constructor.
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.
static _getLastLocalChange($a_key)
get the date of the last local change
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
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.
if($modEnd===false) $module
redirection script todo: (a better solution should control the processing via a xml file)