ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjLanguage Class Reference

Class ilObjLanguage. More...

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

Public Member Functions

 ilObjLanguage ($a_id=0, $a_call_by_reference=false)
 Constructor. 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...
 
 _getLastLocalChange ($a_key)
 get the date of the last local change 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...
 
 cut_header ($content)
 remove lang-file haeder information from '$content' This function seeks for a special keyword where the language information starts. 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
 ilObject ($a_id=0, $a_reference=true)
 Constructor public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ($a_force_db=false)
 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 ()
 
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id More...
 
 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...
 
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class) 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...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _lookupOwner ($a_id)
 lookup object owner More...
 
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update More...
 
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects. More...
 
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree More...
 
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes More...
 
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static) More...
 
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static) More...
 
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static) More...
 
 _isInTrash ($a_ref_id)
 checks wether object is in trash More...
 
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash More...
 
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type 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...
 
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event passed, each object may decide how it reacts. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 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...
 
 _lookupCreationDate ($a_id)
 Lookup creation date. 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 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 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 _getAllReferences ($a_id)
 get all reference ids of object More...
 
static _lookupTitle ($a_id)
 lookup object title More...
 
static _getIdsForTitle ($title, $type='', $partialmatch=false)
 
static _lookupDescription ($a_id)
 lookup object description More...
 
static _lookupObjId ($a_id)
 
static setDeletedDates ($a_ref_ids)
 Set deleted date type $ilDB. More...
 
static _lookupType ($a_id, $a_reference=false)
 lookup object type More...
 
static _lookupObjectId ($a_ref_id)
 lookup object id 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 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
 
 $ilias
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 
 $obj_data_record
 object_data record More...
 

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.

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

References $ilDB.

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

329  {
330  global $ilDB;
331  if (!$a_keep_local_change)
332  {
333  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = ".
334  $ilDB->quote($a_lang_key, "text"));
335  }
336  else
337  {
338  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = ".
339  $ilDB->quote($a_lang_key, "text").
340  " AND local_change IS NULL");
341  }
342  }
global $ilDB
+ Here is the caller graph for this function:

◆ _getLastLocalChange()

ilObjLanguage::_getLastLocalChange (   $a_key)

get the date of the last local change

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

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

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

Referenced by ilLanguageTableGUI\fillRow().

402  {
403  global $ilDB;
404 
405  $q = sprintf("SELECT MAX(local_change) last_change FROM lng_data ".
406  "WHERE lang_key = %s AND local_change IS NOT NULL",
407  $ilDB->quote($a_key, "text"));
408  $result = $ilDB->query($q);
409 
410  if ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
411  {
412  return $row['last_change'];
413  }
414  else
415  {
416  return "";
417  }
418  }
$result
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
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 817 of file class.ilObjLanguage.php.

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

Referenced by install(), and refresh().

818  {
819  include_once("./Services/Utilities/classes/class.ilStr.php");
820 
821  if (!empty($scope))
822  {
823  if ($scope == 'global')
824  {
825  $scope = '';
826  }
827  else
828  {
829  $scopeExtension = '.' . $scope;
830  }
831  }
832 
834  if ($scope == "local")
835  {
836  $path = $this->cust_lang_path;
837  }
838 
839  $tmpPath = getcwd();
840 
841  // dir check
842  if (!is_dir($path))
843  {
844  $this->ilias->raiseError("Directory not found: ".$path, $this->ilias->error_obj->MESSAGE);
845  }
846 
847  chdir($path);
848 
849  // compute lang-file name format
850  $lang_file = "ilias_" . $this->key . ".lang" . $scopeExtension;
851 
852  // file check
853  if (!is_file($lang_file))
854  {
855  $this->ilias->raiseError("File not found: ".$lang_file,$this->ilias->error_obj->MESSAGE);
856  }
857 
858  // header check
859  $content = $this->cut_header(file($lang_file));
860  if ($content === false)
861  {
862  $this->ilias->raiseError("Wrong Header in ".$lang_file,$this->ilias->error_obj->MESSAGE);
863  }
864 
865  // check (counting) elements of each lang-entry
866  $line = 0;
867  foreach ($content as $key => $val)
868  {
869  $separated = explode($this->separator, trim($val));
870  $num = count($separated);
871  ++$n;
872  if ($num != 3)
873  {
874  $line = $n + 36;
875  $this->ilias->raiseError("Wrong parameter count in ".$lang_file." in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);
876  }
877  if (!ilStr::isUtf8($separated[2]))
878  {
879  $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);
880  }
881  }
882 
883  chdir($tmpPath);
884 
885  // no error occured
886  return true;
887  }
cut_header($content)
remove lang-file haeder information from '$content' This function seeks for a special keyword where t...
redirection script todo: (a better solution should control the processing via a xml file) ...
$n
Definition: RandomTest.php:80
$path
Definition: index.php:22
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 892 of file class.ilObjLanguage.php.

References $ilDB, and ilObject\$lng.

Referenced by ilLanguageTableGUI\fillRow().

893  {
894  global $ilDB, $lng;
895 
896  $set = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up".
897  " ON ud.usr_id = up.usr_id ".
898  " WHERE up.value = ".$ilDB->quote($a_lang, "text").
899  " AND up.keyword = ".$ilDB->quote("language", "text"));
900  $rec = $ilDB->fetchAssoc($set);
901 
902  // add users with no usr_pref set to default language
903  if ($a_lang == $lng->lang_default)
904  {
905  $set2 = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up".
906  " ON (ud.usr_id = up.usr_id AND up.keyword = ".$ilDB->quote("language", "text").")".
907  " WHERE up.value IS NULL ");
908  $rec2 = $ilDB->fetchAssoc($set2);
909  }
910 
911  return (int) $rec["cnt"] + (int) $rec2["cnt"];
912  }
global $ilDB
+ Here is the caller graph for this function:

◆ cut_header()

ilObjLanguage::cut_header (   $content)

remove lang-file haeder information from '$content' This function seeks for a special keyword where the language information starts.

if found it returns the plain language information, otherwise returns false

Parameters
string$contentexpecting an ILIAS lang-file
Returns
string $content content without header info OR false if no valid header was found

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

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

783  {
784  foreach ($content as $key => $val)
785  {
786  if (trim($val) == "<!-- language file start -->")
787  {
788  return array_slice($content,$key +1);
789  }
790  }
791 
792  return false;
793  }
+ 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 743 of file class.ilObjLanguage.php.

References $ilDB.

Referenced by ilObjLanguageExt\_deleteValues().

744  {
745  global $ilDB;
746 
747  $ilDB->manipulate(sprintf("DELETE FROM lng_data " .
748  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
749  $ilDB->quote($a_module, "text"),
750  $ilDB->quote($a_identifier, "text"),
751  $ilDB->quote($a_lang_key, "text")));
752 
753  return true;
754  }
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 348 of file class.ilObjLanguage.php.

References $ilDB, and _deleteLangData().

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

349  {
350  global $ilDB;
351 
352  ilObjLanguage::_deleteLangData($this->key, ($a_mode == 'keep_local'));
353 
354  if ($a_mode == 'all')
355  {
356  $ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = ".
357  $ilDB->quote($this->key, "text"));
358  }
359  }
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 62 of file class.ilObjLanguage.php.

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

Referenced by ilPlugin\updateLanguages().

63  {
64  $objects = array();
65  $languages = ilObject::_getObjectsByType("lng");
66  foreach ($languages as $lang)
67  {
68  $langObj = new ilObjLanguage($lang["obj_id"], false);
69  if ($langObj->isInstalled())
70  {
71  $objects[] = $langObj;
72  }
73  else
74  {
75  unset($langObj);
76  }
77  }
78  return $objects;
79  }
ilObjLanguage($a_id=0, $a_call_by_reference=false)
Constructor.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
+ 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 87 of file class.ilObjLanguage.php.

References $key.

Referenced by install(), and refresh().

88  {
89  return $this->key;
90  }
+ 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 368 of file class.ilObjLanguage.php.

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

Referenced by insert().

369  {
370  global $ilDB;
371 
372  if ($a_min_date == "")
373  {
374  $a_min_date = "1980-01-01 00:00:00";
375  }
376  if ($a_max_date == "")
377  {
378  $a_max_date = "2200-01-01 00:00:00";
379  }
380 
381  $q = sprintf("SELECT * FROM lng_data WHERE lang_key = %s ".
382  "AND local_change >= %s AND local_change <= %s",
383  $ilDB->quote($this->key, "text"), $ilDB->quote($a_min_date, "timestamp"),
384  $ilDB->quote($a_max_date, "timestamp"));
385  $result = $ilDB->query($q);
386 
387  $changes = array();
388  while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
389  {
390  $changes[$row["module"]][$row["identifier"]] = $row["value"];
391  }
392  return $changes;
393  }
$result
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
global $ilDB
+ Here is the caller graph for this function:

◆ getStatus()

ilObjLanguage::getStatus ( )

get language status

Returns
string language status

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

References $status.

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

98  {
99  return $this->status;
100  }
+ Here is the caller graph for this function:

◆ ilObjLanguage()

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

Constructor.

public

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

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

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

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

41  {
42  global $lng;
43 
44  $this->type = "lng";
45  $this->ilObject($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  }
ilObject($a_id=0, $a_reference=true)
Constructor public.
+ Here is the call graph for this function:
+ 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 451 of file class.ilObjLanguage.php.

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

Referenced by install(), and refresh().

452  {
453  global $ilDB;
454 
455  if (!empty($scope))
456  {
457  if ($scope == 'global')
458  {
459  $scope = '';
460  }
461  else
462  {
463  $scopeExtension = '.' . $scope;
464  }
465  }
466 
468  if ($scope == "local")
469  {
470  $path = $this->cust_lang_path;
471  }
472 
473  $lang_file = $path . "/ilias_" . $this->key . ".lang" . $scopeExtension;
474  if (is_file($lang_file))
475  {
476  // initialize the array for updating lng_modules below
477  $lang_array = array();
478  $lang_array["common"] = array();
479 
480  // remove header first
481  if ($content = $this->cut_header(file($lang_file)))
482  {
483  if (empty($scope))
484  {
485  // reset change date for a global file
486  // get all local changes for a global file
487  $change_date = null;
488  $local_changes = $this->getLocalChanges();
489  }
490  else if ($scope == 'local')
491  {
492  // set the change date to import time for a local file
493  // get the modification date of the local file
494  // get the newer local changes for a local file
495  $change_date = date("Y-m-d H:i:s",time());
496  $min_date = date("Y-m-d H:i:s", filemtime($lang_file));
497  $local_changes = $this->getLocalChanges($min_date);
498  }
499 
500  foreach ($content as $key => $val)
501  {
502  // split the line of the language file
503  // [0]: module
504  // [1]: identifier
505  // [2]: value
506  // [3]: comment (optional)
507  $separated = explode($this->separator,trim($val));
508  $pos = strpos($separated[2], $this->comment_separator);
509  if ($pos !== false)
510  {
511  $separated[3] = substr($separated[2], $pos + strlen($this->comment_separator));
512  $separated[2] = substr($separated[2] , 0 , $pos);
513  }
514 
515  // check if the value has a local change
516  $local_value = $local_changes[$separated[0]][$separated[1]];
517 
518  if (empty($scope))
519  {
520  // import of a global language file
521 
522  if ($local_value != "" and $local_value != $separated[2])
523  {
524  // keep an existing and different local calue
525  $lang_array[$separated[0]][$separated[1]] = $local_value;
526  }
527  else
528  {
529  // check for double entries in global file
530  if ($double_checker[$separated[0]][$separated[1]][$this->key])
531  {
532  $this->ilias->raiseError("Duplicate Language Entry in $lang_file:\n$val",
533  $this->ilias->error_obj->MESSAGE);
534  }
535  $double_checker[$separated[0]][$separated[1]][$this->key] = true;
536 
537  // insert a new value if no local value exists
538  // reset local change date if the values are equal
539  ilObjLanguage::replaceLangEntry($separated[0], $separated[1],
540  $this->key, $separated[2], $change_date, $separated[3]);
541 
542  $lang_array[$separated[0]][$separated[1]] = $separated[2];
543  }
544  }
545  else if ($scope == 'local')
546  {
547  // import of a local language file
548 
549  if ($local_value != "")
550  {
551  // keep a locally changed value that is newer than the file
552  $lang_array[$separated[0]][$separated[1]] = $local_value;
553  }
554  else
555  {
556  // insert a new value if no global value exists
557  // (local files may have additional entries for customizations)
558  // set the change date to the import date
559  ilObjLanguage::replaceLangEntry($separated[0], $separated[1],
560  $this->key, $separated[2], $change_date, $separated[3]);
561 
562  $lang_array[$separated[0]][$separated[1]] = $separated[2];
563  }
564  }
565  }
566 
567  $ld = "";
568  if (empty($scope))
569  {
570  $ld = "installed";
571  }
572  else if ($scope == 'local')
573  {
574  $ld = "installed_local";
575  }
576  if ($ld)
577  {
578  $query = "UPDATE object_data SET " .
579  "description = ".$ilDB->quote($ld, "text").", " .
580  "last_update = ".$ilDB->now()." " .
581  "WHERE title = ".$ilDB->quote($this->key, "text")." " .
582  "AND type = 'lng'";
583  $ilDB->manipulate($query);
584  }
585  }
586 
587  foreach($lang_array as $module => $lang_arr)
588  {
589  if ($scope == "local")
590  {
591  $q = "SELECT * FROM lng_modules WHERE ".
592  " lang_key = ".$ilDB->quote($this->key, "text").
593  " AND module = ".$ilDB->quote($module, "text");
594  $set = $ilDB->query($q);
595  $row = $ilDB->fetchAssoc($set);
596  $arr2 = unserialize($row["lang_array"]);
597  if (is_array($arr2))
598  {
599  $lang_arr = array_merge($arr2, $lang_arr);
600  }
601  }
602  ilObjLanguage::replaceLangModule($this->key, $module, $lang_arr);
603  }
604  }
605  }
static replaceLangEntry($a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
cut_header($content)
remove lang-file haeder information from &#39;$content&#39; This function seeks for a special keyword where t...
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) ...
$path
Definition: index.php:22
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 170 of file class.ilObjLanguage.php.

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

171  {
172  if (!empty($scope))
173  {
174  if ($scope == 'global')
175  {
176  $scope = '';
177  }
178  else
179  {
180  $scopeExtension = '.' . $scope;
181  }
182  }
183 
184  if (($this->isInstalled() == false) ||
185  ($this->isInstalled() == true && $this->isLocal() == false && !empty($scope)))
186  {
187  if ($this->check($scope))
188  {
189  // lang-file is ok. Flush data in db and...
190  if (empty($scope))
191  {
192  $this->flush('keep_local');
193  }
194 
195  // ...re-insert data from lang-file
196  $this->insert($scope);
197 
198  // update information in db-table about available/installed languages
199  if (empty($scope))
200  {
201  $newDesc = 'installed';
202  }
203  else if ($scope == 'local')
204  {
205  $newDesc = 'installed_local';
206  }
207  $this->setDescription($newDesc);
208  $this->update();
209  $this->optimizeData();
210  return $this->getKey();
211  }
212  }
213  return "";
214  }
optimizeData()
optimizes the db-table langdata
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 134 of file class.ilObjLanguage.php.

References getStatus().

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

135  {
136  if (substr($this->getStatus(), 0, 9) == "installed")
137  {
138  return true;
139  }
140  else
141  {
142  return false;
143  }
144  }
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 152 of file class.ilObjLanguage.php.

References getStatus().

Referenced by install(), and refresh().

153  {
154  if (substr($this->getStatus(), 10) == "local")
155  {
156  return true;
157  }
158  else
159  {
160  return false;
161  }
162  }
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 105 of file class.ilObjLanguage.php.

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

◆ isUserLanguage()

ilObjLanguage::isUserLanguage ( )

check if language is system language

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

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

◆ optimizeData()

ilObjLanguage::optimizeData ( )

optimizes the db-table langdata

Returns
boolean true on success

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

References $ilDB.

Referenced by install(), and refresh().

801  {
802  global $ilDB;
803 
804  $ilDB->optimizeTable("lng_data");
805  return true;
806  }
global $ilDB
+ Here is the caller graph for this function:

◆ refresh()

ilObjLanguage::refresh ( )

refresh current language

Returns
bool

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

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

243  {
244  if ($this->isInstalled() == true)
245  {
246  if ($this->check())
247  {
248  $this->flush('keep_local');
249  $this->insert();
250  $this->setTitle($this->getKey());
251  $this->setDescription($this->getStatus());
252  $this->update();
253  $this->optimizeData();
254 
255  if ($this->isLocal() == true)
256  {
257  if ($this->check('local'))
258  {
259  $this->insert('local');
260  $this->setTitle($this->getKey());
261  $this->setDescription($this->getStatus());
262  $this->update();
263  $this->optimizeData();
264  }
265  }
266  return true;
267  }
268  }
269  return false;
270  }
optimizeData()
optimizes the db-table langdata
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 275 of file class.ilObjLanguage.php.

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

Referenced by ilObjLanguageFolderGUI\refreshObject().

276  {
277  $languages = ilObject::_getObjectsByType("lng");
278  $refreshed = array();
279 
280  foreach ($languages as $lang)
281  {
282  $langObj = new ilObjLanguage($lang["obj_id"],false);
283  if ($langObj->refresh())
284  {
285  $refreshed[] = $langObj->getKey();
286  }
287  unset($langObj);
288  }
289 
290  self::refreshPlugins($refreshed);
291  }
ilObjLanguage($a_id=0, $a_call_by_reference=false)
Constructor.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
+ 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 298 of file class.ilObjLanguage.php.

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

Referenced by ilObjLanguageFolderGUI\refreshSelectedObject().

299  {
300  global $ilPluginAdmin;
301 
302  // refresh languages of activated plugins
303  include_once("./Services/Component/classes/class.ilPluginSlot.php");
304  $slots = ilPluginSlot::getAllSlots();
305  foreach ($slots as $slot)
306  {
307  $act_plugins = $ilPluginAdmin->getActivePluginsForSlot($slot["component_type"],
308  $slot["component_name"], $slot["slot_id"]);
309  foreach ($act_plugins as $plugin)
310  {
311  include_once("./Services/Component/classes/class.ilPlugin.php");
312  $pl = ilPlugin::getPluginObject($slot["component_type"],
313  $slot["component_name"], $slot["slot_id"], $plugin);
314  if (is_object($pl))
315  {
316  $pl->updateLanguages($a_lang_keys);
317  }
318  }
319  }
320  }
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 648 of file class.ilObjLanguage.php.

References $ilDB.

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

650  {
651  global $ilDB;
652 
653  ilGlobalCache::flushAll();
654 
655  if (isset($a_remarks))
656  {
657  $a_remarks = substr($a_remarks, 0, 250);
658  }
659  if ($a_remarks == '')
660  {
661  unset($a_remarks);
662  }
663 
664  if (isset($a_value))
665  {
666  $a_value = substr($a_value, 0, 4000);
667  }
668  if ($a_value == '')
669  {
670  unset($a_value);
671  }
672 
673  $ilDB->replace(
674  'lng_data',
675  array(
676  'module' => array('text',$a_module),
677  'identifier' => array('text',$a_identifier),
678  'lang_key' => array('text',$a_lang_key)
679  ),
680  array(
681  'value' => array('text',$a_value),
682  'local_change' => array('timestamp',$a_local_change),
683  'remarks' => array('text', $a_remarks)
684  )
685  );
686  return true;
687 
688  /*
689  $ilDB->manipulate(sprintf("DELETE FROM lng_data WHERE module = %s AND ".
690  "identifier = %s AND lang_key = %s",
691  $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
692  $ilDB->quote($a_lang_key, "text")));
693 
694 
695  $ilDB->manipulate(sprintf("INSERT INTO lng_data " .
696  "(module, identifier, lang_key, value, local_change) " .
697  "VALUES (%s,%s,%s,%s,%s)",
698  $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
699  $ilDB->quote($a_lang_key, "text"), $ilDB->quote($a_value, "text"),
700  $ilDB->quote($a_local_change, "timestamp")));
701  */
702  }
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 763 of file class.ilObjLanguage.php.

References $ilDB, and $query.

Referenced by uninstall().

764  {
765  global $ilDB;
766 
767  $query = "UPDATE usr_pref SET " .
768  "value = ".$ilDB->quote($this->lang_default, "text")." " .
769  "WHERE keyword = ".$ilDB->quote('language', "text")." ".
770  "AND value = ".$ilDB->quote($lang_key, "text");
771  $ilDB->manipulate($query);
772  }
global $ilDB
+ Here is the caller graph for this function:

◆ uninstall()

ilObjLanguage::uninstall ( )

uninstall current language

Returns
string uninstalled language key

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

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

223  {
224  if ((substr($this->status, 0, 9) == "installed") && ($this->key != $this->lang_default) && ($this->key != $this->lang_user))
225  {
226  $this->flush('all');
227  $this->setTitle($this->key);
228  $this->setDescription("not_installed");
229  $this->update();
230  $this->resetUserLanguage($this->key);
231 
232  return $this->key;
233  }
234  return "";
235  }
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 707 of file class.ilObjLanguage.php.

References $ilDB.

709  {
710  global $ilDB;
711 
712  if (isset($a_remarks))
713  {
714  $a_remarks = substr($a_remarks, 0, 250);
715  }
716  if ($a_remarks == '')
717  {
718  unset($a_remarks);
719  }
720 
721  if (isset($a_value))
722  {
723  $a_value = substr($a_value, 0, 4000);
724  }
725  if ($a_value == '')
726  {
727  unset($a_value);
728  }
729 
730  $ilDB->manipulate(sprintf("UPDATE lng_data " .
731  "SET value = %s, local_change = %s, remarks = %s ".
732  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
733  $ilDB->quote($a_value, "text"), $ilDB->quote($a_local_change, "timestamp"),
734  $ilDB->quote($a_remarks, "text"),
735  $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
736  $ilDB->quote($a_lang_key, "text")));
737  }
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: