ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjLanguage Class Reference

Class ilObjLanguage. More...

+ Inheritance diagram for ilObjLanguage:
+ Collaboration diagram for ilObjLanguage:

Public Member Functions

 ilObjLanguage ($a_id=0, $a_call_by_reference=false)
 Constructor.
 getKey ()
 get language key
 getStatus ()
 get language status
 isSystemLanguage ()
 check if language is system language
 isUserLanguage ()
 check if language is system language
 isInstalled ()
 Check language object status, and return true if language is installed.
 isLocal ()
 Check language object status, and return true if a local language file is installed.
 install ($scope= '')
 install current language
 uninstall ()
 uninstall current language
 flush ($a_mode= 'all')
 remove language data from database
 getLocalChanges ($a_min_date="", $a_max_date="")
 get locally changed language entries
 _getLastLocalChange ($a_key)
 get the date of the last local change
 insert ($scope= '')
 insert language data from file into database
 resetUserLanguage ($lang_key)
 search ILIAS for users which have selected '$lang_key' as their prefered language and reset them to default language (english).
 cut_header ($content)
 remove lang-file haeder information from '$content' This function seeks for a special keyword where the language information starts.
 optimizeData ()
 optimizes the db-table langdata
 check ($scope= '')
 Validate the logical structure of a lang file.
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor public.
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not)
 read ($a_force_db=false)
 read object data from db into object
 getId ()
 get object id public
 setId ($a_id)
 set object id public
 setRefId ($a_id)
 set reference id public
 getRefId ()
 get reference id public
 getType ()
 get object type public
 setType ($a_type)
 set object type public
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions
 getTitle ()
 get object title public
 getUntranslatedTitle ()
 get untranslated object title public
 setTitle ($a_title)
 set object title
 getDescription ()
 get object description
 setDescription ($a_desc)
 set object description
 getLongDescription ()
 get object long description (stored in object_description)
 getImportId ()
 get import id
 setImportId ($a_import_id)
 set import id
 _lookupObjIdByImportId ($a_import_id)
 getOwner ()
 get object owner
 getOwnerName ()
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id
 setOwner ($a_owner)
 set object owner
 getCreateDate ()
 get create date public
 getLastUpdateDate ()
 get last update date public
 getDiskUsage ()
 Gets the disk usage of the object in bytes.
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class)
 create ()
 create
 update ()
 update object in db
 MDUpdateListener ($a_element)
 Meta data update listener.
 createMetaData ()
 create meta data entry
 updateMetaData ()
 update meta data entry
 deleteMetaData ()
 delete meta data entry
 updateOwner ()
 update owner of object in db
 _getIdForImportId ($a_import_id)
 get current object id for import id (static)
 _lookupOwner ($a_id)
 lookup object owner
 _lookupDescription ($a_id)
 lookup object description
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects.
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static)
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static)
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static)
 _isInTrash ($a_ref_id)
 checks wether object is in trash
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash
 _lookupObjectId ($a_ref_id)
 lookup object id
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!?
 setPermissions ($a_parent_ref)
 set permissions of object
 createReference ()
 creates reference for object
 countReferences ()
 count references of object
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!!
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public
 createRoleFolder ()
 creates a local role folder
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts.
 setRegisterMode ($a_bool)
 isUserRegistered ($a_user_id=0)
 requireRegistration ()
 getXMLZip ()
 getHTMLDirectory ()
 cloneObject ($a_target_id, $a_copy_id=0)
 Clone object permissions, put in tree ...
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container.
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies.
 cloneMetaData ($target_obj)
 Copy meta data.

Static Public Member Functions

static refreshAll ()
 Refresh all installed languages.
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, $a_remarks=null)
 Replace lang entry.
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 countUsers ($a_lang)
 Count number of users that use a language.
- Static Public Member Functions inherited from ilObject
static _getAllReferences ($a_id)
 get all reference ids of object
static _lookupTitle ($a_id)
 lookup object title
static _getIdsForTitle ($title, $type= '', $partialmatch=false)
static _lookupObjId ($a_id)
static _lookupType ($a_id, $a_reference=false)
 lookup object type
 _exists ($a_id, $a_reference=false)
 checks if an object exists in object_data
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type.
static _prepareCloneSelection ($a_ref_ids, $new_type)
 Prepare copy wizard object selection.
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item.
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies.
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies.

Data Fields

 $separator
 $comment_separator
 $lang_default
 $lang_user
 $lang_path
 $key
 $status
- Data Fields inherited from ilObject
const TITLE_LENGTH = 128
 max length of object title
 $ilias
 $lng
 $id
 $ref_id
 $type
 $title
 $untranslatedTitle
 $desc
 $long_desc
 $owner
 $create_date
 $last_update
 $import_id
 $register = false
 $referenced
 $objectList
 $max_title
 $max_desc
 $add_dots
 $obj_data_record
 object_data record

Detailed Description

Class ilObjLanguage.

Author
Sascha Hofmann shofm.nosp@m.ann@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
Id:
class.ilObjLanguage.php 25692 2010-09-15 09:44:16Z mwarkus

Definition at line 14 of file class.ilObjLanguage.php.

Member Function Documentation

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

Delete languge data.

Parameters
stringlang key

Definition at line 280 of file class.ilObjLanguage.php.

References $ilDB.

Referenced by flush(), and ilObjLanguageExt\importLanguageFile().

{
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:

ilObjLanguage::_getLastLocalChange (   $a_key)

get the date of the last local change

Parameters
stringlanguage key
Returns
array change_date "yyyy-mm-dd hh:mm:ss"

Definition at line 353 of file class.ilObjLanguage.php.

References $ilDB, $row, and DB_FETCHMODE_ASSOC.

Referenced by ilLanguageTableGUI\fillRow().

{
global $ilDB;
$q = sprintf("SELECT MAX(local_change) last_change FROM lng_data ".
"WHERE lang_key = %s AND local_change IS NOT NULL",
$ilDB->quote($a_key, "text"));
$result = $ilDB->query($q);
if ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
return $row['last_change'];
}
else
{
return "";
}
}

+ Here is the caller graph for this function:

ilObjLanguage::check (   $scope = '')

Validate the logical structure of a lang file.

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

Returns
string system message
Parameters
string$scopeempty (global) or "local"

Definition at line 733 of file class.ilObjLanguage.php.

References $key, $lang_path, $path, cut_header(), and ilStr\isUtf8().

Referenced by install().

{
include_once("./Services/Utilities/classes/class.ilStr.php");
if (!empty($scope))
{
if ($scope == 'global')
{
$scope = '';
}
else
{
$scopeExtension = '.' . $scope;
}
}
if ($scope == "local")
{
$path = $this->cust_lang_path;
}
$tmpPath = getcwd();
// dir check
if (!is_dir($path))
{
$this->ilias->raiseError("Directory not found: ".$path, $this->ilias->error_obj->MESSAGE);
}
chdir($path);
// compute lang-file name format
$lang_file = "ilias_" . $this->key . ".lang" . $scopeExtension;
// file check
if (!is_file($lang_file))
{
$this->ilias->raiseError("File not found: ".$lang_file,$this->ilias->error_obj->MESSAGE);
}
// header check
if (!$content = $this->cut_header(file($lang_file)))
{
$this->ilias->raiseError("Wrong Header in ".$lang_file,$this->ilias->error_obj->MESSAGE);
}
// check (counting) elements of each lang-entry
$line = 0;
foreach ($content as $key => $val)
{
$separated = explode($this->separator, trim($val));
$num = count($separated);
++$n;
if ($num != 3)
{
$line = $n + 36;
$this->ilias->raiseError("Wrong parameter count in ".$lang_file." in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);
}
if (!ilStr::isUtf8($separated[2]))
{
$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);
}
}
chdir($tmpPath);
// no error occured
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilObjLanguage::countUsers (   $a_lang)
static

Count number of users that use a language.

Definition at line 807 of file class.ilObjLanguage.php.

References $ilDB, and ilObject\$lng.

Referenced by ilLanguageTableGUI\fillRow().

{
global $ilDB, $lng;
$set = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up".
" ON ud.usr_id = up.usr_id ".
" WHERE up.value = ".$ilDB->quote($a_lang, "text").
" AND up.keyword = ".$ilDB->quote("language", "text"));
$rec = $ilDB->fetchAssoc($set);
// add users with no usr_pref set to default language
if ($a_lang == $lng->lang_default)
{
$set2 = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up".
" ON (ud.usr_id = up.usr_id AND up.keyword = ".$ilDB->quote("language", "text").")".
" WHERE up.value IS NULL ");
$rec2 = $ilDB->fetchAssoc($set2);
}
return (int) $rec["cnt"] + (int) $rec2["cnt"];
}

+ Here is the caller graph for this function:

ilObjLanguage::cut_header (   $content)

remove lang-file haeder 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$contentexpecting an ILIAS lang-file
Returns
string $content content without header info OR false if no valid header was found

Definition at line 698 of file class.ilObjLanguage.php.

References $key.

Referenced by check(), ilObjLanguageFolder\checkAllLanguages(), and insert().

{
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:

static ilObjLanguage::deleteLangEntry (   $a_module,
  $a_identifier,
  $a_lang_key 
)
staticfinal

Delete lang entry.

Definition at line 659 of file class.ilObjLanguage.php.

References $ilDB.

Referenced by ilObjLanguageExt\_deleteValues().

{
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")));
return true;
}

+ Here is the caller graph for this function:

ilObjLanguage::flush (   $a_mode = 'all')

remove language data from database

Parameters
string"all" or "keep_local"

Definition at line 300 of file class.ilObjLanguage.php.

References $ilDB, and _deleteLangData().

Referenced by install(), and uninstall().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguage::getKey ( )

get language key

Returns
string language key

Definition at line 63 of file class.ilObjLanguage.php.

References $key.

Referenced by install().

{
return $this->key;
}

+ Here is the caller graph for this function:

ilObjLanguage::getLocalChanges (   $a_min_date = "",
  $a_max_date = "" 
)

get locally changed language entries

Parameters
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 320 of file class.ilObjLanguage.php.

References $ilDB, $row, and DB_FETCHMODE_ASSOC.

Referenced by insert().

{
global $ilDB;
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($this->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:

ilObjLanguage::getStatus ( )

get language status

Returns
string language status

Definition at line 73 of file class.ilObjLanguage.php.

References $status.

Referenced by isInstalled(), and isLocal().

{
return $this->status;
}

+ Here is the caller graph for this function:

ilObjLanguage::ilObjLanguage (   $a_id = 0,
  $a_call_by_reference = false 
)

Constructor.

public

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Definition at line 40 of file class.ilObjLanguage.php.

References ilObject\$desc, ilObject\$lng, ilObject\$title, and ilObject\ilObject().

Referenced by ilObjLanguageExt\ilObjLanguageExt(), and refreshAll().

{
global $lng;
$this->type = "lng";
$this->ilObject($a_id,$a_call_by_reference);
$this->type = "lng";
$this->key = $this->title;
$this->status = $this->desc;
$this->lang_default = $lng->lang_default;
$this->lang_user = $lng->lang_user;
$this->lang_path = $lng->lang_path;
$this->cust_lang_path = $lng->cust_lang_path;
$this->separator = $lng->separator;
$this->comment_separator = $lng->comment_separator;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguage::insert (   $scope = '')

insert language data from file into database

Parameters
string$scopeempty (global) or "local"

Definition at line 378 of file class.ilObjLanguage.php.

References $ilDB, $key, $lang_path, $path, $pos, $query, $row, cut_header(), getLocalChanges(), replaceLangEntry(), and replaceLangModule().

Referenced by install().

{
global $ilDB;
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_" . $this->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)))
{
if (empty($scope))
{
// reset change date for a global file
// get all local changes for a global file
$change_date = null;
$local_changes = $this->getLocalChanges();
}
else if ($scope == 'local')
{
// set the change date to import time for a local file
// get the modification date of the local file
// get the newer local changes for a local file
$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($min_date);
}
foreach ($content as $key => $val)
{
// split the line of the language file
// [0]: module
// [1]: identifier
// [2]: value
// [3]: comment (optional)
$separated = explode($this->separator,trim($val));
$pos = strpos($separated[2], $this->comment_separator);
if ($pos !== false)
{
$separated[3] = substr($separated[2], $pos + strlen($this->comment_separator));
$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))
{
// import of a global language file
if ($local_value != "" and $local_value != $separated[2])
{
// keep an existing and different local calue
$lang_array[$separated[0]][$separated[1]] = $local_value;
}
else
{
// check for double entries in global file
if ($double_checker[$separated[0]][$separated[1]][$this->key])
{
$this->ilias->raiseError("Duplicate Language Entry: ".
$separated[0]."-".$separated[1]."-".$this->key,
$this->ilias->error_obj->MESSAGE);
}
$double_checker[$separated[0]][$separated[1]][$this->key] = true;
// insert a new value if no local value exists
// reset local change date if the values are equal
ilObjLanguage::replaceLangEntry($separated[0], $separated[1],
$this->key, $separated[2], $change_date, $separated[3]);
$lang_array[$separated[0]][$separated[1]] = $separated[2];
}
}
else if ($scope == 'local')
{
// import of a local language file
if ($local_value != "")
{
// keep a locally changed value that is newer than the file
$lang_array[$separated[0]][$separated[1]] = $local_value;
}
else
{
// insert a new value if no global value exists
// (local files may have additional entries for customizations)
// set the change date to the import date
ilObjLanguage::replaceLangEntry($separated[0], $separated[1],
$this->key, $separated[2], $change_date, $separated[3]);
$lang_array[$separated[0]][$separated[1]] = $separated[2];
}
}
}
$ld = "";
if (empty($scope))
{
$ld = "installed";
}
else if ($scope == 'local')
{
$ld = "installed_local";
}
if ($ld)
{
$query = "UPDATE object_data SET " .
"description = ".$ilDB->quote($ld, "text").", " .
"last_update = ".$ilDB->now()." " .
"WHERE title = ".$ilDB->quote($this->key, "text")." " .
"AND type = 'lng'";
$ilDB->manipulate($query);
}
}
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);
}
}
ilObjLanguage::replaceLangModule($this->key, $module, $lang_arr);
}
}
chdir($tmpPath);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguage::install (   $scope = '')

install current language

Returns
string installed language key
Parameters
string$scopeempty (global) or "local"

Definition at line 146 of file class.ilObjLanguage.php.

References check(), flush(), getKey(), insert(), isInstalled(), isLocal(), optimizeData(), ilObject\setDescription(), and ilObject\update().

{
if (!empty($scope))
{
if ($scope == 'global')
{
$scope = '';
}
else
{
$scopeExtension = '.' . $scope;
}
}
if (($this->isInstalled() == false) ||
($this->isInstalled() == true && $this->isLocal() == false && !empty($scope)))
{
if ($this->check($scope))
{
// lang-file is ok. Flush data in db and...
if (empty($scope))
{
$this->flush('keep_local');
}
// ...re-insert data from lang-file
$this->insert($scope);
// update information in db-table about available/installed languages
if (empty($scope))
{
$newDesc = 'installed';
}
else if ($scope == 'local')
{
$newDesc = 'installed_local';
}
$this->setDescription($newDesc);
$this->update();
$this->optimizeData();
return $this->getKey();
}
}
return "";
}

+ Here is the call graph for this function:

ilObjLanguage::isInstalled ( )

Check language object status, and return true if language is installed.

Returns
boolean true if installed

Definition at line 110 of file class.ilObjLanguage.php.

References getStatus().

Referenced by install(), and ilObjLanguageExt\setLocal().

{
if (substr($this->getStatus(), 0, 9) == "installed")
{
return true;
}
else
{
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguage::isLocal ( )

Check language object status, and return true if a local language file is installed.

Returns
boolean true if local language is installed

Definition at line 128 of file class.ilObjLanguage.php.

References getStatus().

Referenced by install().

{
if (substr($this->getStatus(), 10) == "local")
{
return true;
}
else
{
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguage::isSystemLanguage ( )

check if language is system language

Definition at line 81 of file class.ilObjLanguage.php.

{
if ($this->key == $this->lang_default)
return true;
else
return false;
}
ilObjLanguage::isUserLanguage ( )

check if language is system language

Definition at line 92 of file class.ilObjLanguage.php.

{
if ($this->key == $this->lang_user)
{
return true;
}
else
{
return false;
}
}
ilObjLanguage::optimizeData ( )

optimizes the db-table langdata

Returns
boolean true on success

Definition at line 716 of file class.ilObjLanguage.php.

References $ilDB.

Referenced by install().

{
global $ilDB;
$ilDB->optimizeTable("lng_data");
return true;
}

+ Here is the caller graph for this function:

static ilObjLanguage::refreshAll ( )
static

Refresh all installed languages.

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

References $lang, ilObject\_getObjectsByType(), ilPluginSlot\getAllSlots(), ilPlugin\getPluginObject(), and ilObjLanguage().

Referenced by ilObjLanguageFolderGUI\refreshObject().

{
global $ilPluginAdmin;
$languages = ilObject::_getObjectsByType("lng");
foreach ($languages as $lang)
{
$langObj = new ilObjLanguage($lang["obj_id"],false);
if ($langObj->isInstalled() == true)
{
if ($langObj->check())
{
$langObj->flush('keep_local');
$langObj->insert();
$langObj->setTitle($langObj->getKey());
$langObj->setDescription($langObj->getStatus());
$langObj->update();
$langObj->optimizeData();
if ($langObj->isLocal() == true)
{
if ($langObj->check('local'))
{
$langObj->insert('local');
$langObj->setTitle($langObj->getKey());
$langObj->setDescription($langObj->getStatus());
$langObj->update();
$langObj->optimizeData();
}
}
}
}
unset($langObj);
}
// refresh languages of activated plugins
include_once("./Services/Component/classes/class.ilPluginSlot.php");
foreach ($slots as $slot)
{
$act_plugins = $ilPluginAdmin->getActivePluginsForSlot($slot["component_type"],
$slot["component_name"], $slot["slot_id"]);
foreach ($act_plugins as $plugin)
{
include_once("./Services/Component/classes/class.ilPlugin.php");
$pl = ilPlugin::getPluginObject($slot["component_type"],
$slot["component_name"], $slot["slot_id"], $plugin);
if (is_object($pl))
{
$pl->updateLanguages();
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Replace lang entry.

Definition at line 565 of file class.ilObjLanguage.php.

References $ilDB.

Referenced by ilObjLanguageExt\_saveValues(), insert(), and ilPlugin\updateLanguages().

{
global $ilDB;
if (isset($a_remarks))
{
$a_remarks = substr($a_remarks, 0, 250);
}
if ($a_remarks == '')
{
unset($a_remarks);
}
if (isset($a_value))
{
$a_value = substr($a_value, 0, 4000);
}
if ($a_value == '')
{
unset($a_value);
}
$ilDB->replace(
'lng_data',
array(
'module' => array('text',$a_module),
'identifier' => array('text',$a_identifier),
'lang_key' => array('text',$a_lang_key)
),
array(
'value' => array('text',$a_value),
'local_change' => array('timestamp',$a_local_change),
'remarks' => array('text', $a_remarks)
)
);
return true;
/*
$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")));
$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 ilObjLanguage::replaceLangModule (   $a_key,
  $a_module,
  $a_array 
)
staticfinal

Replace language module array.

Definition at line 544 of file class.ilObjLanguage.php.

References $ilDB.

Referenced by ilObjLanguageExt\_deleteValues(), ilObjLanguageExt\_saveValues(), insert(), and ilPlugin\updateLanguages().

{
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:

ilObjLanguage::resetUserLanguage (   $lang_key)

search ILIAS for users which have selected '$lang_key' as their prefered language and reset them to default language (english).

A message is sent to all affected users

Parameters
string$lang_keyinternational language key (2 digits)

Definition at line 679 of file class.ilObjLanguage.php.

References $ilDB, and $query.

Referenced by uninstall().

{
global $ilDB;
$query = "UPDATE usr_pref SET " .
"value = ".$ilDB->quote($this->lang_default, "text")." " .
"WHERE keyword = ".$ilDB->quote('language', "text")." ".
"AND value = ".$ilDB->quote($lang_key, "text");
$ilDB->manipulate($query);
}

+ Here is the caller graph for this function:

ilObjLanguage::uninstall ( )

uninstall current language

Returns
string uninstalled language key

Definition at line 198 of file class.ilObjLanguage.php.

References $key, flush(), resetUserLanguage(), ilObject\setDescription(), ilObject\setTitle(), and ilObject\update().

{
if ((substr($this->status, 0, 9) == "installed") && ($this->key != $this->lang_default) && ($this->key != $this->lang_user))
{
$this->flush('all');
$this->setTitle($this->key);
$this->setDescription("not_installed");
$this->update();
$this->resetUserLanguage($this->key);
return $this->key;
}
return "";
}

+ Here is the call graph for this function:

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

Replace lang entry.

Definition at line 623 of file class.ilObjLanguage.php.

References $ilDB.

{
global $ilDB;
if (isset($a_remarks))
{
$a_remarks = substr($a_remarks, 0, 250);
}
if ($a_remarks == '')
{
unset($a_remarks);
}
if (isset($a_value))
{
$a_value = substr($a_value, 0, 4000);
}
if ($a_value == '')
{
unset($a_value);
}
$ilDB->manipulate(sprintf("UPDATE lng_data " .
"SET value = %s, local_change = %s, remarks = %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_remarks, "text"),
$ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
$ilDB->quote($a_lang_key, "text")));
}

Field Documentation

ilObjLanguage::$comment_separator

Definition at line 24 of file class.ilObjLanguage.php.

ilObjLanguage::$lang_default

Definition at line 25 of file class.ilObjLanguage.php.

ilObjLanguage::$lang_path

Definition at line 27 of file class.ilObjLanguage.php.

Referenced by check(), ilObjLanguageExt\getLangPath(), and insert().

ilObjLanguage::$lang_user

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

ilObjLanguage::$separator

Definition at line 23 of file class.ilObjLanguage.php.

ilObjLanguage::$status

Definition at line 30 of file class.ilObjLanguage.php.

Referenced by getStatus().


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