ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
 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...
 
 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 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 _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 type $ilDB. 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, ilObject\$lng, and ilObject\$title.

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

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

References $ilDB.

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

302  {
303  global $ilDB;
304  if (!$a_keep_local_change) {
305  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
306  $ilDB->quote($a_lang_key, "text"));
307  } else {
308  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
309  $ilDB->quote($a_lang_key, "text") .
310  " AND local_change IS NULL");
311  }
312  }
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 370 of file class.ilObjLanguage.php.

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

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

371  {
372  global $ilDB;
373 
374  $q = sprintf(
375  "SELECT MAX(local_change) last_change FROM lng_data " .
376  "WHERE lang_key = %s AND local_change IS NOT NULL",
377  $ilDB->quote($a_key, "text")
378  );
379  $result = $ilDB->query($q);
380 
381  if ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
382  return $row['last_change'];
383  } else {
384  return "";
385  }
386  }
$result
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 785 of file class.ilObjLanguage.php.

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

Referenced by install(), and refresh().

786  {
787  include_once("./Services/Utilities/classes/class.ilStr.php");
788 
789  if (!empty($scope)) {
790  if ($scope == 'global') {
791  $scope = '';
792  } else {
793  $scopeExtension = '.' . $scope;
794  }
795  }
796 
798  if ($scope == "local") {
799  $path = $this->cust_lang_path;
800  }
801 
802  $tmpPath = getcwd();
803 
804  // dir check
805  if (!is_dir($path)) {
806  $this->ilias->raiseError("Directory not found: " . $path, $this->ilias->error_obj->MESSAGE);
807  }
808 
809  chdir($path);
810 
811  // compute lang-file name format
812  $lang_file = "ilias_" . $this->key . ".lang" . $scopeExtension;
813 
814  // file check
815  if (!is_file($lang_file)) {
816  $this->ilias->raiseError("File not found: " . $lang_file, $this->ilias->error_obj->MESSAGE);
817  }
818 
819  // header check
820  $content = $this->cut_header(file($lang_file));
821  if ($content === false) {
822  $this->ilias->raiseError("Wrong Header in " . $lang_file, $this->ilias->error_obj->MESSAGE);
823  }
824 
825  // check (counting) elements of each lang-entry
826  $line = 0;
827  foreach ($content as $key => $val) {
828  $separated = explode($this->separator, trim($val));
829  $num = count($separated);
830  ++$n;
831  if ($num != 3) {
832  $line = $n + 36;
833  $this->ilias->raiseError("Wrong parameter count in " . $lang_file . " in line $line (Value: $val)! Please check your language file!", $this->ilias->error_obj->MESSAGE);
834  }
835  if (!ilStr::isUtf8($separated[2])) {
836  $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);
837  }
838  }
839 
840  chdir($tmpPath);
841 
842  // no error occured
843  return true;
844  }
redirection script todo: (a better solution should control the processing via a xml file) ...
Reload workbook from saved 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 849 of file class.ilObjLanguage.php.

References $ilDB, and ilObject\$lng.

Referenced by ilLanguageTableGUI\fillRow().

850  {
851  global $ilDB, $lng;
852 
853  $set = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up" .
854  " ON ud.usr_id = up.usr_id " .
855  " WHERE up.value = " . $ilDB->quote($a_lang, "text") .
856  " AND up.keyword = " . $ilDB->quote("language", "text"));
857  $rec = $ilDB->fetchAssoc($set);
858 
859  // add users with no usr_pref set to default language
860  if ($a_lang == $lng->lang_default) {
861  $set2 = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up" .
862  " ON (ud.usr_id = up.usr_id AND up.keyword = " . $ilDB->quote("language", "text") . ")" .
863  " WHERE up.value IS NULL ");
864  $rec2 = $ilDB->fetchAssoc($set2);
865  }
866 
867  return (int) $rec["cnt"] + (int) $rec2["cnt"];
868  }
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 753 of file class.ilObjLanguage.php.

References $key.

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

754  {
755  foreach ($content as $key => $val) {
756  if (trim($val) == "<!-- language file start -->") {
757  return array_slice($content, $key +1);
758  }
759  }
760 
761  return false;
762  }
+ 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 712 of file class.ilObjLanguage.php.

References $ilDB.

Referenced by ilObjLanguageExt\_deleteValues().

713  {
714  global $ilDB;
715 
716  $ilDB->manipulate(sprintf(
717  "DELETE FROM lng_data " .
718  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
719  $ilDB->quote($a_module, "text"),
720  $ilDB->quote($a_identifier, "text"),
721  $ilDB->quote($a_lang_key, "text")
722  ));
723 
724  return true;
725  }
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 318 of file class.ilObjLanguage.php.

References $ilDB, and _deleteLangData().

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

319  {
320  global $ilDB;
321 
322  ilObjLanguage::_deleteLangData($this->key, ($a_mode == 'keep_local'));
323 
324  if ($a_mode == 'all') {
325  $ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = " .
326  $ilDB->quote($this->key, "text"));
327  }
328  }
static _deleteLangData($a_lang_key, $a_keep_local_change=false)
Delete languge data.
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 63 of file class.ilObjLanguage.php.

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

Referenced by ilPlugin\updateLanguages().

64  {
65  $objects = array();
66  $languages = ilObject::_getObjectsByType("lng");
67  foreach ($languages as $lang) {
68  $langObj = new ilObjLanguage($lang["obj_id"], false);
69  if ($langObj->isInstalled()) {
70  $objects[] = $langObj;
71  } else {
72  unset($langObj);
73  }
74  }
75  return $objects;
76  }
Class ilObjLanguage.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
Create styles array
The data for the language used.
+ 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 84 of file class.ilObjLanguage.php.

References $key.

Referenced by install(), and refresh().

85  {
86  return $this->key;
87  }
+ 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 337 of file class.ilObjLanguage.php.

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

Referenced by insert().

338  {
339  global $ilDB;
340 
341  if ($a_min_date == "") {
342  $a_min_date = "1980-01-01 00:00:00";
343  }
344  if ($a_max_date == "") {
345  $a_max_date = "2200-01-01 00:00:00";
346  }
347 
348  $q = sprintf(
349  "SELECT * FROM lng_data WHERE lang_key = %s " .
350  "AND local_change >= %s AND local_change <= %s",
351  $ilDB->quote($this->key, "text"),
352  $ilDB->quote($a_min_date, "timestamp"),
353  $ilDB->quote($a_max_date, "timestamp")
354  );
355  $result = $ilDB->query($q);
356 
357  $changes = array();
358  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
359  $changes[$row["module"]][$row["identifier"]] = $row["value"];
360  }
361  return $changes;
362  }
$result
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getStatus()

ilObjLanguage::getStatus ( )

get language status

Returns
string language status

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

References $status.

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

95  {
96  return $this->status;
97  }
+ 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 419 of file class.ilObjLanguage.php.

References $DIC, $ilDB, $ilErr, $key, $lang_path, $module, $path, $query, $result, $row, array, cut_header(), date, file, getLocalChanges(), replaceLangEntry(), and time.

Referenced by install(), and refresh().

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

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

160  {
161  if (!empty($scope)) {
162  if ($scope == 'global') {
163  $scope = '';
164  } else {
165  $scopeExtension = '.' . $scope;
166  }
167  }
168 
169  if (($this->isInstalled() == false) ||
170  ($this->isInstalled() == true && $this->isLocal() == false && !empty($scope))) {
171  if ($this->check($scope)) {
172  // lang-file is ok. Flush data in db and...
173  if (empty($scope)) {
174  $this->flush('keep_local');
175  }
176 
177  // ...re-insert data from lang-file
178  $this->insert($scope);
179 
180  // update information in db-table about available/installed languages
181  if (empty($scope)) {
182  $newDesc = 'installed';
183  } elseif ($scope == 'local') {
184  $newDesc = 'installed_local';
185  }
186  $this->setDescription($newDesc);
187  $this->update();
188  return $this->getKey();
189  }
190  }
191  return "";
192  }
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 129 of file class.ilObjLanguage.php.

References getStatus().

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

130  {
131  if (substr($this->getStatus(), 0, 9) == "installed") {
132  return true;
133  } else {
134  return false;
135  }
136  }
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 144 of file class.ilObjLanguage.php.

References getStatus().

Referenced by install(), and refresh().

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

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

◆ isUserLanguage()

ilObjLanguage::isUserLanguage ( )

check if language is system language

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

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

◆ optimizeData()

ilObjLanguage::optimizeData ( )

optimizes the db-table langdata

Returns
boolean true on success
Deprecated:

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

771  {
772  // Mantis #22313: removed table optimization
773  return true;
774  }

◆ refresh()

ilObjLanguage::refresh ( )

refresh current language

Returns
bool

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

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

220  {
221  if ($this->isInstalled() == true) {
222  if ($this->check()) {
223  $this->flush('keep_local');
224  $this->insert();
225  $this->setTitle($this->getKey());
226  $this->setDescription($this->getStatus());
227  $this->update();
228 
229  if ($this->isLocal() == true) {
230  if ($this->check('local')) {
231  $this->insert('local');
232  $this->setTitle($this->getKey());
233  $this->setDescription($this->getStatus());
234  $this->update();
235  }
236  }
237  return true;
238  }
239  }
240  return false;
241  }
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 246 of file class.ilObjLanguage.php.

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

Referenced by ilObjLanguageFolderGUI\refreshObject().

247  {
248  $languages = ilObject::_getObjectsByType("lng");
249  $refreshed = array();
250 
251  foreach ($languages as $lang) {
252  $langObj = new ilObjLanguage($lang["obj_id"], false);
253  if ($langObj->refresh()) {
254  $refreshed[] = $langObj->getKey();
255  }
256  unset($langObj);
257  }
258 
259  self::refreshPlugins($refreshed);
260  }
Class ilObjLanguage.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
Create styles array
The data for the language used.
+ 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 267 of file class.ilObjLanguage.php.

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

Referenced by ilObjLanguageFolderGUI\refreshSelectedObject().

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

References $ilDB, and array.

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

618  {
619  global $ilDB;
620 
621  ilGlobalCache::flushAll();
622 
623  if (isset($a_remarks)) {
624  $a_remarks = substr($a_remarks, 0, 250);
625  }
626  if ($a_remarks == '') {
627  unset($a_remarks);
628  }
629 
630  if (isset($a_value)) {
631  $a_value = substr($a_value, 0, 4000);
632  }
633  if ($a_value == '') {
634  unset($a_value);
635  }
636 
637  $ilDB->replace(
638  'lng_data',
639  array(
640  'module' => array('text',$a_module),
641  'identifier' => array('text',$a_identifier),
642  'lang_key' => array('text',$a_lang_key)
643  ),
644  array(
645  'value' => array('text',$a_value),
646  'local_change' => array('timestamp',$a_local_change),
647  'remarks' => array('text', $a_remarks)
648  )
649  );
650  return true;
651 
652  /*
653  $ilDB->manipulate(sprintf("DELETE FROM lng_data WHERE module = %s AND ".
654  "identifier = %s AND lang_key = %s",
655  $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
656  $ilDB->quote($a_lang_key, "text")));
657 
658 
659  $ilDB->manipulate(sprintf("INSERT INTO lng_data " .
660  "(module, identifier, lang_key, value, local_change) " .
661  "VALUES (%s,%s,%s,%s,%s)",
662  $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
663  $ilDB->quote($a_lang_key, "text"), $ilDB->quote($a_value, "text"),
664  $ilDB->quote($a_local_change, "timestamp")));
665  */
666  }
Create styles array
The data for the language used.
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 734 of file class.ilObjLanguage.php.

References $ilDB, and $query.

Referenced by uninstall().

735  {
736  global $ilDB;
737 
738  $query = "UPDATE usr_pref SET " .
739  "value = " . $ilDB->quote($this->lang_default, "text") . " " .
740  "WHERE keyword = " . $ilDB->quote('language', "text") . " " .
741  "AND value = " . $ilDB->quote($lang_key, "text");
742  $ilDB->manipulate($query);
743  }
$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 200 of file class.ilObjLanguage.php.

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

201  {
202  if ((substr($this->status, 0, 9) == "installed") && ($this->key != $this->lang_default) && ($this->key != $this->lang_user)) {
203  $this->flush('all');
204  $this->setTitle($this->key);
205  $this->setDescription("not_installed");
206  $this->update();
207  $this->resetUserLanguage($this->key);
208 
209  return $this->key;
210  }
211  return "";
212  }
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 671 of file class.ilObjLanguage.php.

References $ilDB.

678  {
679  global $ilDB;
680 
681  if (isset($a_remarks)) {
682  $a_remarks = substr($a_remarks, 0, 250);
683  }
684  if ($a_remarks == '') {
685  unset($a_remarks);
686  }
687 
688  if (isset($a_value)) {
689  $a_value = substr($a_value, 0, 4000);
690  }
691  if ($a_value == '') {
692  unset($a_value);
693  }
694 
695  $ilDB->manipulate(sprintf(
696  "UPDATE lng_data " .
697  "SET value = %s, local_change = %s, remarks = %s " .
698  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
699  $ilDB->quote($a_value, "text"),
700  $ilDB->quote($a_local_change, "timestamp"),
701  $ilDB->quote($a_remarks, "text"),
702  $ilDB->quote($a_module, "text"),
703  $ilDB->quote($a_identifier, "text"),
704  $ilDB->quote($a_lang_key, "text")
705  ));
706  }
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: