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

Class ilObjLanguageExt. More...

+ Inheritance diagram for ilObjLanguageExt:
+ Collaboration diagram for ilObjLanguageExt:

Public Member Functions

 ilObjLanguageExt ($a_id=0, $a_call_by_reference=false)
 Constructor.
 getGlobalLanguageFile ()
 Read and get the global language file as an object.
 setLocal ($a_local=true)
 Set the local status of the language.
 getLongDescription ()
 Get the full language description.
 getLangPath ()
 Get the language files path.
 getCustLangPath ()
 Get the customized language files path.
 getAllRemarks ()
 Get all remarks from the database.
 getAllValues ($a_modules=array(), $a_pattern= '')
 Get all values from the database.
 getChangedValues ($a_modules=array(), $a_pattern= '')
 Get only the changed values from the database which differ from the original language file.
 getUnchangedValues ($a_modules=array(), $a_pattern= '')
 Get only the unchanged values from the database which are equal to the original language file.
 getAddedValues ($a_modules=array(), $a_pattern= '')
 Get only the entries which don't exist in the global language file.
 getCommentedValues ($a_modules=array(), $a_pattern= '')
 Get all values from the database for wich the global language file has a comment.
 getMergedValues ()
 Get the local values merged into the values of the global language file.
 getMergedRemarks ()
 Get the local remarks merged into the remarks of the global language file.
 importLanguageFile ($a_file, $a_mode_existing= 'keepnew')
 Import a language file into the ilias database.
- Public Member Functions inherited from ilObjLanguage
 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
 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 _getModules ($a_lang_key)
 Get all modules of a language.
static _getRemarks ($a_lang_key, $a_all_changed=false)
 Get all remarks of a language.
static _getValues ($a_lang_key, $a_modules=array(), $a_topics=array(), $a_pattern= '', $a_state= '')
 Get the translations of specified topics.
static _saveValues ($a_lang_key, $a_values=array(), $a_remarks=array())
 Save a set of translation in the database.
static _deleteValues ($a_lang_key, $a_values=array())
 Delete a set of translation in the database.
- Static Public Member Functions inherited from ilObjLanguage
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.

Additional Inherited Members

- Data Fields inherited from ilObjLanguage
 $separator
 $comment_separator
 $lang_default
 $lang_user
 $lang_path
 $key
 $status

Detailed Description

Member Function Documentation

static ilObjLanguageExt::_deleteValues (   $a_lang_key,
  $a_values = array() 
)
static

Delete a set of translation in the database.

static

Parameters
stringlanguage key
arraymodule.separator.topic => value

Definition at line 468 of file class.ilObjLanguageExt.php.

References $ilDB, ilObjLanguage\$key, ilObject\$lng, $row, ilObjLanguage\deleteLangEntry(), and ilObjLanguage\replaceLangModule().

Referenced by ilObjLanguageExtGUI\maintainObject().

{
global $ilDB, $lng;
if (!is_array($a_values))
{
return;
}
$delete_array = array();
// save the single translations in lng_data
foreach ($a_values as $key => $value)
{
$keys = explode($lng->separator, $key);
if (count($keys) == 2)
{
$module = $keys[0];
$topic = $keys[1];
$delete_array[$module][$topic] = $value;
ilObjLanguage::deleteLangEntry($module, $topic, $a_lang_key);
}
}
// save the serialized module entries in lng_modules
foreach ($delete_array as $module => $entries)
{
$set = $ilDB->query(sprintf("SELECT * FROM lng_modules " .
"WHERE lang_key = %s AND module = %s",
$ilDB->quote($a_lang_key, "text"), $ilDB->quote($module, "text")));
$row = $ilDB->fetchAssoc($set);
$arr = unserialize($row["lang_array"]);
if (is_array($arr))
{
$entries = array_diff_key($arr, $entries);
}
ilObjLanguage::replaceLangModule($a_lang_key, $module, $entries);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilObjLanguageExt::_getModules (   $a_lang_key)
static

Get all modules of a language.

static

Parameters
stringlanguage key
Returns
array list of modules

Definition at line 286 of file class.ilObjLanguageExt.php.

References $ilDB, and DB_FETCHMODE_ASSOC.

Referenced by ilObjLanguageExtGUI\statisticsObject(), and ilObjLanguageExtGUI\viewObject().

{
global $ilDB;
$q = "SELECT DISTINCT module FROM lng_data WHERE ".
" lang_key = ".$ilDB->quote($a_lang_key, "text")." order by module";
$set = $ilDB->query($q);
while ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
{
$modules[] = $rec["module"];
}
return $modules;
}

+ Here is the caller graph for this function:

static ilObjLanguageExt::_getRemarks (   $a_lang_key,
  $a_all_changed = false 
)
static

Get all remarks of a language.

static

Parameters
stringlanguage key
booleaninclude empty remarks for local changes
Returns
array module.separator.topic => remarks

Definition at line 310 of file class.ilObjLanguageExt.php.

References $ilDB, ilObject\$lng, and $row.

Referenced by getAllRemarks(), getMergedRemarks(), and ilObjLanguageExtGUI\viewObject().

{
global $ilDB, $lng;
$q = "SELECT module, identifier, remarks"
. " FROM lng_data"
. " WHERE lang_key = ".$ilDB->quote($a_lang_key, "text");
if ($a_all_changed)
{
$q .= " AND (remarks IS NOT NULL OR local_change IS NOT NULL)";
}
else
{
$q .= " AND remarks IS NOT NULL";
}
$result = $ilDB->query($q);
$remarks = array();
while ($row = $ilDB->fetchAssoc($result))
{
$remarks[$row["module"].$lng->separator.$row["identifier"]] = $row["remarks"];
}
return $remarks;
}

+ Here is the caller graph for this function:

static ilObjLanguageExt::_getValues (   $a_lang_key,
  $a_modules = array(),
  $a_topics = array(),
  $a_pattern = '',
  $a_state = '' 
)
static

Get the translations of specified topics.

static

Parameters
stringlanguage key
arraylist of modules
arraylist of topics
arraysearch pattern
stringlocal change state ('changed', 'unchanged', '')
Returns
array module.separator.topic => value

Definition at line 349 of file class.ilObjLanguageExt.php.

References $ilDB, ilObject\$lng, and DB_FETCHMODE_ASSOC.

Referenced by getAddedValues(), getAllValues(), getChangedValues(), getCommentedValues(), getMergedValues(), getUnchangedValues(), and ilObjLanguageExtGUI\viewObject().

{
global $ilDB, $lng;
$q = "SELECT * FROM lng_data WHERE".
" lang_key = ".$ilDB->quote($a_lang_key, "text")." ";
if (is_array($a_modules) && count($a_modules) > 0)
{
$q .= " AND ".$ilDB->in("module", $a_modules, false, "text");
}
if (is_array($a_topics) && count($a_topics) > 0)
{
$q .= " AND ".$ilDB->in("identifier", $a_topics, false, "text");
}
if ($a_pattern)
{
$q .= " AND ".$ilDB->like("value", "text", "%".$a_pattern."%");
}
if ($a_state == "changed")
{
$q .= " AND NOT local_change IS NULL ";
}
if ($a_state == "unchanged")
{
$q .= " AND local_change IS NULL ";
}
$q .= " ORDER BY module, identifier";
$set = $ilDB->query($q);
$values = array();
while ($rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
{
$values[$rec["module"].$lng->separator.$rec["identifier"]] = $rec["value"];
}
return $values;
}

+ Here is the caller graph for this function:

static ilObjLanguageExt::_saveValues (   $a_lang_key,
  $a_values = array(),
  $a_remarks = array() 
)
static

Save a set of translation in the database.

static

Parameters
stringlanguage key
arraymodule.separator.topic => value
arraymodule.separator.topic => remarks

Definition at line 401 of file class.ilObjLanguageExt.php.

References $ilDB, ilObjLanguage\$key, ilObject\$lng, $row, ilLanguageFile\_getGlobalLanguageFile(), ilObjLanguage\replaceLangEntry(), and ilObjLanguage\replaceLangModule().

Referenced by importLanguageFile(), and ilObjLanguageExtGUI\saveObject().

{
global $ilDB, $lng;
if (!is_array($a_values))
{
return;
}
$save_array = array();
$save_date = date("Y-m-d H:i:s", time());
// read and get the global values
require_once "./Services/Language/classes/class.ilLanguageFile.php";
$global_file_obj = ilLanguageFile::_getGlobalLanguageFile($a_lang_key);
$global_values = $global_file_obj->getAllValues();
$global_comments = $global_file_obj->getAllComments();
// save the single translations in lng_data
foreach ($a_values as $key => $value)
{
$keys = explode($lng->separator, $key);
if (count($keys) == 2)
{
$module = $keys[0];
$topic = $keys[1];
$save_array[$module][$topic] = $value;
if ($global_values[$key] != $value
or $global_comments[$key] != $a_remarks[$key])
{
$local_change = $save_date;
}
else
{
$local_change = null;
}
$a_lang_key, $value, $local_change, $a_remarks[$key]);
}
}
// save the serialized module entries in lng_modules
foreach ($save_array as $module => $entries)
{
$set = $ilDB->query(sprintf("SELECT * FROM lng_modules " .
"WHERE lang_key = %s AND module = %s",
$ilDB->quote($a_lang_key, "text"), $ilDB->quote($module, "text")));
$row = $ilDB->fetchAssoc($set);
$arr = unserialize($row["lang_array"]);
if (is_array($arr))
{
$entries = array_merge($arr, $entries);
}
ilObjLanguage::replaceLangModule($a_lang_key, $module, $entries);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguageExt::getAddedValues (   $a_modules = array(),
  $a_pattern = '' 
)

Get only the entries which don't exist in the global language file.

Parameters
arraylist of modules
arraysearch pattern
Returns
array module.separator.topic => value

Definition at line 144 of file class.ilObjLanguageExt.php.

References _getValues(), and getGlobalLanguageFile().

{
$global_file_obj = $this->getGlobalLanguageFile();
$global_values = $global_file_obj->getAllValues();
$local_values = self::_getValues($this->key, $a_modules, NULL, $a_pattern);
return array_diff_key($local_values, $global_values);
}

+ Here is the call graph for this function:

ilObjLanguageExt::getAllRemarks ( )

Get all remarks from the database.

Returns
array module.separator.topic => remark

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

References _getRemarks().

{
return self::_getRemarks($this->key);
}

+ Here is the call graph for this function:

ilObjLanguageExt::getAllValues (   $a_modules = array(),
  $a_pattern = '' 
)

Get all values from the database.

Parameters
arraylist of modules
stringsearch pattern
Returns
array module.separator.topic => value

Definition at line 104 of file class.ilObjLanguageExt.php.

References _getValues().

Referenced by importLanguageFile().

{
return self::_getValues($this->key, $a_modules, NULL, $a_pattern);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguageExt::getChangedValues (   $a_modules = array(),
  $a_pattern = '' 
)

Get only the changed values from the database which differ from the original language file.

Parameters
arraylist of modules
stringsearch pattern
Returns
array module.separator.topic => value

Definition at line 118 of file class.ilObjLanguageExt.php.

References _getValues().

Referenced by importLanguageFile().

{
return self::_getValues($this->key, $a_modules, NULL, $a_pattern, 'changed');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguageExt::getCommentedValues (   $a_modules = array(),
  $a_pattern = '' 
)

Get all values from the database for wich the global language file has a comment.

Note: This function checks the comments in the globel lang file, not the remarks in the database!

Parameters
arraylist of modules
arraysearch pattern
Returns
array module.separator.topic => value

Definition at line 164 of file class.ilObjLanguageExt.php.

References _getValues(), and getGlobalLanguageFile().

{
$global_file_obj = $this->getGlobalLanguageFile();
$global_comments = $global_file_obj->getAllComments();
$local_values = self::_getValues($this->key, $a_modules, NULL, $a_pattern);
return array_intersect_key($local_values, $global_comments);
}

+ Here is the call graph for this function:

ilObjLanguageExt::getCustLangPath ( )

Get the customized language files path.

Returns
string path of customized language files folder

Definition at line 82 of file class.ilObjLanguageExt.php.

{
return $this->cust_lang_path;
}
ilObjLanguageExt::getGlobalLanguageFile ( )

Read and get the global language file as an object.

Returns
object global language file

Definition at line 29 of file class.ilObjLanguageExt.php.

References ilLanguageFile\_getGlobalLanguageFile().

Referenced by getAddedValues(), getCommentedValues(), getMergedRemarks(), and getMergedValues().

{
require_once "./Services/Language/classes/class.ilLanguageFile.php";
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguageExt::getLangPath ( )

Get the language files path.

Returns
string path of language files folder

Definition at line 72 of file class.ilObjLanguageExt.php.

References ilObjLanguage\$lang_path.

{
}
ilObjLanguageExt::getLongDescription ( )

Get the full language description.

Returns
string description

Reimplemented from ilObject.

Definition at line 62 of file class.ilObjLanguageExt.php.

{
return $this->lng->txt($this->desc);
}
ilObjLanguageExt::getMergedRemarks ( )

Get the local remarks merged into the remarks of the global language file.

The returned array contains:

  1. all remarks that exist globally, with their local values, ordered like in the global language file
  2. all additional local remarks, ordered by module and identifier
Returns
array module.separator.topic => value

Definition at line 206 of file class.ilObjLanguageExt.php.

References _getRemarks(), and getGlobalLanguageFile().

{
$global_file_obj = $this->getGlobalLanguageFile();
$global_comments = $global_file_obj->getAllComments();
// get remarks including empty remarks for local changes
$local_remarks = self::_getRemarks($this->key, true);
return array_merge($global_comments, $local_remarks);
}

+ Here is the call graph for this function:

ilObjLanguageExt::getMergedValues ( )

Get the local values merged into the values of the global language file.

The returned array contains:

  1. all entries that exist globally, with their local values, ordered like in the global language file
  2. all additional local entries, ordered by module and identifier
Returns
array module.separator.topic => value

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

References _getValues(), and getGlobalLanguageFile().

{
$global_file_obj = $this->getGlobalLanguageFile();
$global_values = $global_file_obj->getAllValues();
$local_values = self::_getValues($this->key);
return array_merge($global_values, $local_values);
}

+ Here is the call graph for this function:

ilObjLanguageExt::getUnchangedValues (   $a_modules = array(),
  $a_pattern = '' 
)

Get only the unchanged values from the database which are equal to the original language file.

Parameters
arraylist of modules
arraysearch pattern
Returns
array module.separator.topic => value

Definition at line 132 of file class.ilObjLanguageExt.php.

References _getValues().

{
return self::_getValues($this->key, $a_modules, NULL, $a_pattern, 'unchanged');
}

+ Here is the call graph for this function:

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

Constructor.

Definition at line 20 of file class.ilObjLanguageExt.php.

References ilObjLanguage\ilObjLanguage().

{
$this->ilObjLanguage($a_id, $a_call_by_reference);
}

+ Here is the call graph for this function:

ilObjLanguageExt::importLanguageFile (   $a_file,
  $a_mode_existing = 'keepnew' 
)

Import a language file into the ilias database.

Parameters
stringhandling of existing values ('keepall','keepnew','replace','delete')

Definition at line 226 of file class.ilObjLanguageExt.php.

References $ilDB, $ilErr, ilObjLanguage\$key, ilObjLanguage\_deleteLangData(), _saveValues(), getAllValues(), and getChangedValues().

{
global $ilDB, $ilErr;
// read the new language file
require_once "./Services/Language/classes/class.ilLanguageFile.php";
$import_file_obj = new ilLanguageFile($a_file);
if (!$import_file_obj->read())
{
$ilErr->raiseError($import_file_obj->getErrorMessage(),$ilErr->MESSAGE);
}
switch($a_mode_existing)
{
// keep all existing entries
case 'keepall':
$to_keep = $this->getAllValues();
break;
// keep existing online changes
case 'keepnew':
$to_keep = $this->getChangedValues();
break;
// replace all existing definitions
case 'replace':
$to_keep = array();
break;
// delete all existing entries
case 'delete':
ilObjLanguage::_deleteLangData($this->key, false);
$ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = ".
$ilDB->quote($this->key, "text"));
$to_keep = array();
break;
default:
return;
}
// process the values of the import file
$to_save = array();
foreach ($import_file_obj->getAllValues() as $key => $value)
{
if (!isset($to_keep[$key]))
{
$to_save[$key] = $value;
}
}
self::_saveValues($this->key, $to_save, $import_file_obj->getAllComments());
}

+ Here is the call graph for this function:

ilObjLanguageExt::setLocal (   $a_local = true)

Set the local status of the language.

Parameters
booleanlocal status (true/false)

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

References ilObjLanguage\isInstalled(), ilObject\setDescription(), and ilObject\update().

{
if ($this->isInstalled())
{
if ($a_local == true)
{
$this->setDescription("installed_local");
}
else
{
$this->setDescription("installed");
}
$this->update();
}
}

+ Here is the call graph for this function:


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