ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLanguage Class Reference

language handling More...

+ Collaboration diagram for ilLanguage:

Public Member Functions

 ilLanguage ($a_lang_key)
 Constructor read the single-language file and put this in an array text.
 getLangKey ()
 getDefaultLanguage ()
 txtlng ($a_module, $a_topic, $a_language)
 gets the text for a given topic in a given language if the topic is not in the list, the topic itself with "-" will be returned
 txt ($a_topic, $a_default_lang_fallback_mod="")
 gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be returned
 exists ($a_topic)
 Check if language entry exists.
 loadLanguageModule ($a_module)
 getInstalledLanguages ()
 _lookupEntry ($a_lang_key, $a_mod, $a_id)
 getUsedTopics ()
 getUsedModules ()
 getUserLanguage ()
 ilLanguage ($a_lang_key)
 Constructor read the single-language file and put this in an array text.
 txt ($a_topic)
 gets the text for a given topic
 getLanguages ()
 get all setup languages in the system
 installLanguages ($a_lang_keys, $a_local_keys)
 install languages
 getInstalledLanguages ()
 get already installed languages (in db)
 getInstalledLocalLanguages ()
 get already installed local languages (in db)
 getAvailableLanguages ()
 get already registered languages (in db)
 checkLanguage ($a_lang_key, $scope= '')
 validate the logical structure of a lang-file
 cut_header ($content)
 Remove *.lang header information from '$content'.
 flushLanguage ($a_lang_key, $a_mode= 'all')
 remove language data from database
 getLocalChanges ($a_lang_key, $a_min_date="", $a_max_date="")
 get locally changed language entries
 insertLanguage ($lang_key, $scope= '')
 insert language data from file in database
 getLocalLanguages ()
 Searches for the existence of *.lang.local files.
 getInstallableLanguages ()
 setDbHandler ($a_db_handler)
 set db handler object object db handler
 loadLanguageModule ()

Static Public Member Functions

static lookupId ($a_lang_key)
 Lookup obj_id of language ilDB $ilDB.
static _deleteLangData ($a_lang_key, $a_keep_local_change)
 Delete languge data.
static replaceLangModule ($a_key, $a_module, $a_array)
 Replace language module array.
static replaceLangEntry ($a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
 Replace lang entry.
static updateLangEntry ($a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
 Update lang entry.

Data Fields

 $ilias
 $text = array()
 $lang_default = "en"
 $lang_user
 $lang_path
 $lang_key
 $lang_name
 $separator = "#:#"
 $comment_separator = "###"
 $loaded_modules

Detailed Description

language handling

language handling for setup

this class offers the language handling for an application. it works initially on one file: languages.txt from this file the class can generate many single language files. the constructor is called with a small language abbreviation e.g. $lng = new Language("en"); the constructor reads the single-languagefile en.lang and puts this into an array. with e.g. $lng->txt("user_updated"); you can translate a lang-topic into the actual language

Author
Peter Gabriel pgabr.nosp@m.iel@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
Id:
class.ilLanguage.php 27813 2011-02-21 10:10:41Z smeyer
Todo:
Das Datefeld wird bei Aenderungen einer Sprache (update, install, deinstall) nicht richtig gesetzt!!! Die Formatfunktionen gehoeren nicht in class.Language. Die sind auch woanders einsetzbar!!! Daher->besser in class.Format

this class offers the language handling for an application. the constructor is called with a small language abbreviation e.g. $lng = new Language("en"); the constructor reads the single-languagefile en.lang and puts this into an array. with e.g. $lng->txt("user_updated"); you can translate a lang-topic into the actual language

Author
Peter Gabriel pgabr.nosp@m.iel@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
Id:
class.ilLanguage.php 27896 2011-02-28 15:49:51Z smeyer
Todo:
The DATE field is not set correctly on changes of a language (update, install, your stable). The format functions do not belong in class.Language. Those are also applicable elsewhere. Therefore, they would be better placed in class.Format

Definition at line 26 of file class.ilLanguage.php.

Member Function Documentation

static ilLanguage::_deleteLangData (   $a_lang_key,
  $a_keep_local_change 
)
static

Delete languge data.

Parameters
stringlang key

Definition at line 517 of file class.ilLanguage.php.

References $ilDB.

Referenced by flushLanguage().

{
global $ilDB;
if (!$a_keep_local_change)
{
$ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = ".
$ilDB->quote($a_lang_key, "text"));
}
else
{
$ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = ".
$ilDB->quote($a_lang_key, "text").
" AND local_change IS NULL");
}
}

+ Here is the caller graph for this function:

ilLanguage::_lookupEntry (   $a_lang_key,
  $a_mod,
  $a_id 
)

Definition at line 329 of file class.ilLanguage.php.

References $ilDB.

Referenced by ilLinkChecker\__txt(), ilAccountRegistrationGUI\displayForm(), ilPersonalSettingsGUI\initGeneralSettingsForm(), ilAccountMail\replacePlaceholders(), ilStartUpGUI\showLanguageSelection(), ilStartUpGUI\showUserAgreement(), ilCron\txt(), ilCronCheckUserAccounts\txt(), txt(), and txtlng().

{
global $ilDB;
$set = $ilDB->query($q = sprintf("SELECT * FROM lng_data WHERE module = %s ".
"AND lang_key = %s AND identifier = %s",
$ilDB->quote((string) $a_mod, "text"), $ilDB->quote((string) $a_lang_key, "text"),
$ilDB->quote((string) $a_id, "text")));
$rec = $ilDB->fetchAssoc($set);
if ($rec["value"] != "")
{
// remember the used topics
$this->used_topics[$a_id] = $a_id;
$this->used_modules[$a_mod] = $a_mod;
return $rec["value"];
}
return "-".$a_id."-";
}

+ Here is the caller graph for this function:

ilLanguage::checkLanguage (   $a_lang_key,
  $scope = '' 
)

validate the logical structure of a lang-file

This function checks if a lang-file of a given lang_key exists, the file has a header, and each lang-entry consists of exactly three elements (module, identifier, value).

Parameters
string$a_lang_keyinternational language key (2 digits)
string$scopeempty (global) or "local"
Returns
string $info_text message about results of check OR "1" if all checks successfully passed

Definition at line 411 of file class.ilLanguage.php.

References $lang_path, $path, and cut_header().

Referenced by installLanguages().

{
if (!empty($scope))
{
if ($scope == 'global')
{
$scope = '';
}
else
{
$scopeExtension = '.' . $scope;
}
}
if ($scope == "local")
{
$path = $this->cust_lang_path;
}
$tmpPath = getcwd();
chdir($path);
// compute lang-file name format
$lang_file = "ilias_" . $a_lang_key . ".lang" . $scopeExtension;
// file check
if (!is_file($lang_file))
{
chdir($tmpPath);
return false;
}
// header check
if (!$content = $this->cut_header(file($lang_file)))
{
chdir($tmpPath);
return false;
}
// check (counting) elements of each lang-entry
foreach ($content as $key => $val)
{
$separated = explode($this->separator, trim($val));
$num = count($separated);
if ($num != 3)
{
chdir($tmpPath);
return false;
}
}
chdir($tmpPath);
// no error occured
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLanguage::cut_header (   $content)

Remove *.lang header information from '$content'.

This function seeks for a special keyword where the language information starts. If found it returns the plain language information; otherwise returns false.

Parameters
string$contentexpect an ILIAS lang-file
Returns
string $content content without header info OR false if no valid header was found private

Definition at line 480 of file class.ilLanguage.php.

Referenced by checkLanguage(), and insertLanguage().

{
foreach ($content as $key => $val)
{
if (trim($val) == "<!-- language file start -->")
{
return array_slice($content,$key +1);
}
}
return false;
}

+ Here is the caller graph for this function:

ilLanguage::exists (   $a_topic)

Check if language entry exists.

Parameters
object$a_topic
Returns

Definition at line 261 of file class.ilLanguage.php.

{
return isset($this->text[$a_topic]);
}
ilLanguage::flushLanguage (   $a_lang_key,
  $a_mode = 'all' 
)

remove language data from database

Parameters
stringlanguage key
string"all" or "keep_local"

Definition at line 499 of file class.ilLanguage.php.

References $ilDB, and _deleteLangData().

Referenced by installLanguages().

{
$ilDB = $this->db;
ilLanguage::_deleteLangData($a_lang_key, ($a_mode == 'keep_local'));
if ($a_mode == 'all')
{
$ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = ".
$ilDB->quote($a_lang_key, "text"));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLanguage::getAvailableLanguages ( )

get already registered languages (in db)

Returns
array array with information about languages that has been registered in db

Definition at line 381 of file class.ilLanguage.php.

References $ilDB, $query, and $row.

Referenced by installLanguages().

{
global $ilDB;
$arr = array();
$query = "SELECT * FROM object_data ".
"WHERE type = ".$ilDB->quote("lng", "text");
$r = $ilDB->query($query);
while ($row = $ilDB->fetchObject($r))
{
$arr[$row->title]["obj_id"] = $row->obj_id;
$arr[$row->title]["status"] = $row->description;
}
return $arr;
}

+ Here is the caller graph for this function:

ilLanguage::getDefaultLanguage ( )

Definition at line 185 of file class.ilLanguage.php.

{
return $this->lang_default ? $this->lang_default : 'en';
}
ilLanguage::getInstallableLanguages ( )

Definition at line 789 of file class.ilLanguage.php.

References $d, $lang_key, and getLanguages().

{
$setup_langs = $this->getLanguages();
$d = dir($this->lang_path);
$tmpPath = getcwd();
chdir ($this->lang_path);
// get available lang-files
while ($entry = $d->read())
{
if (is_file($entry) && (ereg ("(^ilias_.{2}\.lang$)", $entry)))
{
$lang_key = substr($entry,6,2);
$languages1[] = $lang_key;
}
}
//$languages = array_intersect($languages1,$setup_langs);
chdir($tmpPath);
return $languages1;
}

+ Here is the call graph for this function:

ilLanguage::getInstalledLanguages ( )

Definition at line 313 of file class.ilLanguage.php.

References $lang, and ilObject\_getObjectsByType().

Referenced by ilLanguage(), and ilInitialisation\initLanguage().

{
$langlist = ilObject::_getObjectsByType("lng");
foreach ($langlist as $lang)
{
if (substr($lang["desc"], 0, 9) == "installed")
{
$languages[] = $lang["title"];
}
}
return $languages ? $languages : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLanguage::getInstalledLanguages ( )

get already installed languages (in db)

Returns
array array with inforamtion about each installed language

Definition at line 334 of file class.ilLanguage.php.

References $ilDB, $query, and $row.

{
global $ilDB;
$arr = array();
$query = "SELECT * FROM object_data ".
"WHERE type = ".$ilDB->quote("lng", "text")." ".
"AND ".$ilDB->like("description", "text", 'installed%');
$r = $ilDB->query($query);
while ($row = $ilDB->fetchObject($r))
{
$arr[] = $row->title;
}
return $arr;
}
ilLanguage::getInstalledLocalLanguages ( )

get already installed local languages (in db)

Returns
array array with inforamtion about each installed language

Definition at line 358 of file class.ilLanguage.php.

References $ilDB, $query, and $row.

{
global $ilDB;
$arr = array();
$query = "SELECT * FROM object_data ".
"WHERE type = ".$ilDB->quote("lng", "text")." ".
"AND description = ".$ilDB->quote('installed_local', "text");
$r = $ilDB->query($query);
while ($row = $ilDB->fetchObject($r))
{
$arr[] = $row->title;
}
return $arr;
}
ilLanguage::getLangKey ( )

Definition at line 180 of file class.ilLanguage.php.

References $lang_key.

{
}
ilLanguage::getLanguages ( )

get all setup languages in the system

the functions looks for setup*.lang-files in the languagedirectory public

Returns
array langs

Definition at line 189 of file class.ilLanguage.php.

References $d, and $lang_key.

Referenced by getInstallableLanguages().

{
$d = dir($this->lang_path);
$tmpPath = getcwd();
chdir ($this->lang_path);
// get available setup-files
while ($entry = $d->read())
{
if (is_file($entry) && (ereg ("(^setup_.{2}\.lang$)", $entry)))
{
$lang_key = substr($entry,6,2);
$languages[] = $lang_key;
}
}
chdir($tmpPath);
return $languages;
}

+ Here is the caller graph for this function:

ilLanguage::getLocalChanges (   $a_lang_key,
  $a_min_date = "",
  $a_max_date = "" 
)

get locally changed language entries

Parameters
stringlanguage key
stringminimum change date "yyyy-mm-dd hh:mm:ss"
stringmaximum change date "yyyy-mm-dd hh:mm:ss"
Returns
array [module][identifier] => value

Definition at line 541 of file class.ilLanguage.php.

References $ilDB, $result, $row, and DB_FETCHMODE_ASSOC.

Referenced by insertLanguage().

{
$ilDB = $this->db;
if ($a_min_date == "")
{
$a_min_date = "1980-01-01 00:00:00";
}
if ($a_max_date == "")
{
$a_max_date = "2200-01-01 00:00:00";
}
$q = sprintf("SELECT * FROM lng_data WHERE lang_key = %s ".
"AND local_change >= %s AND local_change <= %s",
$ilDB->quote($a_lang_key, "text"), $ilDB->quote($a_min_date, "timestamp"),
$ilDB->quote($a_max_date, "timestamp"));
$result = $ilDB->query($q);
$changes = array();
while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
$changes[$row["module"]][$row["identifier"]] = $row["value"];
}
return $changes;
}

+ Here is the caller graph for this function:

ilLanguage::getLocalLanguages ( )

Searches for the existence of *.lang.local files.

return $local_langs array of language keys

Definition at line 764 of file class.ilLanguage.php.

References $d, and $lang_key.

{
$local_langs = array();
if (is_dir($this->cust_lang_path))
{
$d = dir($this->cust_lang_path);
$tmpPath = getcwd();
chdir ($this->cust_lang_path);
// get available .lang.local files
while ($entry = $d->read())
{
if (is_file($entry) && (ereg ("(^ilias_.{2}\.lang.local$)", $entry)))
{
$lang_key = substr($entry,6,2);
$local_langs[] = $lang_key;
}
}
chdir($tmpPath);
}
return $local_langs;
}
ilLanguage::getUsedModules ( )

Definition at line 387 of file class.ilLanguage.php.

{
if (is_array($this->used_modules))
{
asort($this->used_modules);
return $this->used_modules;
}
else
{
return array();
}
}
ilLanguage::getUsedTopics ( )

Definition at line 374 of file class.ilLanguage.php.

{
if (is_array($this->used_topics))
{
asort($this->used_topics);
return $this->used_topics;
}
else
{
return array();
}
}
ilLanguage::getUserLanguage ( )

Definition at line 400 of file class.ilLanguage.php.

References $lang_user.

{
}
ilLanguage::ilLanguage (   $a_lang_key)

Constructor read the single-language file and put this in an array text.

the text array is two-dimensional. First dimension is the language. Second dimension is the languagetopic. Content is the translation. public

Parameters
stringlanguagecode (two characters), e.g. "de", "en", "in"
Returns
boolean false if reading failed

Definition at line 100 of file class.ilLanguage.php.

References $row, and ILIAS_ABSOLUTE_PATH.

{
$this->lang_key = ($a_lang_key) ? $a_lang_key : $this->lang_default;
$this->lang_path = ILIAS_ABSOLUTE_PATH."/lang";
$this->cust_lang_path = ILIAS_ABSOLUTE_PATH."/Customizing/global/lang";
// set lang file...
$txt = file($this->lang_path."/setup_lang_sel_multi.lang");
// ...and load langdata
if (is_array($txt))
{
foreach ($txt as $row)
{
if ($row[0] != "#")
{
$a = explode($this->separator,trim($row));
$this->text[trim($a[0])] = trim($a[1]);
}
}
}
// set lang file...
$txt = file($this->lang_path."/setup_".$this->lang_key.".lang");
// ...and load langdata
if (is_array($txt))
{
foreach ($txt as $row)
{
if ($row[0] != "#")
{
$a = explode($this->separator,trim($row));
$this->text[trim($a[0])] = trim($a[1]);
}
}
return true;
}
return false;
}
ilLanguage::ilLanguage (   $a_lang_key)

Constructor read the single-language file and put this in an array text.

the text array is two-dimensional. First dimension is the language. Second dimension is the languagetopic. Content is the translation.

public

Parameters
stringlanguagecode (two characters), e.g. "de", "en", "in"
Returns
boolean false if reading failed

Definition at line 123 of file class.ilLanguage.php.

References $ilias, $ilIliasIniFile, $ilSetting, $lang_default, $log, getInstalledLanguages(), ILIAS_ABSOLUTE_PATH, and loadLanguageModule().

{
// store used modules and topics in a global variable
// ($lng seems to be initialized more than once)
global $ilias_lang_used_topics;
global $ilias_lang_used_modules;
$this->used_topics =& $ilias_lang_used_topics;
$this->used_modules =& $ilias_lang_used_modules;
$this->ilias =& $ilias;
if (!isset($log))
{
if (is_object($ilias))
{
$this->log = new ilLog(ILIAS_LOG_DIR,ILIAS_LOG_FILE,$ilias->getClientId(),ILIAS_LOG_ENABLED);
}
}
else
{
$this->log =& $log;
}
$this->lang_key = $a_lang_key;
$this->text = array();
$this->loaded_modules = array();
//$this->lang_path = ILIAS_ABSOLUTE_PATH.substr($this->ilias->ini->readVariable("language","path"),1);
// if no directory was found fall back to default lang dir
//if (!is_dir($this->lang_path))
//{
$this->lang_path = ILIAS_ABSOLUTE_PATH."/lang";
//}
$this->cust_lang_path = ILIAS_ABSOLUTE_PATH."/Customizing/global/lang";
$this->lang_default = $ilIliasIniFile->readVariable("language","default");
if (is_object($ilSetting) && $ilSetting->get("language") != "")
{
$this->lang_default = $ilSetting->get("language");
}
$this->lang_user = $ilUser->prefs["language"];
$langs = $this->getInstalledLanguages();
if (!in_array($this->lang_key,$langs))
{
$this->lang_key = $this->lang_default;
}
$this->loadLanguageModule("common");
return true;
}

+ Here is the call graph for this function:

ilLanguage::insertLanguage (   $lang_key,
  $scope = '' 
)

insert language data from file in database

Parameters
string$lang_keyinternational language key (2 digits)
string$scopeempty (global) or "local"
Returns
void

Definition at line 577 of file class.ilLanguage.php.

References $ilDB, $lang_key, $lang_path, $path, $row, cut_header(), getLocalChanges(), replaceLangEntry(), replaceLangModule(), and updateLangEntry().

Referenced by installLanguages().

{
$ilDB =& $this->db;
$lang_array = array();
if (!empty($scope))
{
if ($scope == 'global')
{
$scope = '';
}
else
{
$scopeExtension = '.' . $scope;
}
}
if ($scope == "local")
{
$path = $this->cust_lang_path;
}
$tmpPath = getcwd();
chdir($path);
$lang_file = "ilias_" . $lang_key . ".lang" . $scopeExtension;
if ($lang_file)
{
// initialize the array for updating lng_modules below
$lang_array = array();
$lang_array["common"] = array();
// remove header first
if ($content = $this->cut_header(file($lang_file)))
{
// get the local changes from the database
if (empty($scope))
{
$local_changes = $this->getLocalChanges($lang_key);
}
else if ($scope == 'local')
{
$change_date = date("Y-m-d H:i:s",time());
$min_date = date("Y-m-d H:i:s", filemtime($lang_file));
$local_changes = $this->getLocalChanges($lang_key, $min_date);
}
foreach ($content as $key => $val)
{
$separated = explode($this->separator,trim($val));
//get position of the comment_separator
$pos = strpos($separated[2], $this->comment_separator);
if ($pos !== false)
{
//cut comment of
$separated[2] = substr($separated[2] , 0 , $pos);
}
// check if the value has a local change
$local_value = $local_changes[$separated[0]][$separated[1]];
if (empty($scope))
{
if ($local_value != "" and $local_value != $separated[2])
{
// keep the locally changed value
$lang_array[$separated[0]][$separated[1]] = $local_value;
}
else
{
// insert a new value if no local value exists
// reset local_change if the values are equal
ilLanguage::replaceLangEntry($separated[0], $separated[1],
$lang_key, $separated[2]);
$lang_array[$separated[0]][$separated[1]] = $separated[2];
}
}
else if ($scope == 'local')
{
if ($local_value != "")
{
// keep a locally changed value that is newer than the local file
$lang_array[$separated[0]][$separated[1]] = $local_value;
}
else
{
// UPDATE because the global values have already been INSERTed
ilLanguage::updateLangEntry($separated[0], $separated[1],
$lang_key, $separated[2], $change_date);
$lang_array[$separated[0]][$separated[1]] = $separated[2];
}
}
}
}
foreach($lang_array as $module => $lang_arr)
{
if ($scope == "local")
{
$q = "SELECT * FROM lng_modules WHERE ".
" lang_key = ".$ilDB->quote($this->key, "text").
" AND module = ".$ilDB->quote($module, "text");
$set = $ilDB->query($q);
$row = $ilDB->fetchAssoc($set);
$arr2 = unserialize($row["lang_array"]);
if (is_array($arr2))
{
$lang_arr = array_merge($arr2, $lang_arr);
}
}
}
}
chdir($tmpPath);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLanguage::installLanguages (   $a_lang_keys,
  $a_local_keys 
)

install languages

Parameters
arrayarray with lang_keys of languages to install
Returns
boolean true on success

Definition at line 216 of file class.ilLanguage.php.

References $ilDB, $lang_key, $query, checkLanguage(), flushLanguage(), getAvailableLanguages(), and insertLanguage().

{
global $ilDB;
if (empty($a_lang_keys))
{
$a_lang_keys = array();
}
if (empty($a_local_keys))
{
$a_local_keys = array();
}
$err_lang = array();
$db_langs = $this->getAvailableLanguages();
foreach ($a_lang_keys as $lang_key)
{
if ($this->checkLanguage($lang_key))
{
$this->flushLanguage($lang_key, 'keep_local');
$this->insertLanguage($lang_key);
if (in_array($lang_key, $a_local_keys))
{
if ($this->checkLanguage($lang_key, "local"))
{
$this->insertLanguage($lang_key, "local");
}
else
{
$err_lang[] = $lang_key;
}
}
// register language first time install
if (!array_key_exists($lang_key,$db_langs))
{
if (in_array($lang_key, $a_local_keys))
{
$itype = 'installed_local';
}
else
{
$itype = 'installed';
}
$lid = $ilDB->nextId("object_data");
$query = "INSERT INTO object_data ".
"(obj_id,type,title,description,owner,create_date,last_update) ".
"VALUES ".
"(".
$ilDB->quote($lid, "integer").",".
$ilDB->quote("lng", "text").",".
$ilDB->quote($lang_key, "text").",".
$ilDB->quote($itype, "text").",".
$ilDB->quote('-1',"integer").",".
$ilDB->now().",".
$ilDB->now().
")";
$this->db->manipulate($query);
}
}
else
{
$err_lang[] = $lang_key;
}
}
foreach ($db_langs as $key => $val)
{
if (!in_array($key,$err_lang))
{
if (in_array($key,$a_lang_keys))
{
if (in_array($key, $a_local_keys))
{
$ld = 'installed_local';
}
else
{
$ld = 'installed';
}
$query = "UPDATE object_data SET " .
"description = ".$ilDB->quote($ld, "text").", " .
"last_update = ".$ilDB->now()." " .
"WHERE obj_id = ".$ilDB->quote($val["obj_id"], "integer")." " .
"AND type = ".$ilDB->quote("lng", "text");
$ilDB->manipulate($query);
}
else
{
$this->flushLanguage($key, "all");
if (substr($val["status"], 0, 9) == "installed")
{
$query = "UPDATE object_data SET " .
"description = ".$ilDB->quote("not_installed", "text").", " .
"last_update = ".$ilDB->now()." " .
"WHERE obj_id = ".$ilDB->quote($val["obj_id"], "integer")." " .
"AND type = ".$ilDB->quote("lng", "text");
$ilDB->manipulate($query);
}
}
}
}
return ($err_lang) ? $err_lang : true;
}

+ Here is the call graph for this function:

ilLanguage::loadLanguageModule (   $a_module)

Definition at line 266 of file class.ilLanguage.php.

References $ilDB, $lang_key, $lang_user, $row, and DB_FETCHMODE_ASSOC.

Referenced by ilObjUserGUI\__sendProfileMail().

{
global $ilDB;
if (in_array($a_module, $this->loaded_modules))
{
return;
}
$this->loaded_modules[] = $a_module;
// remember the used modules globally
$this->used_modules[$a_module] = $a_module;
if (empty($this->lang_key))
{
}
/*
$query = "SELECT identifier,value FROM lng_data " .
"WHERE lang_key = '" . $lang_key."' " .
"AND module = '$a_module'";
$r = $this->ilias->db->query($query);
while ($row = $r->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->text[$row->identifier] = $row->value;
}
*/
$q = "SELECT * FROM lng_modules " .
"WHERE lang_key = ".$ilDB->quote($lang_key, "text")." AND module = ".
$ilDB->quote($a_module, "text");
$r = $ilDB->query($q);
$row = $r->fetchRow(DB_FETCHMODE_ASSOC);
$new_text = unserialize($row["lang_array"]);
if (is_array($new_text))
{
$this->text = array_merge($this->text, $new_text);
}
}

+ Here is the caller graph for this function:

ilLanguage::loadLanguageModule ( )

Definition at line 831 of file class.ilLanguage.php.

Referenced by ilLanguage().

{
}

+ Here is the caller graph for this function:

static ilLanguage::lookupId (   $a_lang_key)
static

Lookup obj_id of language ilDB $ilDB.

Parameters
string$a_lang_key
Returns
int

Definition at line 357 of file class.ilLanguage.php.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilStartUpGUI\getLoginPageEditorHTML(), and ilAuthLoginPageEditorTableGUI\parse().

{
global $ilDB;
$query = 'SELECT obj_id FROM object_data '.' '.
'WHERE title = '.$ilDB->quote($a_lang_key, 'text').' '.
'AND type = '.$ilDB->quote('lng','text');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->obj_id;
}
return 0;
}

+ Here is the caller graph for this function:

static ilLanguage::replaceLangEntry (   $a_module,
  $a_identifier,
  $a_lang_key,
  $a_value,
  $a_local_change = null 
)
staticfinal

Replace lang entry.

Definition at line 723 of file class.ilLanguage.php.

References $ilDB.

Referenced by insertLanguage().

{
global $ilDB;
$ilDB->manipulate(sprintf("DELETE FROM lng_data WHERE module = %s AND ".
"identifier = %s AND lang_key = %s",
$ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
$ilDB->quote($a_lang_key, "text")));
// insert a new value if no local value exists
// reset local_change if the values are equal
$ilDB->manipulate(sprintf("INSERT INTO lng_data " .
"(module, identifier, lang_key, value, local_change) " .
"VALUES (%s,%s,%s,%s,%s)",
$ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
$ilDB->quote($a_lang_key, "text"), $ilDB->quote($a_value, "text"),
$ilDB->quote($a_local_change, "timestamp")));
}

+ Here is the caller graph for this function:

static ilLanguage::replaceLangModule (   $a_key,
  $a_module,
  $a_array 
)
staticfinal

Replace language module array.

Definition at line 703 of file class.ilLanguage.php.

References $ilDB.

Referenced by insertLanguage().

{
global $ilDB;
$ilDB->manipulate(sprintf("DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
$ilDB->quote($a_key, "text"), $ilDB->quote($a_module, "text")));
/*$ilDB->manipulate(sprintf("INSERT INTO lng_modules (lang_key, module, lang_array) VALUES ".
"(%s,%s,%s)", $ilDB->quote($a_key, "text"),
$ilDB->quote($a_module, "text"),
$ilDB->quote(serialize($a_array), "clob")));*/
$ilDB->insert("lng_modules", array(
"lang_key" => array("text", $a_key),
"module" => array("text", $a_module),
"lang_array" => array("clob", serialize($a_array))
));
}

+ Here is the caller graph for this function:

ilLanguage::setDbHandler (   $a_db_handler)

set db handler object object db handler

Returns
boolean true on success

Definition at line 819 of file class.ilLanguage.php.

{
if (empty($a_db_handler) or !is_object($a_db_handler))
{
return false;
}
$this->db =& $a_db_handler;
return true;
}
ilLanguage::txt (   $a_topic)

gets the text for a given topic

if the topic is not in the list, the topic itself with "-" will be returned public

Parameters
stringtopic
Returns
string text clear-text

Definition at line 151 of file class.ilLanguage.php.

References $log.

{
global $log;
if (empty($a_topic))
{
return "";
}
$translation = $this->text[$a_topic];
//get position of the comment_separator
$pos = strpos($translation, $this->comment_separator);
if ($pos !== false)
{
// remove comment
$translation = substr($translation,0,$pos);
}
if ($translation == "")
{
$log->writeLanguageLog($a_topic,$this->lang_key);
return "-".$a_topic."-";
}
else
{
return $translation;
}
}
ilLanguage::txt (   $a_topic,
  $a_default_lang_fallback_mod = "" 
)

gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be returned

public

Parameters
stringtopic
Returns
string text clear-text

Definition at line 219 of file class.ilLanguage.php.

References _lookupEntry().

Referenced by txtlng().

{
if (empty($a_topic))
{
return "";
}
// remember the used topics
$this->used_topics[$a_topic] = $a_topic;
$translation = "";
if (isset($this->text[$a_topic]))
{
$translation = $this->text[$a_topic];
}
if ($translation == "" && $a_default_lang_fallback_mod != "")
{
$translation = ilLanguage::_lookupEntry($this->lang_default,
$a_default_lang_fallback_mod, $a_topic);
}
if ($translation == "")
{
if (ILIAS_LOG_ENABLED && is_object($this->log))
{
$this->log->writeLanguageLog($a_topic,$this->lang_key);
}
return "-".$a_topic."-";
}
else
{
return $translation;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLanguage::txtlng (   $a_module,
  $a_topic,
  $a_language 
)

gets the text for a given topic in a given language if the topic is not in the list, the topic itself with "-" will be returned

public

Parameters
stringtopic
string$a_languageThe language of the output string
Returns
string text clear-text

Definition at line 199 of file class.ilLanguage.php.

References _lookupEntry(), and txt().

{
if (strcmp($a_language, $this->lang_key) == 0)
{
return $this->txt($a_topic);
}
else
{
return ilLanguage::_lookupEntry($a_language, $a_module, $a_topic);
}
}

+ Here is the call graph for this function:

static ilLanguage::updateLangEntry (   $a_module,
  $a_identifier,
  $a_lang_key,
  $a_value,
  $a_local_change = null 
)
staticfinal

Update lang entry.

Definition at line 746 of file class.ilLanguage.php.

References $ilDB.

Referenced by insertLanguage().

{
global $ilDB;
$ilDB->manipulate(sprintf("UPDATE lng_data " .
"SET value = %s, local_change = %s ".
"WHERE module = %s AND identifier = %s AND lang_key = %s ",
$ilDB->quote($a_value, "text"), $ilDB->quote($a_local_change, "timestamp"),
$ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
$ilDB->quote($a_lang_key, "text")));
}

+ Here is the caller graph for this function:

Field Documentation

ilLanguage::$comment_separator = "###"

Definition at line 103 of file class.ilLanguage.php.

ilLanguage::$ilias

Definition at line 34 of file class.ilLanguage.php.

Referenced by ilLanguage().

ilLanguage::$lang_default = "en"

Definition at line 51 of file class.ilLanguage.php.

Referenced by ilLanguage().

ilLanguage::$lang_name

Definition at line 87 of file class.ilLanguage.php.

ilLanguage::$lang_path

Definition at line 71 of file class.ilLanguage.php.

Referenced by checkLanguage(), and insertLanguage().

ilLanguage::$lang_user

Definition at line 61 of file class.ilLanguage.php.

Referenced by getUserLanguage(), and loadLanguageModule().

ilLanguage::$loaded_modules

Definition at line 111 of file class.ilLanguage.php.

ilLanguage::$separator = "#:#"

Definition at line 95 of file class.ilLanguage.php.

ilLanguage::$text = array()

Definition at line 42 of file class.ilLanguage.php.


The documentation for this class was generated from the following files: