ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilObjLanguage Class Reference

Class ilObjLanguage. More...

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

Public Member Functions

 __construct ($a_id=0, $a_call_by_reference=false)
 Constructor. More...
 
 getKey ()
 get language key More...
 
 getStatus ()
 get language status More...
 
 isSystemLanguage ()
 check if language is system language More...
 
 isUserLanguage ()
 check if language is system language More...
 
 isInstalled ()
 Check language object status, and return true if language is installed. More...
 
 isLocal ()
 Check language object status, and return true if a local language file is installed. More...
 
 install ($scope='')
 install current language More...
 
 uninstall ()
 uninstall current language More...
 
 refresh ()
 refresh current language More...
 
 flush ($a_mode='all')
 remove language data from database More...
 
 getLocalChanges ($a_min_date="", $a_max_date="")
 get locally changed language entries More...
 
 insert ($scope='')
 insert language data from file into database More...
 
 resetUserLanguage ($lang_key)
 search ILIAS for users which have selected '$lang_key' as their prefered language and reset them to default language (english). More...
 
 optimizeData ()
 optimizes the db-table langdata More...
 
 check ($scope='')
 Validate the logical structure of a lang file. More...
 
- Public Member Functions inherited from ilObject
 __construct ($a_id=0, $a_reference=true)
 Constructor @access public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ()
 read object data from db into object More...
 
 getId ()
 get object id @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 setOfflineStatus ($a_status)
 Set offline status. More...
 
 getOfflineStatus ()
 Get offline status. More...
 
 supportsOfflineHandling ()
 Check whether object supports offline handling. More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 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) @access public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static getInstalledLanguages ()
 Get the language objects of the installed languages. More...
 
static refreshAll ()
 Refresh all installed languages. More...
 
static refreshPlugins ($a_lang_keys=null)
 
static _deleteLangData ($a_lang_key, $a_keep_local_change=false)
 Delete languge data. More...
 
static _getLastLocalChange ($a_key)
 get the date of the last local change More...
 
static _getLocalChangesByModule ($a_key, $a_module)
 Get the local changes of a language module. More...
 
static replaceLangEntry ( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
 Replace lang entry. More...
 
static updateLangEntry ( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
 Replace lang entry. More...
 
static deleteLangEntry ($a_module, $a_identifier, $a_lang_key)
 Delete lang entry. More...
 
static cut_header ($content)
 remove lang-file haeder information from '$content' This function seeks for a special keyword where the language information starts. More...
 
static countUsers ($a_lang)
 Count number of users that use a language. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
 
static _lookupImportId ($a_obj_id)
 
static _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
static _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
static _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static lookupOfflineStatus ($a_obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner ($a_id)
 lookup object owner More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
static _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
static _lookupObjId ($a_id)
 
static _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
static setDeletedDates ($a_ref_ids)
 Set deleted date. More...
 
static _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
static _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
static _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
static _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
static _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id More...
 
static _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type More...
 
static _exists ($a_id, $a_reference=false, $a_type=null)
 checks if an object exists in object_data@access public More...
 
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type. More...
 
static _prepareCloneSelection ($a_ref_ids, $new_type, $show_path=true)
 Prepare copy wizard object selection. More...
 
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $a_obj_ids)
 Get long description data. More...
 
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns. More...
 
static fixMissingTitles ($a_type, array &$a_obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate ($a_id)
 Lookup creation date. More...
 
static hasAutoRating ($a_type, $a_ref_id)
 Check if auto rating is active for parent group/course. More...
 

Data Fields

 $separator
 
 $comment_separator
 
 $lang_default
 
 $lang_user
 
 $lang_path
 
 $key
 
 $status
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $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
 

Additional Inherited Members

- Protected Attributes inherited from ilObject
 $objDefinition
 
 $db
 
 $log
 
 $error
 
 $tree
 
 $app_event_handler
 
 $rbacadmin
 
 $rbacreview
 

Detailed Description

Class ilObjLanguage.

Author
Sascha Hofmann shofm.nosp@m.ann@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

@access public

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

Reimplemented from ilObject.

Reimplemented in ilObjLanguageExt.

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

41 {
42 global $DIC;
43 $lng = $DIC->language();
44
45 $this->type = "lng";
46 parent::__construct($a_id, $a_call_by_reference);
47
48 $this->type = "lng";
49 $this->key = $this->title;
50 $this->status = $this->desc;
51 $this->lang_default = $lng->lang_default;
52 $this->lang_user = $lng->lang_user;
53 $this->lang_path = $lng->lang_path;
54 $this->cust_lang_path = $lng->cust_lang_path;
55 $this->separator = $lng->separator;
56 $this->comment_separator = $lng->comment_separator;
57 }
global $DIC
Definition: saml.php:7

References ilObject\$desc, $DIC, ilObject\$lng, and ilObject\$title.

Member Function Documentation

◆ _deleteLangData()

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

Delete languge data.

Parameters
stringlang key

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

304 {
305 global $DIC;
306 $ilDB = $DIC->database();
307
308 if (!$a_keep_local_change) {
309 $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
310 $ilDB->quote($a_lang_key, "text"));
311 } else {
312 $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
313 $ilDB->quote($a_lang_key, "text") .
314 " AND local_change IS NULL");
315 }
316 }
global $ilDB

References $DIC, and $ilDB.

Referenced by flush().

+ Here is the caller graph for this function:

◆ _getLastLocalChange()

static ilObjLanguage::_getLastLocalChange (   $a_key)
static

get the date of the last local change

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

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

377 {
378 global $DIC;
379 $ilDB = $DIC->database();
380
381 $q = sprintf(
382 "SELECT MAX(local_change) last_change FROM lng_data " .
383 "WHERE lang_key = %s AND local_change IS NOT NULL",
384 $ilDB->quote($a_key, "text")
385 );
386 $result = $ilDB->query($q);
387
389 return $row['last_change'];
390 } else {
391 return "";
392 }
393 }
$result
$row

References $DIC, $ilDB, $result, $row, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilObjLanguageFolderGUI\confirmRefreshSelectedObject(), and ilLanguageTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ _getLocalChangesByModule()

static ilObjLanguage::_getLocalChangesByModule (   $a_key,
  $a_module 
)
static

Get the local changes of a language module.

Parameters
string$a_keyLanguage key
string$a_moduleModule key
Returns
array identifier => value

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

403 {
404 global $DIC;
405 $ilDB = $DIC->database();
406
407 $changes = array();
408 $result = $ilDB->queryF(
409 "SELECT * FROM lng_data WHERE lang_key = %s AND module = %s AND local_change IS NOT NULL",
410 array('text', 'text'),
411 array($a_key, $a_module)
412 );
413
414 while ($row = $ilDB->fetchAssoc($result)) {
415 $changes[$row['identifier']] = $row['value'];
416 }
417 return $changes;
418 }

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

Referenced by ilPlugin\updateLanguages().

+ Here is the caller graph for this function:

◆ check()

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

800 {
801 include_once("./Services/Utilities/classes/class.ilStr.php");
802
803 if (!empty($scope)) {
804 if ($scope == 'global') {
805 $scope = '';
806 } else {
807 $scopeExtension = '.' . $scope;
808 }
809 }
810
812 if ($scope == "local") {
813 $path = $this->cust_lang_path;
814 }
815
816 $tmpPath = getcwd();
817
818 // dir check
819 if (!is_dir($path)) {
820 $this->ilias->raiseError("Directory not found: " . $path, $this->ilias->error_obj->MESSAGE);
821 }
822
823 chdir($path);
824
825 // compute lang-file name format
826 $lang_file = "ilias_" . $this->key . ".lang" . $scopeExtension;
827
828 // file check
829 if (!is_file($lang_file)) {
830 $this->ilias->raiseError("File not found: " . $lang_file, $this->ilias->error_obj->MESSAGE);
831 }
832
833 // header check
834 $content = $this->cut_header(file($lang_file));
835 if ($content === false) {
836 $this->ilias->raiseError("Wrong Header in " . $lang_file, $this->ilias->error_obj->MESSAGE);
837 }
838
839 // check (counting) elements of each lang-entry
840 $line = 0;
841 foreach ($content as $key => $val) {
842 $separated = explode($this->separator, trim($val));
843 $num = count($separated);
844 ++$n;
845 if ($num != 3) {
846 $line = $n + 36;
847 $this->ilias->raiseError("Wrong parameter count in " . $lang_file . " in line $line (Value: $val)! Please check your language file!", $this->ilias->error_obj->MESSAGE);
848 }
849 if (!ilStr::isUtf8($separated[2])) {
850 $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);
851 }
852 }
853
854 chdir($tmpPath);
855
856 // no error occured
857 return true;
858 }
$n
Definition: RandomTest.php:85
$path
Definition: aliased.php:25
static cut_header($content)
remove lang-file haeder information from '$content' This function seeks for a special keyword where t...
static isUtf8($a_str)
Check whether string is utf-8.
redirection script todo: (a better solution should control the processing via a xml file)

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

Referenced by install(), and refresh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countUsers()

static ilObjLanguage::countUsers (   $a_lang)
static

Count number of users that use a language.

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

864 {
865 global $DIC;
866 $ilDB = $DIC->database();
867 $lng = $DIC->language();
868
869 $set = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up" .
870 " ON ud.usr_id = up.usr_id " .
871 " WHERE up.value = " . $ilDB->quote($a_lang, "text") .
872 " AND up.keyword = " . $ilDB->quote("language", "text"));
873 $rec = $ilDB->fetchAssoc($set);
874
875 // add users with no usr_pref set to default language
876 if ($a_lang == $lng->lang_default) {
877 $set2 = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up" .
878 " ON (ud.usr_id = up.usr_id AND up.keyword = " . $ilDB->quote("language", "text") . ")" .
879 " WHERE up.value IS NULL ");
880 $rec2 = $ilDB->fetchAssoc($set2);
881 }
882
883 return (int) $rec["cnt"] + (int) $rec2["cnt"];
884 }

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

Referenced by ilLanguageTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ cut_header()

static ilObjLanguage::cut_header (   $content)
static

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

768 {
769 foreach ($content as $key => $val) {
770 if (trim($val) == "<!-- language file start -->") {
771 return array_slice($content, $key + 1);
772 }
773 }
774
775 return false;
776 }

References $key.

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

+ Here is the caller graph for this function:

◆ deleteLangEntry()

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

Delete lang entry.

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

725 {
726 global $DIC;
727 $ilDB = $DIC->database();
728
729 $ilDB->manipulate(sprintf(
730 "DELETE FROM lng_data " .
731 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
732 $ilDB->quote($a_module, "text"),
733 $ilDB->quote($a_identifier, "text"),
734 $ilDB->quote($a_lang_key, "text")
735 ));
736
737 return true;
738 }

References $DIC, and $ilDB.

Referenced by ilObjLanguageExt\_deleteValues().

+ Here is the caller graph for this function:

◆ flush()

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

remove language data from database

Parameters
string"all" or "keep_local"

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

323 {
324 global $DIC;
325 $ilDB = $DIC->database();
326
327 ilObjLanguage::_deleteLangData($this->key, ($a_mode == 'keep_local'));
328
329 if ($a_mode == 'all') {
330 $ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = " .
331 $ilDB->quote($this->key, "text"));
332 }
333 }
static _deleteLangData($a_lang_key, $a_keep_local_change=false)
Delete languge data.

References $DIC, $ilDB, and _deleteLangData().

Referenced by install(), refresh(), and uninstall().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstalledLanguages()

static ilObjLanguage::getInstalledLanguages ( )
static

Get the language objects of the installed languages.

Returns
self[]

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

65 {
66 $objects = array();
68 foreach ($languages as $lang) {
69 $langObj = new ilObjLanguage($lang["obj_id"], false);
70 if ($langObj->isInstalled()) {
71 $objects[] = $langObj;
72 } else {
73 unset($langObj);
74 }
75 }
76 return $objects;
77 }
Class ilObjLanguage.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
$languages
Definition: cssgen2.php:34
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349

References $lang, $languages, and ilObject\_getObjectsByType().

Referenced by ilPlugin\updateLanguages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getKey()

ilObjLanguage::getKey ( )

get language key

Returns
string language key

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

86 {
87 return $this->key;
88 }

References $key.

Referenced by install(), and refresh().

+ Here is the caller graph for this function:

◆ getLocalChanges()

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

343 {
344 global $DIC;
345 $ilDB = $DIC->database();
346
347 if ($a_min_date == "") {
348 $a_min_date = "1980-01-01 00:00:00";
349 }
350 if ($a_max_date == "") {
351 $a_max_date = "2200-01-01 00:00:00";
352 }
353
354 $q = sprintf(
355 "SELECT * FROM lng_data WHERE lang_key = %s " .
356 "AND local_change >= %s AND local_change <= %s",
357 $ilDB->quote($this->key, "text"),
358 $ilDB->quote($a_min_date, "timestamp"),
359 $ilDB->quote($a_max_date, "timestamp")
360 );
361 $result = $ilDB->query($q);
362
363 $changes = array();
364 while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
365 $changes[$row["module"]][$row["identifier"]] = $row["value"];
366 }
367 return $changes;
368 }

References $DIC, $ilDB, $result, $row, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by insert().

+ Here is the caller graph for this function:

◆ getStatus()

ilObjLanguage::getStatus ( )

get language status

Returns
string language status

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

96 {
97 return $this->status;
98 }

References $status.

Referenced by isInstalled(), isLocal(), and refresh().

+ Here is the caller graph for this function:

◆ insert()

ilObjLanguage::insert (   $scope = '')

insert language data from file into database

Parameters
string$scopeempty (global) or "local"

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

427 {
428 global $DIC;
429 $ilDB = $DIC->database();
430
431 if (!empty($scope)) {
432 if ($scope == 'global') {
433 $scope = '';
434 } else {
435 $scopeExtension = '.' . $scope;
436 }
437 }
438
440 if ($scope == "local") {
441 $path = $this->cust_lang_path;
442 }
443
444 $lang_file = $path . "/ilias_" . $this->key . ".lang" . $scopeExtension;
445
446 if (is_file($lang_file)) {
447 // initialize the array for updating lng_modules below
448 $lang_array = array();
449 $lang_array["common"] = array();
450
451 // remove header first
452 if ($content = $this->cut_header(file($lang_file))) {
453 if (empty($scope)) {
454 // reset change date for a global file
455 // get all local changes for a global file
456 $change_date = null;
457 $local_changes = $this->getLocalChanges();
458 } elseif ($scope == 'local') {
459 // set the change date to import time for a local file
460 // get the modification date of the local file
461 // get the newer local changes for a local file
462 $change_date = date("Y-m-d H:i:s", time());
463 $min_date = date("Y-m-d H:i:s", filemtime($lang_file));
464 $local_changes = $this->getLocalChanges($min_date);
465 }
466
467 foreach ($content as $key => $val) {
468 // split the line of the language file
469 // [0]: module
470 // [1]: identifier
471 // [2]: value
472 // [3]: comment (optional)
473 $separated = explode($this->separator, trim($val));
474 $pos = strpos($separated[2], $this->comment_separator);
475 if ($pos !== false) {
476 $separated[3] = substr($separated[2], $pos + strlen($this->comment_separator));
477 $separated[2] = substr($separated[2], 0, $pos);
478 }
479
480 // check if the value has a local change
481 $local_value = $local_changes[$separated[0]][$separated[1]];
482
483 if (empty($scope)) {
484 // import of a global language file
485
486 if ($local_value != "" and $local_value != $separated[2]) {
487 // keep an existing and different local calue
488 $lang_array[$separated[0]][$separated[1]] = $local_value;
489 } else {
490 // check for double entries in global file
491 if ($double_checker[$separated[0]][$separated[1]][$this->key]) {
492 $this->ilias->raiseError(
493 "Duplicate Language Entry in $lang_file:\n$val",
494 $this->ilias->error_obj->MESSAGE
495 );
496 }
497 $double_checker[$separated[0]][$separated[1]][$this->key] = true;
498
499 // insert a new value if no local value exists
500 // reset local change date if the values are equal
502 $separated[0],
503 $separated[1],
504 $this->key,
505 $separated[2],
506 $change_date,
507 $separated[3]
508 );
509
510 $lang_array[$separated[0]][$separated[1]] = $separated[2];
511 }
512 } elseif ($scope == 'local') {
513 // import of a local language file
514
515 if ($local_value != "") {
516 // keep a locally changed value that is newer than the file
517 $lang_array[$separated[0]][$separated[1]] = $local_value;
518 } else {
519 // insert a new value if no global value exists
520 // (local files may have additional entries for customizations)
521 // set the change date to the import date
523 $separated[0],
524 $separated[1],
525 $this->key,
526 $separated[2],
527 $change_date,
528 $separated[3]
529 );
530
531 $lang_array[$separated[0]][$separated[1]] = $separated[2];
532 }
533 }
534 }
535
536 $ld = "";
537 if (empty($scope)) {
538 $ld = "installed";
539 } elseif ($scope == 'local') {
540 $ld = "installed_local";
541 }
542 if ($ld) {
543 $query = "UPDATE object_data SET " .
544 "description = " . $ilDB->quote($ld, "text") . ", " .
545 "last_update = " . $ilDB->now() . " " .
546 "WHERE title = " . $ilDB->quote($this->key, "text") . " " .
547 "AND type = 'lng'";
548 $ilDB->manipulate($query);
549 }
550 }
551
552 foreach ($lang_array as $module => $lang_arr) {
553 if ($scope == "local") {
554 $q = "SELECT * FROM lng_modules WHERE " .
555 " lang_key = " . $ilDB->quote($this->key, "text") .
556 " AND module = " . $ilDB->quote($module, "text");
557 $set = $ilDB->query($q);
558 $row = $ilDB->fetchAssoc($set);
559 $arr2 = unserialize($row["lang_array"]);
560 if (is_array($arr2)) {
561 $lang_arr = array_merge($arr2, $lang_arr);
562 }
563 }
564 ilObjLanguage::replaceLangModule($this->key, $module, $lang_arr);
565 }
566 }
567 }
static replaceLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
getLocalChanges($a_min_date="", $a_max_date="")
get locally changed language entries
$ld
Definition: langwiz.php:244
if($modEnd===false) $module
Definition: module.php:59
$query

References $DIC, $ilDB, $key, $lang_path, $ld, $module, $path, $query, $row, cut_header(), getLocalChanges(), and replaceLangEntry().

Referenced by install(), and refresh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ install()

ilObjLanguage::install (   $scope = '')

install current language

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

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

161 {
162 if (!empty($scope)) {
163 if ($scope == 'global') {
164 $scope = '';
165 } else {
166 $scopeExtension = '.' . $scope;
167 }
168 }
169
170 if (($this->isInstalled() == false) ||
171 ($this->isInstalled() == true && $this->isLocal() == false && !empty($scope))) {
172 if ($this->check($scope)) {
173 // lang-file is ok. Flush data in db and...
174 if (empty($scope)) {
175 $this->flush('keep_local');
176 }
177
178 // ...re-insert data from lang-file
179 $this->insert($scope);
180
181 // update information in db-table about available/installed languages
182 if (empty($scope)) {
183 $newDesc = 'installed';
184 } elseif ($scope == 'local') {
185 $newDesc = 'installed_local';
186 }
187 $this->setDescription($newDesc);
188 $this->update();
189 return $this->getKey();
190 }
191 }
192 return "";
193 }
isInstalled()
Check language object status, and return true if language is installed.
getKey()
get language key
isLocal()
Check language object status, and return true if a local language file is installed.
flush($a_mode='all')
remove language data from database
insert($scope='')
insert language data from file into database
check($scope='')
Validate the logical structure of a lang file.
update()
update object in db
setDescription($a_desc)
set object description

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

+ Here is the call graph for this function:

◆ isInstalled()

ilObjLanguage::isInstalled ( )

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

Returns
boolean true if installed

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

131 {
132 if (substr($this->getStatus(), 0, 9) == "installed") {
133 return true;
134 } else {
135 return false;
136 }
137 }
getStatus()
get language status

References getStatus().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLocal()

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

146 {
147 if (substr($this->getStatus(), 10) == "local") {
148 return true;
149 } else {
150 return false;
151 }
152 }

References getStatus().

Referenced by install(), and refresh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSystemLanguage()

ilObjLanguage::isSystemLanguage ( )

check if language is system language

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

104 {
105 if ($this->key == $this->lang_default) {
106 return true;
107 } else {
108 return false;
109 }
110 }

◆ isUserLanguage()

ilObjLanguage::isUserLanguage ( )

check if language is system language

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

116 {
117 if ($this->key == $this->lang_user) {
118 return true;
119 } else {
120 return false;
121 }
122 }

◆ optimizeData()

ilObjLanguage::optimizeData ( )

optimizes the db-table langdata

Returns
boolean true on success
Deprecated:

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

785 {
786 // Mantis #22313: removed table optimization
787 return true;
788 }

◆ refresh()

ilObjLanguage::refresh ( )

refresh current language

Returns
bool

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

221 {
222 if ($this->isInstalled() == true) {
223 if ($this->check()) {
224 $this->flush('keep_local');
225 $this->insert();
226 $this->setTitle($this->getKey());
227 $this->setDescription($this->getStatus());
228 $this->update();
229
230 if ($this->isLocal() == true) {
231 if ($this->check('local')) {
232 $this->insert('local');
233 $this->setTitle($this->getKey());
234 $this->setDescription($this->getStatus());
235 $this->update();
236 }
237 }
238 return true;
239 }
240 }
241 return false;
242 }
setTitle($a_title)
set object title

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

+ Here is the call graph for this function:

◆ refreshAll()

static ilObjLanguage::refreshAll ( )
static

Refresh all installed languages.

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

248 {
250 $refreshed = array();
251
252 foreach ($languages as $lang) {
253 $langObj = new ilObjLanguage($lang["obj_id"], false);
254 if ($langObj->refresh()) {
255 $refreshed[] = $langObj->getKey();
256 }
257 unset($langObj);
258 }
259
260 self::refreshPlugins($refreshed);
261 }
static refreshPlugins($a_lang_keys=null)

References $lang, $languages, ilObject\_getObjectsByType(), and refreshPlugins().

Referenced by ilObjLanguageFolderGUI\refreshObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ refreshPlugins()

static ilObjLanguage::refreshPlugins (   $a_lang_keys = null)
static

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

269 {
270 global $DIC;
271 $ilPluginAdmin = $DIC['ilPluginAdmin'];
272
273 // refresh languages of activated plugins
274 include_once("./Services/Component/classes/class.ilPluginSlot.php");
275 $slots = ilPluginSlot::getAllSlots();
276 foreach ($slots as $slot) {
277 $act_plugins = $ilPluginAdmin->getActivePluginsForSlot(
278 $slot["component_type"],
279 $slot["component_name"],
280 $slot["slot_id"]
281 );
282 foreach ($act_plugins as $plugin) {
283 include_once("./Services/Component/classes/class.ilPlugin.php");
285 $slot["component_type"],
286 $slot["component_name"],
287 $slot["slot_id"],
288 $plugin
289 );
290 if (is_object($pl)) {
291 $pl->updateLanguages($a_lang_keys);
292 }
293 }
294 }
295 }
static getAllSlots()
Get all plugin slots.
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)

References $DIC, ilPluginSlot\getAllSlots(), and ilPlugin\getPluginObject().

Referenced by refreshAll(), and ilObjLanguageFolderGUI\refreshSelectedObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replaceLangEntry()

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

627 {
628 global $DIC;
629 $ilDB = $DIC->database();
630
631 // avoid a cache flush here (see mantis #28818)
632 // ilGlobalCache::flushAll();
633
634 if (isset($a_remarks)) {
635 $a_remarks = substr($a_remarks, 0, 250);
636 }
637 if ($a_remarks == '') {
638 unset($a_remarks);
639 }
640
641 if (isset($a_value)) {
642 $a_value = substr($a_value, 0, 4000);
643 }
644 if ($a_value == '') {
645 unset($a_value);
646 }
647
648 $ilDB->replace(
649 'lng_data',
650 array(
651 'module' => array('text',$a_module),
652 'identifier' => array('text',$a_identifier),
653 'lang_key' => array('text',$a_lang_key)
654 ),
655 array(
656 'value' => array('text',$a_value),
657 'local_change' => array('timestamp',$a_local_change),
658 'remarks' => array('text', $a_remarks)
659 )
660 );
661 return true;
662
663 /*
664 $ilDB->manipulate(sprintf("DELETE FROM lng_data WHERE module = %s AND ".
665 "identifier = %s AND lang_key = %s",
666 $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
667 $ilDB->quote($a_lang_key, "text")));
668
669
670 $ilDB->manipulate(sprintf("INSERT INTO lng_data " .
671 "(module, identifier, lang_key, value, local_change) " .
672 "VALUES (%s,%s,%s,%s,%s)",
673 $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
674 $ilDB->quote($a_lang_key, "text"), $ilDB->quote($a_value, "text"),
675 $ilDB->quote($a_local_change, "timestamp")));
676 */
677 }

References $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ resetUserLanguage()

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

748 {
749 global $DIC;
750 $ilDB = $DIC->database();
751
752 $query = "UPDATE usr_pref SET " .
753 "value = " . $ilDB->quote($this->lang_default, "text") . " " .
754 "WHERE keyword = " . $ilDB->quote('language', "text") . " " .
755 "AND value = " . $ilDB->quote($lang_key, "text");
756 $ilDB->manipulate($query);
757 }

References $DIC, $ilDB, and $query.

Referenced by uninstall().

+ Here is the caller graph for this function:

◆ uninstall()

ilObjLanguage::uninstall ( )

uninstall current language

Returns
string uninstalled language key

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

202 {
203 if ((substr($this->status, 0, 9) == "installed") && ($this->key != $this->lang_default) && ($this->key != $this->lang_user)) {
204 $this->flush('all');
205 $this->setTitle($this->key);
206 $this->setDescription("not_installed");
207 $this->update();
208 $this->resetUserLanguage($this->key);
209
210 return $this->key;
211 }
212 return "";
213 }
resetUserLanguage($lang_key)
search ILIAS for users which have selected '$lang_key' as their prefered language and reset them to d...

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

+ Here is the call graph for this function:

◆ updateLangEntry()

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

689 {
690 global $DIC;
691 $ilDB = $DIC->database();
692
693 if (isset($a_remarks)) {
694 $a_remarks = substr($a_remarks, 0, 250);
695 }
696 if ($a_remarks == '') {
697 unset($a_remarks);
698 }
699
700 if (isset($a_value)) {
701 $a_value = substr($a_value, 0, 4000);
702 }
703 if ($a_value == '') {
704 unset($a_value);
705 }
706
707 $ilDB->manipulate(sprintf(
708 "UPDATE lng_data " .
709 "SET value = %s, local_change = %s, remarks = %s " .
710 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
711 $ilDB->quote($a_value, "text"),
712 $ilDB->quote($a_local_change, "timestamp"),
713 $ilDB->quote($a_remarks, "text"),
714 $ilDB->quote($a_module, "text"),
715 $ilDB->quote($a_identifier, "text"),
716 $ilDB->quote($a_lang_key, "text")
717 ));
718 }

References $DIC, and $ilDB.

Field Documentation

◆ $comment_separator

ilObjLanguage::$comment_separator

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

◆ $key

◆ $lang_default

ilObjLanguage::$lang_default

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

◆ $lang_path

ilObjLanguage::$lang_path

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

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

◆ $lang_user

ilObjLanguage::$lang_user

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

◆ $separator

ilObjLanguage::$separator

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

◆ $status

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: