ILIAS  release_7 Revision v7.30-3-g800a261c036
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 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 public More...
 
 setId ($a_id)
 set object id public More...
 
 setRefId ($a_id)
 set reference id public More...
 
 getRefId ()
 get reference id public More...
 
 getType ()
 get object type public More...
 
 setType ($a_type)
 set object type public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title public More...
 
 getUntranslatedTitle ()
 get untranslated object title 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 public More...
 
 getLastUpdateDate ()
 get last update date 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...
 
 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!! 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) 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, $a_deleted_by)
 
static setDeletedDates ($a_ref_ids, $a_user_id)
 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 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 _getIcon ( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item. 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.

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, $DIC, ilObject\$lng, ilObject\$title, and ILIAS\GlobalScreen\Provider\__construct().

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: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

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.

References $DIC, and $ilDB.

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

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 $DIC
Definition: goto.php:24
global $ilDB
+ 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.

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

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

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 
388  if ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
389  return $row['last_change'];
390  } else {
391  return "";
392  }
393  }
$result
global $DIC
Definition: goto.php:24
global $ilDB
+ 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.

References $DIC, $ilDB, and $result.

Referenced by ilPlugin\updateLanguages().

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  }
$result
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 700 of file class.ilObjLanguage.php.

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

Referenced by install(), and refresh().

701  {
702  include_once("./Services/Utilities/classes/class.ilStr.php");
703 
704  if (!empty($scope)) {
705  if ($scope == 'global') {
706  $scope = '';
707  } else {
708  $scopeExtension = '.' . $scope;
709  }
710  }
711 
712  $path = $this->lang_path;
713  if ($scope == "local") {
714  $path = $this->cust_lang_path;
715  }
716 
717  $tmpPath = getcwd();
718 
719  // dir check
720  if (!is_dir($path)) {
721  $this->ilias->raiseError("Directory not found: " . $path, $this->ilias->error_obj->MESSAGE);
722  }
723 
724  chdir($path);
725 
726  // compute lang-file name format
727  $lang_file = "ilias_" . $this->key . ".lang" . $scopeExtension;
728 
729  // file check
730  if (!is_file($lang_file)) {
731  $this->ilias->raiseError("File not found: " . $lang_file, $this->ilias->error_obj->MESSAGE);
732  }
733 
734  // header check
735  $content = $this->cut_header(file($lang_file));
736  if ($content === false) {
737  $this->ilias->raiseError("Wrong Header in " . $lang_file, $this->ilias->error_obj->MESSAGE);
738  }
739 
740  // check (counting) elements of each lang-entry
741  $line = 0;
742  foreach ($content as $key => $val) {
743  $separated = explode($this->separator, trim($val));
744  $num = count($separated);
745  ++$n;
746  if ($num != 3) {
747  $line = $n + 36;
748  $this->ilias->raiseError("Wrong parameter count in " . $lang_file . " in line $line (Value: $val)! Please check your language file!", $this->ilias->error_obj->MESSAGE);
749  }
750  if (!ilStr::isUtf8($separated[2])) {
751  $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);
752  }
753  }
754 
755  chdir($tmpPath);
756 
757  // no error occured
758  return true;
759  }
redirection script todo: (a better solution should control the processing via a xml file) ...
$n
Definition: RandomTest.php:85
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.
+ 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 764 of file class.ilObjLanguage.php.

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

Referenced by ilLanguageTableGUI\fillRow().

765  {
766  global $DIC;
767  $ilDB = $DIC->database();
768  $lng = $DIC->language();
769 
770  $set = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up" .
771  " ON ud.usr_id = up.usr_id " .
772  " WHERE up.value = " . $ilDB->quote($a_lang, "text") .
773  " AND up.keyword = " . $ilDB->quote("language", "text"));
774  $rec = $ilDB->fetchAssoc($set);
775 
776  // add users with no usr_pref set to default language
777  if ($a_lang == $lng->lang_default) {
778  $set2 = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up" .
779  " ON (ud.usr_id = up.usr_id AND up.keyword = " . $ilDB->quote("language", "text") . ")" .
780  " WHERE up.value IS NULL ");
781  $rec2 = $ilDB->fetchAssoc($set2);
782  }
783 
784  return (int) $rec["cnt"] + (int) $rec2["cnt"];
785  }
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 668 of file class.ilObjLanguage.php.

References $key.

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

669  {
670  foreach ($content as $key => $val) {
671  if (trim($val) == "<!-- language file start -->") {
672  return array_slice($content, $key + 1);
673  }
674  }
675 
676  return false;
677  }
+ 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 625 of file class.ilObjLanguage.php.

References $DIC, and $ilDB.

Referenced by ilObjLanguageExt\_deleteValues().

626  {
627  global $DIC;
628  $ilDB = $DIC->database();
629 
630  $ilDB->manipulate(sprintf(
631  "DELETE FROM lng_data " .
632  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
633  $ilDB->quote($a_module, "text"),
634  $ilDB->quote($a_identifier, "text"),
635  $ilDB->quote($a_lang_key, "text")
636  ));
637 
638  return true;
639  }
global $DIC
Definition: goto.php:24
global $ilDB
+ 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.

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

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

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.
global $DIC
Definition: goto.php:24
global $ilDB
+ 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.

References $lang, and ilObject\_getObjectsByType().

Referenced by ilPlugin\updateLanguages().

65  {
66  $objects = array();
67  $languages = ilObject::_getObjectsByType("lng");
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.
$lang
Definition: xapiexit.php:8
+ 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.

References $key.

Referenced by install(), and refresh().

86  {
87  return $this->key;
88  }
+ 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.

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

Referenced by insert().

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  }
$result
global $DIC
Definition: goto.php:24
global $ilDB
+ 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.

References $status.

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

96  {
97  return $this->status;
98  }
+ 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.

References $DIC, $ilDB, $ilErr, $lang_path, $result, ilCachedLanguage\getInstance(), and getLocalChanges().

Referenced by install(), and refresh().

427  {
428  global $DIC;
429  $ilDB = $DIC->database();
430  $scopeExtension = "";
431  if (!empty($scope)) {
432  if ($scope == 'global') {
433  $scope = '';
434  } else {
435  $scopeExtension = '.' . $scope;
436  }
437  }
438 
439  $path = $this->lang_path;
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 = self::cut_header(file($lang_file))) {
453  $local_changes = null;
454  if (empty($scope)) {
455  // get all local changes for a global file
456  $local_changes = $this->getLocalChanges();
457  } elseif ($scope == 'local') {
458  // get the modification date of the local file
459  // get the newer local changes for a local file
460  $min_date = date("Y-m-d H:i:s", filemtime($lang_file));
461  $local_changes = $this->getLocalChanges($min_date);
462  }
463  $dbAccess = new ilObjLanguageDBAccess($ilDB, $this->key, $content, $local_changes, $scope);
464  $lang_array = $dbAccess->insertLangEntries($lang_file);
465  $dbAccess->replaceLangModules($lang_array);
466  }
467  }
468  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getLocalChanges($a_min_date="", $a_max_date="")
get locally changed language entries
global $DIC
Definition: goto.php:24
global $ilDB
+ 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.

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

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.
insert($scope='')
insert language data from file into database
check($scope='')
Validate the logical structure of a lang file.
flush($a_mode='all')
remove language data from database
isLocal()
Check language object status, and return true if a local language file is installed.
setDescription($a_desc)
set object description
update()
update object in db
getKey()
get language key
+ 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.

References getStatus().

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

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

References getStatus().

Referenced by install(), and refresh().

146  {
147  if (substr($this->getStatus(), 10) == "local") {
148  return true;
149  } else {
150  return false;
151  }
152  }
getStatus()
get language status
+ 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 685 of file class.ilObjLanguage.php.

686  {
687  // Mantis #22313: removed table optimization
688  return true;
689  }

◆ refresh()

ilObjLanguage::refresh ( )

refresh current language

Returns
bool

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

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

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  }
isInstalled()
Check language object status, and return true if language is installed.
insert($scope='')
insert language data from file into database
setTitle($a_title)
set object title
getStatus()
get language status
check($scope='')
Validate the logical structure of a lang file.
flush($a_mode='all')
remove language data from database
isLocal()
Check language object status, and return true if a local language file is installed.
setDescription($a_desc)
set object description
update()
update object in db
getKey()
get language key
+ 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.

References $lang, and ilObject\_getObjectsByType().

Referenced by ilObjLanguageFolderGUI\refreshObject().

248  {
249  $languages = ilObject::_getObjectsByType("lng");
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  }
Class ilObjLanguage.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
$lang
Definition: xapiexit.php:8
+ 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.

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

Referenced by ilObjLanguageFolderGUI\refreshSelectedObject().

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 getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)
global $DIC
Definition: goto.php:24
static getAllSlots()
Get all plugin slots.
+ 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 521 of file class.ilObjLanguage.php.

References $DIC, and $ilDB.

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

528  {
529  global $DIC;
530  $ilDB = $DIC->database();
531 
532  // avoid a cache flush here (see mantis #28818)
533  // ilGlobalCache::flushAll();
534 
535  if (isset($a_remarks)) {
536  $a_remarks = substr($a_remarks, 0, 250);
537  }
538  if ($a_remarks == '') {
539  $a_remarks = null;
540  }
541 
542  if (isset($a_value)) {
543  $a_value = substr($a_value, 0, 4000);
544  }
545  if ($a_value == '') {
546  $a_value = null;
547  }
548 
549  $ilDB->replace(
550  'lng_data',
551  array(
552  'module' => array('text',$a_module),
553  'identifier' => array('text',$a_identifier),
554  'lang_key' => array('text',$a_lang_key)
555  ),
556  array(
557  'value' => array('text',$a_value),
558  'local_change' => array('timestamp',$a_local_change),
559  'remarks' => array('text', $a_remarks)
560  )
561  );
562  return true;
563 
564  /*
565  $ilDB->manipulate(sprintf("DELETE FROM lng_data WHERE module = %s AND ".
566  "identifier = %s AND lang_key = %s",
567  $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
568  $ilDB->quote($a_lang_key, "text")));
569 
570 
571  $ilDB->manipulate(sprintf("INSERT INTO lng_data " .
572  "(module, identifier, lang_key, value, local_change) " .
573  "VALUES (%s,%s,%s,%s,%s)",
574  $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
575  $ilDB->quote($a_lang_key, "text"), $ilDB->quote($a_value, "text"),
576  $ilDB->quote($a_local_change, "timestamp")));
577  */
578  }
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 648 of file class.ilObjLanguage.php.

References $DIC, $ilDB, and $query.

Referenced by uninstall().

649  {
650  global $DIC;
651  $ilDB = $DIC->database();
652 
653  $query = "UPDATE usr_pref SET " .
654  "value = " . $ilDB->quote($this->lang_default, "text") . " " .
655  "WHERE keyword = " . $ilDB->quote('language', "text") . " " .
656  "AND value = " . $ilDB->quote($lang_key, "text");
657  $ilDB->manipulate($query);
658  }
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ 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.

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

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  }
setTitle($a_title)
set object title
resetUserLanguage($lang_key)
search ILIAS for users which have selected &#39;$lang_key&#39; as their prefered language and reset them to d...
flush($a_mode='all')
remove language data from database
setDescription($a_desc)
set object description
update()
update object in db
+ 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 583 of file class.ilObjLanguage.php.

References $DIC, and $ilDB.

590  {
591  global $DIC;
592  $ilDB = $DIC->database();
593 
594  if (isset($a_remarks)) {
595  $a_remarks = substr($a_remarks, 0, 250);
596  }
597  if ($a_remarks == '') {
598  unset($a_remarks);
599  }
600 
601  if (isset($a_value)) {
602  $a_value = substr($a_value, 0, 4000);
603  }
604  if ($a_value == '') {
605  unset($a_value);
606  }
607 
608  $ilDB->manipulate(sprintf(
609  "UPDATE lng_data " .
610  "SET value = %s, local_change = %s, remarks = %s " .
611  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
612  $ilDB->quote($a_value, "text"),
613  $ilDB->quote($a_local_change, "timestamp"),
614  $ilDB->quote($a_remarks, "text"),
615  $ilDB->quote($a_module, "text"),
616  $ilDB->quote($a_identifier, "text"),
617  $ilDB->quote($a_lang_key, "text")
618  ));
619  }
global $DIC
Definition: goto.php:24
global $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: