ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 
 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 ()
 
 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...
 
 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
 
 $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
 

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

References $ilDB.

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

327  {
328  global $ilDB;
329  if (!$a_keep_local_change)
330  {
331  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = ".
332  $ilDB->quote($a_lang_key, "text"));
333  }
334  else
335  {
336  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = ".
337  $ilDB->quote($a_lang_key, "text").
338  " AND local_change IS NULL");
339  }
340  }
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 399 of file class.ilObjLanguage.php.

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

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

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

References $lang_path, $n, $path, cut_header(), file, 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  }
$path
Definition: aliased.php:25
redirection script todo: (a better solution should control the processing via a xml file) ...
Reload workbook from saved file
$n
Definition: RandomTest.php:80
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 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()

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 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 
789  return array_slice($content,$key +1);
790  }
791  }
792 
793  return false;
794  }
+ 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 346 of file class.ilObjLanguage.php.

References $ilDB, and _deleteLangData().

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

347  {
348  global $ilDB;
349 
350  ilObjLanguage::_deleteLangData($this->key, ($a_mode == 'keep_local'));
351 
352  if ($a_mode == 'all')
353  {
354  $ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = ".
355  $ilDB->quote($this->key, "text"));
356  }
357  }
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, $languages, ilObject\_getObjectsByType(), and array.

Referenced by ilPlugin\updateLanguages().

64  {
65  $objects = array();
67  foreach ($languages as $lang)
68  {
69  $langObj = new ilObjLanguage($lang["obj_id"], false);
70  if ($langObj->isInstalled())
71  {
72  $objects[] = $langObj;
73  }
74  else
75  {
76  unset($langObj);
77  }
78  }
79  return $objects;
80  }
Class ilObjLanguage.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
Create styles array
The data for the language used.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
$languages
Definition: cssgen2.php:34
+ 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 88 of file class.ilObjLanguage.php.

References $key.

Referenced by install(), and refresh().

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

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

Referenced by insert().

367  {
368  global $ilDB;
369 
370  if ($a_min_date == "")
371  {
372  $a_min_date = "1980-01-01 00:00:00";
373  }
374  if ($a_max_date == "")
375  {
376  $a_max_date = "2200-01-01 00:00:00";
377  }
378 
379  $q = sprintf("SELECT * FROM lng_data WHERE lang_key = %s ".
380  "AND local_change >= %s AND local_change <= %s",
381  $ilDB->quote($this->key, "text"), $ilDB->quote($a_min_date, "timestamp"),
382  $ilDB->quote($a_max_date, "timestamp"));
383  $result = $ilDB->query($q);
384 
385  $changes = array();
386  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
387  {
388  $changes[$row["module"]][$row["identifier"]] = $row["value"];
389  }
390  return $changes;
391  }
$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 98 of file class.ilObjLanguage.php.

References $status.

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

99  {
100  return $this->status;
101  }
+ 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 449 of file class.ilObjLanguage.php.

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

Referenced by install(), and refresh().

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

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

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

References getStatus().

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

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

References getStatus().

Referenced by install(), and refresh().

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

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

◆ isUserLanguage()

ilObjLanguage::isUserLanguage ( )

check if language is system language

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

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

◆ optimizeData()

ilObjLanguage::optimizeData ( )

optimizes the db-table langdata

Returns
boolean true on success
Deprecated:

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

803  {
804  // Mantis #22313: removed table optimization
805  return true;
806  }

◆ 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(), 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 
254  if ($this->isLocal() == true)
255  {
256  if ($this->check('local'))
257  {
258  $this->insert('local');
259  $this->setTitle($this->getKey());
260  $this->setDescription($this->getStatus());
261  $this->update();
262  }
263  }
264  return true;
265  }
266  }
267  return false;
268  }
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 273 of file class.ilObjLanguage.php.

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

Referenced by ilObjLanguageFolderGUI\refreshObject().

274  {
276  $refreshed = array();
277 
278  foreach ($languages as $lang)
279  {
280  $langObj = new ilObjLanguage($lang["obj_id"],false);
281  if ($langObj->refresh())
282  {
283  $refreshed[] = $langObj->getKey();
284  }
285  unset($langObj);
286  }
287 
288  self::refreshPlugins($refreshed);
289  }
Class ilObjLanguage.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
Create styles array
The data for the language used.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
$languages
Definition: cssgen2.php:34
+ 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 296 of file class.ilObjLanguage.php.

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

Referenced by ilObjLanguageFolderGUI\refreshSelectedObject().

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

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  }
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 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: