ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
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

 __construct (int $a_id=0, bool $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 (string $scope="")
 install current language More...
 
 uninstall ()
 uninstall current language More...
 
 refresh ()
 refresh current language More...
 
 flush (string $a_mode="all")
 remove language data from database $a_mode "all" or "keep_local" More...
 
 getLocalChanges (string $a_min_date="", string $a_max_date="")
 get locally changed language entries $a_min_date minimum change date "yyyy-mm-dd hh:mm:ss" $a_max_date maximum change date "yyyy-mm-dd hh:mm:ss" Return array [module][identifier] => value More...
 
 insert (string $scope="")
 insert language data from file into database More...
 
 resetUserLanguage (string $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 (string $scope="")
 Validate the logical structure of a lang file. More...
 
- Public Member Functions inherited from ilObject
 __construct (int $id=0, bool $reference=true)
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 processAutoRating ()
 
 read ()
 
 getId ()
 
 setId (int $id)
 
 setRefId (int $ref_id)
 
 getRefId ()
 
 getType ()
 
 setType (string $type)
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 
 getUntranslatedTitle ()
 Get untranslated object title WebDAV needs to access the untranslated title of an object. More...
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $desc)
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 
 setImportId (string $import_id)
 
 setOfflineStatus (bool $status)
 
 getOfflineStatus ()
 
 supportsOfflineHandling ()
 
 getOwner ()
 
 getOwnerName ()
 get full name of object owner More...
 
 setOwner (int $usr_id)
 
 getCreateDate ()
 Get create date in YYYY-MM-DD HH-MM-SS format. More...
 
 getLastUpdateDate ()
 Get last update date in YYYY-MM-DD HH-MM-SS format. More...
 
 create ()
 note: title, description and type should be set when this function is called More...
 
 update ()
 
 MDUpdateListener (string $element)
 Metadata update listener. More...
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree (int $parent_ref_id)
 maybe this method should be in tree object!? More...
 
 setPermissions (int $parent_ref_id)
 
 setParentRolePermissions (int $parent_ref_id)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 
 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. More...
 
 applyDidacticTemplate (int $tpl_id)
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo (int $target_id, int $copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies (int $target_id, int $copy_id)
 Clone object dependencies. More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 selfOrParentWithRatingEnabled ()
 
 getPossibleSubObjects (bool $filter=true)
 get all possible sub objects of this type the object can decide which types of sub objects 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 (array $a_lang_keys=null)
 Refresh languages of activated plugins $a_lang_keys keys of languages to be refreshed (not yet supported, all available will be refreshed) More...
 
static _deleteLangData (string $a_lang_key, bool $a_keep_local_change=false)
 Delete languge data $a_lang_key lang key. More...
 
static _getLastLocalChange (string $a_key)
 get the date of the last local change $a_key language key Return change_date "yyyy-mm-dd hh:mm:ss" More...
 
static _getLocalChangesByModule (string $a_key, string $a_module)
 Get the local changes of a language module $a_key Language key $a_module Module key Return array identifier => value. More...
 
static replaceLangEntry (string $a_module, string $a_identifier, string $a_lang_key, string $a_value, string $a_local_change=null, string $a_remarks=null)
 Replace lang entry. More...
 
static updateLangEntry (string $a_module, string $a_identifier, string $a_lang_key, string $a_value, string $a_local_change=null, string $a_remarks=null)
 Replace lang entry. More...
 
static deleteLangEntry (string $a_module, string $a_identifier, string $a_lang_key)
 Delete lang entry. More...
 
static cut_header (array $content)
 remove lang-file haeder information from '$content' This function seeks for a special keyword where the language information starts. More...
 
static countUsers (string $a_lang)
 Count number of users that use a language. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId (string $import_id)
 Get (latest) object id for an import id. More...
 
static _lookupImportId (int $obj_id)
 
static _lookupOwnerName (int $owner_id)
 Lookup owner name for owner id. More...
 
static _getIdForImportId (string $import_id)
 
static _getAllReferences (int $id)
 get all reference ids for object ID More...
 
static _lookupTitle (int $obj_id)
 
static lookupOfflineStatus (int $obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner (int $obj_id)
 Lookup owner user ID for object ID. More...
 
static _getIdsForTitle (string $title, string $type='', bool $partial_match=false)
 
static _lookupDescription (int $obj_id)
 
static _lookupLastUpdate (int $obj_id, bool $formatted=false)
 
static _getLastUpdateOfObjects (array $obj_ids)
 
static _lookupObjId (int $ref_id)
 
static _setDeletedDate (int $ref_id, int $deleted_by)
 
static setDeletedDates (array $ref_ids, int $user_id)
 
static _resetDeletedDate (int $ref_id)
 
static _lookupDeletedDate (int $ref_id)
 
static _writeTitle (int $obj_id, string $title)
 write title to db (static) More...
 
static _writeDescription (int $obj_id, string $desc)
 write description to db (static) More...
 
static _writeImportId (int $obj_id, string $import_id)
 write import id to db (static) More...
 
static _lookupType (int $id, bool $reference=false)
 
static _isInTrash (int $ref_id)
 
static _hasUntrashedReference (int $obj_id)
 checks whether an object has at least one reference that is not in trash More...
 
static _lookupObjectId (int $ref_id)
 
static _getObjectsDataForType (string $type, bool $omit_trash=false)
 get all objects of a certain type More...
 
static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType (string $obj_type="", int $owner=null)
 
static _prepareCloneSelection (array $ref_ids, string $new_type, bool $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon (int $obj_id=0, string $size="big", string $type="", bool $offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies (int $obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $obj_ids)
 
static getAllOwnedRepositoryObjects (int $user_id)
 
static fixMissingTitles ($type, array &$obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate (int $obj_id)
 
static _getObjectTypeIdByTitle (string $type, \ilDBInterface $ilDB=null)
 

Data Fields

string $separator
 separator of module, comment separator, identifier & values in language files More...
 
string $comment_separator
 
string $lang_default
 
string $lang_user
 
string $lang_path
 
string $key
 
string $status
 
string $cust_lang_path
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 
const DESC_LENGTH = 128
 
const LONG_DESC_LENGTH = 4000
 
const TABLE_OBJECT_DATA = "object_data"
 
array $objectList
 
string $untranslatedTitle
 

Additional Inherited Members

- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 
- Protected Attributes inherited from ilObject
ilLogger $obj_log
 
ILIAS $ilias
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLogger $log
 
ilErrorHandling $error
 
ilTree $tree
 
ilAppEventHandler $app_event_handler
 
ilRbacAdmin $rbac_admin
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilLanguage $lng
 
int $id
 
bool $referenced
 
bool $call_by_reference
 
int $max_title = self::TITLE_LENGTH
 
int $max_desc = self::DESC_LENGTH
 
bool $add_dots = true
 
int $ref_id = null
 
string $type = ""
 
string $title = ""
 
bool $offline = false
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

$a_id reference_id or object_id $a_call_by_reference treat the id as reference_id (true) or object_id (false)

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

References ilObject\$desc, $DIC, ilObject\$lng, ilObject\$title, ILIAS\GlobalScreen\Provider\__construct(), and ilLanguage\getCustomLangPath().

51  {
52  global $DIC;
53  $lng = $DIC->language();
54 
55  $this->type = "lng";
56  parent::__construct($a_id, $a_call_by_reference);
57 
58  $this->type = "lng";
59  $this->key = $this->title;
60  $this->status = $this->desc;
61  $this->lang_default = $lng->lang_default;
62  $this->lang_user = $lng->lang_user;
63  $this->lang_path = $lng->lang_path;
64  $this->cust_lang_path = $lng->getCustomLangPath();
65  $this->separator = $lng->separator;
66  $this->comment_separator = $lng->comment_separator;
67  }
string $title
string $desc
global $DIC
Definition: feed.php:28
ilLanguage $lng
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ _deleteLangData()

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

Delete languge data $a_lang_key lang key.

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

References $DIC, and $ilDB.

Referenced by ilObjLanguageExt\getMergedRemarks().

292  : void
293  {
294  global $DIC;
295  $ilDB = $DIC->database();
296 
297  if (!$a_keep_local_change) {
298  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
299  $ilDB->quote($a_lang_key, "text"));
300  } else {
301  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
302  $ilDB->quote($a_lang_key, "text") .
303  " AND local_change IS NULL");
304  }
305  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _getLastLocalChange()

static ilObjLanguage::_getLastLocalChange ( string  $a_key)
static

get the date of the last local change $a_key language key Return change_date "yyyy-mm-dd hh:mm:ss"

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

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

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

365  : string
366  {
367  global $DIC;
368  $ilDB = $DIC->database();
369 
370  $q = sprintf(
371  "SELECT MAX(local_change) last_change FROM lng_data " .
372  "WHERE lang_key = %s AND local_change IS NOT NULL",
373  $ilDB->quote($a_key, "text")
374  );
375  $result = $ilDB->query($q);
376 
377  if ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
378  return (string) $row["last_change"];
379  } else {
380  return "";
381  }
382  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ _getLocalChangesByModule()

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

Get the local changes of a language module $a_key Language key $a_module Module key Return array identifier => value.

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

References $DIC, and $ilDB.

Referenced by ilPluginLanguage\updateLanguages().

391  : array
392  {
393  global $DIC;
394  $ilDB = $DIC->database();
395 
396  $changes = array();
397  $result = $ilDB->queryF(
398  "SELECT * FROM lng_data WHERE lang_key = %s AND module = %s AND local_change IS NOT NULL",
399  array("text", "text"),
400  array($a_key, $a_module)
401  );
402 
403  while ($row = $ilDB->fetchAssoc($result)) {
404  $changes[$row["identifier"]] = $row["value"];
405  }
406  return $changes;
407  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ check()

ilObjLanguage::check ( string  $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).

$scope empty (global) or "local" Return system message

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

References $cust_lang_path, $lang_path, $path, $scope, and ilStr\isUtf8().

Referenced by install(), and refresh().

671  : bool
672  {
673  include_once "./Services/Utilities/classes/class.ilStr.php";
674  $scopeExtension = "";
675  if (!empty($scope)) {
676  if ($scope === "global") {
677  $scope = "";
678  } else {
679  $scopeExtension = "." . $scope;
680  }
681  }
682 
684  if ($scope === "local") {
686  }
687 
688  $tmpPath = getcwd();
689 
690  // dir check
691  if (!is_dir($path)) {
692  $this->ilias->raiseError("Directory not found: " . $path, $this->ilias->error_obj->MESSAGE);
693  }
694 
695  chdir($path);
696 
697  // compute lang-file name format
698  $lang_file = "ilias_" . $this->key . ".lang" . $scopeExtension;
699 
700  // file check
701  if (!is_file($lang_file)) {
702  $this->ilias->raiseError("File not found: " . $lang_file, $this->ilias->error_obj->MESSAGE);
703  }
704 
705  // header check
706  $content = self::cut_header(file($lang_file));
707  if ($content === false) {
708  $this->ilias->raiseError("Wrong Header in " . $lang_file, $this->ilias->error_obj->MESSAGE);
709  }
710 
711  // check (counting) elements of each lang-entry
712  $line = 0;
713  $n = 0;
714  foreach ($content as $key => $val) {
715  $separated = explode($this->separator, trim($val));
716  $num = count($separated);
717  ++$n;
718  if ($num !== 3) {
719  $line = $n + 36;
720  $this->ilias->raiseError("Wrong parameter count in " . $lang_file . " in line $line (Value: $val)! Please check your language file!", $this->ilias->error_obj->MESSAGE);
721  }
722  if (!ilStr::isUtf8($separated[2])) {
723  $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);
724  }
725  }
726 
727  chdir($tmpPath);
728 
729  // no error occured
730  return true;
731  }
$scope
Definition: ltiregstart.php:53
$path
Definition: ltiservices.php:32
static isUtf8(string $a_str)
Check whether string is utf-8.
header include for all ilias files.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countUsers()

static ilObjLanguage::countUsers ( string  $a_lang)
static

Count number of users that use a language.

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

References $DIC, $ilDB, ilObject\$lng, and ILIAS\Repository\int().

Referenced by ilLanguageTableGUI\fillRow().

736  : int
737  {
738  global $DIC;
739  $ilDB = $DIC->database();
740  $lng = $DIC->language();
741 
742  $set = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up" .
743  " ON ud.usr_id = up.usr_id " .
744  " WHERE up.value = " . $ilDB->quote($a_lang, "text") .
745  " AND up.keyword = " . $ilDB->quote("language", "text"));
746  $rec = $ilDB->fetchAssoc($set);
747 
748  // add users with no usr_pref set to default language
749  if ($a_lang == $lng->lang_default) {
750  $set2 = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up" .
751  " ON (ud.usr_id = up.usr_id AND up.keyword = " . $ilDB->quote("language", "text") . ")" .
752  " WHERE up.value IS NULL ");
753  $rec2 = $ilDB->fetchAssoc($set2);
754  }
755 
756  return (int) $rec["cnt"] + (int) ($rec2["cnt"] ?? 0);
757  }
global $DIC
Definition: feed.php:28
ilLanguage $lng
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cut_header()

static ilObjLanguage::cut_header ( array  $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

$content expecting an ILIAS lang-file Return content without header info OR false if no valid header was found

Returns
bool|array

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

Referenced by ilObjLanguageFolder\checkAllLanguages().

640  {
641  foreach ($content as $key => $val) {
642  if (trim($val) === "<!-- language file start -->") {
643  return array_slice($content, $key + 1);
644  }
645  }
646 
647  return false;
648  }
+ Here is the caller graph for this function:

◆ deleteLangEntry()

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

Delete lang entry.

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

References $DIC, and $ilDB.

Referenced by ilObjLanguageExt\_deleteValues().

595  : bool
596  {
597  global $DIC;
598  $ilDB = $DIC->database();
599 
600  $ilDB->manipulate(sprintf(
601  "DELETE FROM lng_data " .
602  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
603  $ilDB->quote($a_module, "text"),
604  $ilDB->quote($a_identifier, "text"),
605  $ilDB->quote($a_lang_key, "text")
606  ));
607 
608  return true;
609  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ flush()

ilObjLanguage::flush ( string  $a_mode = "all")

remove language data from database $a_mode "all" or "keep_local"

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

References $DIC, and $ilDB.

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

311  : void
312  {
313  global $DIC;
314  $ilDB = $DIC->database();
315 
316  self::_deleteLangData($this->key, ($a_mode === "keep_local"));
317 
318  if ($a_mode === "all") {
319  $ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = " .
320  $ilDB->quote($this->key, "text"));
321  }
322  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getInstalledLanguages()

static ilObjLanguage::getInstalledLanguages ( )
static

Get the language objects of the installed languages.

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

References $lang, and ilObject\_getObjectsByType().

Referenced by ilPluginLanguage\updateLanguages().

73  : array
74  {
75  $objects = array();
76  $languages = ilObject::_getObjectsByType("lng");
77  foreach ($languages as $lang) {
78  $langObj = new ilObjLanguage((int) $lang["obj_id"], false);
79  if ($langObj->isInstalled()) {
80  $objects[] = $langObj;
81  } else {
82  unset($langObj);
83  }
84  }
85  return $objects;
86  }
Class ilObjLanguage.
static _getObjectsByType(string $obj_type="", int $owner=null)
$lang
Definition: xapiexit.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getKey()

ilObjLanguage::getKey ( )

get language key

Return language key

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

References $key.

Referenced by install(), and refresh().

94  : string
95  {
96  return $this->key;
97  }
+ Here is the caller graph for this function:

◆ getLocalChanges()

ilObjLanguage::getLocalChanges ( string  $a_min_date = "",
string  $a_max_date = "" 
)

get locally changed language entries $a_min_date minimum change date "yyyy-mm-dd hh:mm:ss" $a_max_date maximum change date "yyyy-mm-dd hh:mm:ss" Return array [module][identifier] => value

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

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

Referenced by insert().

331  : array
332  {
333  global $DIC;
334  $ilDB = $DIC->database();
335 
336  if ($a_min_date === "") {
337  $a_min_date = "1980-01-01 00:00:00";
338  }
339  if ($a_max_date === "") {
340  $a_max_date = "2200-01-01 00:00:00";
341  }
342 
343  $q = sprintf(
344  "SELECT * FROM lng_data WHERE lang_key = %s " .
345  "AND local_change >= %s AND local_change <= %s",
346  $ilDB->quote($this->key, "text"),
347  $ilDB->quote($a_min_date, "timestamp"),
348  $ilDB->quote($a_max_date, "timestamp")
349  );
350  $result = $ilDB->query($q);
351 
352  $changes = array();
353  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
354  $changes[$row["module"]][$row["identifier"]] = $row["value"];
355  }
356  return $changes;
357  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getStatus()

ilObjLanguage::getStatus ( )

get language status

Return language status

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

References $status.

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

104  : string
105  {
106  return $this->status;
107  }
+ Here is the caller graph for this function:

◆ insert()

ilObjLanguage::insert ( string  $scope = "")

insert language data from file into database

$scope empty (global) or "local"

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

References $cust_lang_path, $DIC, $ilDB, $ilErr, $lang_path, $path, $scope, ilCachedLanguage\getInstance(), and getLocalChanges().

Referenced by install(), and refresh().

415  : void
416  {
417  global $DIC;
418  $ilDB = $DIC->database();
419  $scopeExtension = "";
420  if (!empty($scope)) {
421  if ($scope === "global") {
422  $scope = "";
423  } else {
424  $scopeExtension = "." . $scope;
425  }
426  }
427 
429  if ($scope === "local") {
431  }
432 
433  $lang_file = $path . "/ilias_" . $this->key . ".lang" . $scopeExtension;
434 
435  if (is_file($lang_file)) {
436  // remove header first
437  if ($content = self::cut_header(file($lang_file))) {
438  $local_changes = null;
439  if (empty($scope)) {
440  // get all local changes for a global file
441  $local_changes = $this->getLocalChanges();
442  } elseif ($scope === "local") {
443  // get the modification date of the local file
444  // get the newer local changes for a local file
445  $min_date = date("Y-m-d H:i:s", filemtime($lang_file));
446  $local_changes = $this->getLocalChanges($min_date);
447  }
448  $dbAccess = new ilObjLanguageDBAccess($ilDB, $this->key, $content, $local_changes, $scope);
449  $lang_array = $dbAccess->insertLangEntries($lang_file);
450  $dbAccess->replaceLangModules($lang_array);
451  }
452  }
453  }
$scope
Definition: ltiregstart.php:53
$path
Definition: ltiservices.php:32
global $DIC
Definition: feed.php:28
getLocalChanges(string $a_min_date="", string $a_max_date="")
get locally changed language entries $a_min_date minimum change date "yyyy-mm-dd hh:mm:ss" $a_max_dat...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ install()

ilObjLanguage::install ( string  $scope = "")

install current language

$scope empty (global) or "local" Return installed language key

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

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

168  : string
169  {
170  if (!empty($scope)) {
171  if ($scope === "global") {
172  $scope = "";
173  } else {
174  $scopeExtension = "." . $scope;
175  }
176  }
177 
178  if (!$this->isInstalled() || (!$this->isLocal() && !empty($scope))) {
179  if ($this->check($scope)) {
180  // lang-file is ok. Flush data in db and...
181  if (empty($scope)) {
182  $this->flush("keep_local");
183  }
184 
185  // ...re-insert data from lang-file
186  $this->insert($scope);
187 
188  // update information in db-table about available/installed languages
189  $newDesc = '';
190  if (empty($scope)) {
191  $newDesc = "installed";
192  } elseif ($scope === "local") {
193  $newDesc = "installed_local";
194  }
195  $this->setDescription($newDesc);
196  $this->update();
197  return $this->getKey();
198  }
199  }
200  return "";
201  }
insert(string $scope="")
insert language data from file into database
$scope
Definition: ltiregstart.php:53
isInstalled()
Check language object status, and return true if language is installed.
setDescription(string $desc)
check(string $scope="")
Validate the logical structure of a lang file.
flush(string $a_mode="all")
remove language data from database $a_mode "all" or "keep_local"
isLocal()
Check language object status, and return true if a local language file is installed.
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.

Return true if installed

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

References getStatus().

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

138  : bool
139  {
140  if (strpos($this->getStatus(), "installed") === 0) {
141  return true;
142  } else {
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.

Return true if local language is installed

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

References getStatus().

Referenced by install(), and refresh().

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

112  : bool
113  {
114  if ($this->key == $this->lang_default) {
115  return true;
116  } else {
117  return false;
118  }
119  }

◆ isUserLanguage()

ilObjLanguage::isUserLanguage ( )

check if language is system language

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

124  : bool
125  {
126  if ($this->key == $this->lang_user) {
127  return true;
128  } else {
129  return false;
130  }
131  }

◆ optimizeData()

ilObjLanguage::optimizeData ( )

optimizes the db-table langdata

Return true on success

Deprecated:

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

656  : bool
657  {
658  // Mantis #22313: removed table optimization
659  return true;
660  }

◆ refresh()

ilObjLanguage::refresh ( )

refresh current language

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

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

227  : bool
228  {
229  if ($this->isInstalled() && $this->check()) {
230  $this->flush("keep_local");
231  $this->insert();
232  $this->setTitle($this->getKey());
233  $this->setDescription($this->getStatus());
234  $this->update();
235 
236  if ($this->isLocal() && $this->check("local")) {
237  $this->insert("local");
238  $this->setTitle($this->getKey());
239  $this->setDescription($this->getStatus());
240  $this->update();
241  }
242 
243  return true;
244  }
245 
246  return false;
247  }
insert(string $scope="")
insert language data from file into database
setTitle(string $title)
isInstalled()
Check language object status, and return true if language is installed.
setDescription(string $desc)
getStatus()
get language status
check(string $scope="")
Validate the logical structure of a lang file.
flush(string $a_mode="all")
remove language data from database $a_mode "all" or "keep_local"
isLocal()
Check language object status, and return true if a local language file is installed.
getKey()
get language key
+ Here is the call graph for this function:

◆ refreshAll()

static ilObjLanguage::refreshAll ( )
static

Refresh all installed languages.

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

References $lang, and ilObject\_getObjectsByType().

Referenced by ilObjLanguageFolderGUI\refreshObject().

252  : void
253  {
254  $languages = ilObject::_getObjectsByType("lng");
255  $refreshed = array();
256 
257  foreach ($languages as $lang) {
258  $langObj = new ilObjLanguage($lang["obj_id"], false);
259  if ($langObj->refresh()) {
260  $refreshed[] = $langObj->getKey();
261  }
262  unset($langObj);
263  }
264 
265  self::refreshPlugins($refreshed);
266  }
Class ilObjLanguage.
static _getObjectsByType(string $obj_type="", int $owner=null)
$lang
Definition: xapiexit.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ refreshPlugins()

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

Refresh languages of activated plugins $a_lang_keys keys of languages to be refreshed (not yet supported, all available will be refreshed)

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

References $DIC, and XapiProxy\$plugin.

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

273  : void
274  {
275  global $DIC;
276 
277  $component_repository = $DIC["component.repository"];
278  foreach ($component_repository->getPlugins() as $plugin) {
279  if (!$plugin->isActive()) {
280  continue;
281  }
282  $handler = new ilPluginLanguage($plugin);
283  $handler->updateLanguages($a_lang_keys);
284  }
285  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ replaceLangEntry()

static ilObjLanguage::replaceLangEntry ( string  $a_module,
string  $a_identifier,
string  $a_lang_key,
string  $a_value,
string  $a_local_change = null,
string  $a_remarks = null 
)
staticfinal

Replace lang entry.

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

References $DIC, and $ilDB.

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

513  : bool {
514  global $DIC;
515  $ilDB = $DIC->database();
516 
517  // avoid a cache flush here (see mantis #28818)
518  // ilGlobalCache::flushAll();
519 
520  if (is_string($a_remarks) && $a_remarks !== '') {
521  $a_remarks = substr($a_remarks, 0, 250);
522  }
523 
524  if ($a_remarks === '') {
525  $a_remarks = null;
526  }
527 
528  if ($a_value === "") {
529  $a_value = null;
530  } else {
531  $a_value = substr($a_value, 0, 4000);
532  }
533 
534  $ilDB->replace(
535  "lng_data",
536  array(
537  "module" => array("text",$a_module),
538  "identifier" => array("text",$a_identifier),
539  "lang_key" => array("text",$a_lang_key)
540  ),
541  array(
542  "value" => array("text",$a_value),
543  "local_change" => array("timestamp",$a_local_change),
544  "remarks" => array("text", $a_remarks)
545  )
546  );
547  return true;
548  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ resetUserLanguage()

ilObjLanguage::resetUserLanguage ( string  $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

$lang_key international language key (2 digits)

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

References $DIC, $ilDB, and $query.

Referenced by uninstall().

618  : void
619  {
620  global $DIC;
621  $ilDB = $DIC->database();
622 
623  $query = "UPDATE usr_pref SET " .
624  "value = " . $ilDB->quote($this->lang_default, "text") . " " .
625  "WHERE keyword = " . $ilDB->quote('language', "text") . " " .
626  "AND value = " . $ilDB->quote($lang_key, "text");
627  $ilDB->manipulate($query);
628  }
global $DIC
Definition: feed.php:28
$query
+ Here is the caller graph for this function:

◆ uninstall()

ilObjLanguage::uninstall ( )

uninstall current language

Return uninstalled language key

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

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

209  : string
210  {
211  if ((strpos($this->status, "installed") === 0) && ($this->key != $this->lang_default) && ($this->key != $this->lang_user)) {
212  $this->flush('all');
213  $this->setTitle($this->key);
214  $this->setDescription("not_installed");
215  $this->update();
216  $this->resetUserLanguage($this->key);
217 
218  return $this->key;
219  }
220  return "";
221  }
setTitle(string $title)
setDescription(string $desc)
resetUserLanguage(string $lang_key)
search ILIAS for users which have selected &#39;$lang_key&#39; as their prefered language and reset them to d...
flush(string $a_mode="all")
remove language data from database $a_mode "all" or "keep_local"
+ Here is the call graph for this function:

◆ updateLangEntry()

static ilObjLanguage::updateLangEntry ( string  $a_module,
string  $a_identifier,
string  $a_lang_key,
string  $a_value,
string  $a_local_change = null,
string  $a_remarks = null 
)
staticfinal

Replace lang entry.

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

References $DIC, and $ilDB.

560  : void {
561  global $DIC;
562  $ilDB = $DIC->database();
563 
564  if (is_string($a_remarks) && $a_remarks !== '') {
565  $a_remarks = substr($a_remarks, 0, 250);
566  }
567 
568  if ($a_remarks === '') {
569  $a_remarks = null;
570  }
571 
572  if ($a_value === "") {
573  $a_value = null;
574  } else {
575  $a_value = substr($a_value, 0, 4000);
576  }
577 
578  $ilDB->manipulate(sprintf(
579  "UPDATE lng_data " .
580  "SET value = %s, local_change = %s, remarks = %s " .
581  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
582  $ilDB->quote($a_value, "text"),
583  $ilDB->quote($a_local_change, "timestamp"),
584  $ilDB->quote($a_remarks, "text"),
585  $ilDB->quote($a_module, "text"),
586  $ilDB->quote($a_identifier, "text"),
587  $ilDB->quote($a_lang_key, "text")
588  ));
589  }
global $DIC
Definition: feed.php:28

Field Documentation

◆ $comment_separator

string ilObjLanguage::$comment_separator

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

◆ $cust_lang_path

string ilObjLanguage::$cust_lang_path

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

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

◆ $key

◆ $lang_default

string ilObjLanguage::$lang_default

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

◆ $lang_path

string ilObjLanguage::$lang_path

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

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

◆ $lang_user

string ilObjLanguage::$lang_user

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

◆ $separator

string ilObjLanguage::$separator

separator of module, comment separator, identifier & values in language files

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

◆ $status

string ilObjLanguage::$status

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

Referenced by getStatus().


The documentation for this class was generated from the following file: