ILIAS  release_4-4 Revision
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...
 
 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...
 
 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...
 
 createRoleFolder ()
 creates a local role folder 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 refreshAll ()
 Refresh all installed languages. More...
 
static _deleteLangData ($a_lang_key, $a_keep_local_change)
 Delete languge data. More...
 
static replaceLangModule ($a_key, $a_module, $a_array)
 Replace language module array. 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 
)
static

Delete languge data.

Parameters
stringlang key

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

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

281  {
282  global $ilDB;
283  if (!$a_keep_local_change)
284  {
285  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = ".
286  $ilDB->quote($a_lang_key, "text"));
287  }
288  else
289  {
290  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = ".
291  $ilDB->quote($a_lang_key, "text").
292  " AND local_change IS NULL");
293  }
294  }
+ 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 353 of file class.ilObjLanguage.php.

References $result, $row, and DB_FETCHMODE_ASSOC.

Referenced by ilLanguageTableGUI\fillRow().

354  {
355  global $ilDB;
356 
357  $q = sprintf("SELECT MAX(local_change) last_change FROM lng_data ".
358  "WHERE lang_key = %s AND local_change IS NOT NULL",
359  $ilDB->quote($a_key, "text"));
360  $result = $ilDB->query($q);
361 
362  if ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
363  {
364  return $row['last_change'];
365  }
366  else
367  {
368  return "";
369  }
370  }
$result
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
+ 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 732 of file class.ilObjLanguage.php.

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

Referenced by install().

733  {
734  include_once("./Services/Utilities/classes/class.ilStr.php");
735 
736  if (!empty($scope))
737  {
738  if ($scope == 'global')
739  {
740  $scope = '';
741  }
742  else
743  {
744  $scopeExtension = '.' . $scope;
745  }
746  }
747 
749  if ($scope == "local")
750  {
751  $path = $this->cust_lang_path;
752  }
753 
754  $tmpPath = getcwd();
755 
756  // dir check
757  if (!is_dir($path))
758  {
759  $this->ilias->raiseError("Directory not found: ".$path, $this->ilias->error_obj->MESSAGE);
760  }
761 
762  chdir($path);
763 
764  // compute lang-file name format
765  $lang_file = "ilias_" . $this->key . ".lang" . $scopeExtension;
766 
767  // file check
768  if (!is_file($lang_file))
769  {
770  $this->ilias->raiseError("File not found: ".$lang_file,$this->ilias->error_obj->MESSAGE);
771  }
772 
773  // header check
774  $content = $this->cut_header(file($lang_file));
775  if ($content === false)
776  {
777  $this->ilias->raiseError("Wrong Header in ".$lang_file,$this->ilias->error_obj->MESSAGE);
778  }
779 
780  // check (counting) elements of each lang-entry
781  $line = 0;
782  foreach ($content as $key => $val)
783  {
784  $separated = explode($this->separator, trim($val));
785  $num = count($separated);
786  ++$n;
787  if ($num != 3)
788  {
789  $line = $n + 36;
790  $this->ilias->raiseError("Wrong parameter count in ".$lang_file." in line $line (Value: $val)! Please check your language file!",$this->ilias->error_obj->MESSAGE);
791  }
792  if (!ilStr::isUtf8($separated[2]))
793  {
794  $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);
795  }
796  }
797 
798  chdir($tmpPath);
799 
800  // no error occured
801  return true;
802  }
cut_header($content)
remove lang-file haeder information from '$content' This function seeks for a special keyword where t...
isUtf8($a_str)
Check whether string is utf-8.
redirection script todo: (a better solution should control the processing via a xml file) ...
$n
Definition: RandomTest.php:80
$path
Definition: index.php:22
+ 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 807 of file class.ilObjLanguage.php.

References ilObject\$lng.

Referenced by ilLanguageTableGUI\fillRow().

808  {
809  global $ilDB, $lng;
810 
811  $set = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud JOIN usr_pref up".
812  " ON ud.usr_id = up.usr_id ".
813  " WHERE up.value = ".$ilDB->quote($a_lang, "text").
814  " AND up.keyword = ".$ilDB->quote("language", "text"));
815  $rec = $ilDB->fetchAssoc($set);
816 
817  // add users with no usr_pref set to default language
818  if ($a_lang == $lng->lang_default)
819  {
820  $set2 = $ilDB->query("SELECT COUNT(*) cnt FROM usr_data ud LEFT JOIN usr_pref up".
821  " ON (ud.usr_id = up.usr_id AND up.keyword = ".$ilDB->quote("language", "text").")".
822  " WHERE up.value IS NULL ");
823  $rec2 = $ilDB->fetchAssoc($set2);
824  }
825 
826  return (int) $rec["cnt"] + (int) $rec2["cnt"];
827  }
+ 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 697 of file class.ilObjLanguage.php.

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

698  {
699  foreach ($content as $key => $val)
700  {
701  if (trim($val) == "<!-- language file start -->")
702  {
703  return array_slice($content,$key +1);
704  }
705  }
706 
707  return false;
708  }
+ 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 658 of file class.ilObjLanguage.php.

Referenced by ilObjLanguageExt\_deleteValues().

659  {
660  global $ilDB;
661 
662  $ilDB->manipulate(sprintf("DELETE FROM lng_data " .
663  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
664  $ilDB->quote($a_module, "text"),
665  $ilDB->quote($a_identifier, "text"),
666  $ilDB->quote($a_lang_key, "text")));
667 
668  return true;
669  }
+ 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 300 of file class.ilObjLanguage.php.

References _deleteLangData().

Referenced by install(), and uninstall().

301  {
302  global $ilDB;
303 
304  ilObjLanguage::_deleteLangData($this->key, ($a_mode == 'keep_local'));
305 
306  if ($a_mode == 'all')
307  {
308  $ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = ".
309  $ilDB->quote($this->key, "text"));
310  }
311  }
static _deleteLangData($a_lang_key, $a_keep_local_change)
Delete languge data.
+ 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 63 of file class.ilObjLanguage.php.

References $key.

Referenced by install().

64  {
65  return $this->key;
66  }
+ 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 320 of file class.ilObjLanguage.php.

References $result, $row, and DB_FETCHMODE_ASSOC.

Referenced by insert().

321  {
322  global $ilDB;
323 
324  if ($a_min_date == "")
325  {
326  $a_min_date = "1980-01-01 00:00:00";
327  }
328  if ($a_max_date == "")
329  {
330  $a_max_date = "2200-01-01 00:00:00";
331  }
332 
333  $q = sprintf("SELECT * FROM lng_data WHERE lang_key = %s ".
334  "AND local_change >= %s AND local_change <= %s",
335  $ilDB->quote($this->key, "text"), $ilDB->quote($a_min_date, "timestamp"),
336  $ilDB->quote($a_max_date, "timestamp"));
337  $result = $ilDB->query($q);
338 
339  $changes = array();
340  while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
341  {
342  $changes[$row["module"]][$row["identifier"]] = $row["value"];
343  }
344  return $changes;
345  }
$result
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
+ Here is the caller graph for this function:

◆ getStatus()

ilObjLanguage::getStatus ( )

get language status

Returns
string language status

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

References $status.

Referenced by isInstalled(), and isLocal().

74  {
75  return $this->status;
76  }
+ 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 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 378 of file class.ilObjLanguage.php.

References $key, $lang_path, $path, $query, $row, cut_header(), getLocalChanges(), replaceLangEntry(), and replaceLangModule().

Referenced by install().

379  {
380  global $ilDB;
381 
382  if (!empty($scope))
383  {
384  if ($scope == 'global')
385  {
386  $scope = '';
387  }
388  else
389  {
390  $scopeExtension = '.' . $scope;
391  }
392  }
393 
395  if ($scope == "local")
396  {
397  $path = $this->cust_lang_path;
398  }
399 
400  $tmpPath = getcwd();
401  chdir($path);
402 
403  $lang_file = "ilias_" . $this->key . ".lang" . $scopeExtension;
404 
405  if ($lang_file)
406  {
407  // initialize the array for updating lng_modules below
408  $lang_array = array();
409  $lang_array["common"] = array();
410 
411  // remove header first
412  if ($content = $this->cut_header(file($lang_file)))
413  {
414  if (empty($scope))
415  {
416  // reset change date for a global file
417  // get all local changes for a global file
418  $change_date = null;
419  $local_changes = $this->getLocalChanges();
420  }
421  else if ($scope == 'local')
422  {
423  // set the change date to import time for a local file
424  // get the modification date of the local file
425  // get the newer local changes for a local file
426  $change_date = date("Y-m-d H:i:s",time());
427  $min_date = date("Y-m-d H:i:s", filemtime($lang_file));
428  $local_changes = $this->getLocalChanges($min_date);
429  }
430 
431  foreach ($content as $key => $val)
432  {
433  // split the line of the language file
434  // [0]: module
435  // [1]: identifier
436  // [2]: value
437  // [3]: comment (optional)
438  $separated = explode($this->separator,trim($val));
439  $pos = strpos($separated[2], $this->comment_separator);
440  if ($pos !== false)
441  {
442  $separated[3] = substr($separated[2], $pos + strlen($this->comment_separator));
443  $separated[2] = substr($separated[2] , 0 , $pos);
444  }
445 
446  // check if the value has a local change
447  $local_value = $local_changes[$separated[0]][$separated[1]];
448 
449  if (empty($scope))
450  {
451  // import of a global language file
452 
453  if ($local_value != "" and $local_value != $separated[2])
454  {
455  // keep an existing and different local calue
456  $lang_array[$separated[0]][$separated[1]] = $local_value;
457  }
458  else
459  {
460  // check for double entries in global file
461  if ($double_checker[$separated[0]][$separated[1]][$this->key])
462  {
463  $this->ilias->raiseError("Duplicate Language Entry in $lang_file:\n$val",
464  $this->ilias->error_obj->MESSAGE);
465  }
466  $double_checker[$separated[0]][$separated[1]][$this->key] = true;
467 
468  // insert a new value if no local value exists
469  // reset local change date if the values are equal
470  ilObjLanguage::replaceLangEntry($separated[0], $separated[1],
471  $this->key, $separated[2], $change_date, $separated[3]);
472 
473  $lang_array[$separated[0]][$separated[1]] = $separated[2];
474  }
475  }
476  else if ($scope == 'local')
477  {
478  // import of a local language file
479 
480  if ($local_value != "")
481  {
482  // keep a locally changed value that is newer than the file
483  $lang_array[$separated[0]][$separated[1]] = $local_value;
484  }
485  else
486  {
487  // insert a new value if no global value exists
488  // (local files may have additional entries for customizations)
489  // set the change date to the import date
490  ilObjLanguage::replaceLangEntry($separated[0], $separated[1],
491  $this->key, $separated[2], $change_date, $separated[3]);
492 
493  $lang_array[$separated[0]][$separated[1]] = $separated[2];
494  }
495  }
496  }
497 
498  $ld = "";
499  if (empty($scope))
500  {
501  $ld = "installed";
502  }
503  else if ($scope == 'local')
504  {
505  $ld = "installed_local";
506  }
507  if ($ld)
508  {
509  $query = "UPDATE object_data SET " .
510  "description = ".$ilDB->quote($ld, "text").", " .
511  "last_update = ".$ilDB->now()." " .
512  "WHERE title = ".$ilDB->quote($this->key, "text")." " .
513  "AND type = 'lng'";
514  $ilDB->manipulate($query);
515  }
516  }
517 
518  foreach($lang_array as $module => $lang_arr)
519  {
520  if ($scope == "local")
521  {
522  $q = "SELECT * FROM lng_modules WHERE ".
523  " lang_key = ".$ilDB->quote($this->key, "text").
524  " AND module = ".$ilDB->quote($module, "text");
525  $set = $ilDB->query($q);
526  $row = $ilDB->fetchAssoc($set);
527  $arr2 = unserialize($row["lang_array"]);
528  if (is_array($arr2))
529  {
530  $lang_arr = array_merge($arr2, $lang_arr);
531  }
532  }
533  ilObjLanguage::replaceLangModule($this->key, $module, $lang_arr);
534  }
535  }
536 
537  chdir($tmpPath);
538  }
static replaceLangEntry($a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
static replaceLangModule($a_key, $a_module, $a_array)
Replace language module array.
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
+ 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 146 of file class.ilObjLanguage.php.

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

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

References getStatus().

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

111  {
112  if (substr($this->getStatus(), 0, 9) == "installed")
113  {
114  return true;
115  }
116  else
117  {
118  return false;
119  }
120  }
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 128 of file class.ilObjLanguage.php.

References getStatus().

Referenced by install().

129  {
130  if (substr($this->getStatus(), 10) == "local")
131  {
132  return true;
133  }
134  else
135  {
136  return false;
137  }
138  }
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 81 of file class.ilObjLanguage.php.

82  {
83  if ($this->key == $this->lang_default)
84  return true;
85  else
86  return false;
87  }

◆ isUserLanguage()

ilObjLanguage::isUserLanguage ( )

check if language is system language

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

93  {
94  if ($this->key == $this->lang_user)
95  {
96  return true;
97  }
98  else
99  {
100  return false;
101  }
102  }

◆ optimizeData()

ilObjLanguage::optimizeData ( )

optimizes the db-table langdata

Returns
boolean true on success

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

Referenced by install().

716  {
717  global $ilDB;
718 
719  $ilDB->optimizeTable("lng_data");
720  return true;
721  }
+ Here is the caller graph for this function:

◆ refreshAll()

static ilObjLanguage::refreshAll ( )
static

Refresh all installed languages.

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

References $lang, ilObject\_getObjectsByType(), ilPluginSlot\getAllSlots(), ilPlugin\getPluginObject(), and ilObjLanguage().

Referenced by ilObjLanguageFolderGUI\refreshObject().

217  {
218  global $ilPluginAdmin;
219 
220  $languages = ilObject::_getObjectsByType("lng");
221 
222  foreach ($languages as $lang)
223  {
224  $langObj = new ilObjLanguage($lang["obj_id"],false);
225 
226  if ($langObj->isInstalled() == true)
227  {
228  if ($langObj->check())
229  {
230  $langObj->flush('keep_local');
231  $langObj->insert();
232  $langObj->setTitle($langObj->getKey());
233  $langObj->setDescription($langObj->getStatus());
234  $langObj->update();
235  $langObj->optimizeData();
236 
237  if ($langObj->isLocal() == true)
238  {
239  if ($langObj->check('local'))
240  {
241  $langObj->insert('local');
242  $langObj->setTitle($langObj->getKey());
243  $langObj->setDescription($langObj->getStatus());
244  $langObj->update();
245  $langObj->optimizeData();
246  }
247  }
248  }
249  }
250 
251  unset($langObj);
252  }
253 
254  // refresh languages of activated plugins
255  include_once("./Services/Component/classes/class.ilPluginSlot.php");
256  $slots = ilPluginSlot::getAllSlots();
257  foreach ($slots as $slot)
258  {
259  $act_plugins = $ilPluginAdmin->getActivePluginsForSlot($slot["component_type"],
260  $slot["component_name"], $slot["slot_id"]);
261  foreach ($act_plugins as $plugin)
262  {
263  include_once("./Services/Component/classes/class.ilPlugin.php");
264  $pl = ilPlugin::getPluginObject($slot["component_type"],
265  $slot["component_name"], $slot["slot_id"], $plugin);
266  if (is_object($pl))
267  {
268  $pl->updateLanguages();
269  }
270  }
271  }
272  }
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
ilObjLanguage($a_id=0, $a_call_by_reference=false)
Constructor.
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
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 564 of file class.ilObjLanguage.php.

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

566  {
567  global $ilDB;
568 
569 
570  if (isset($a_remarks))
571  {
572  $a_remarks = substr($a_remarks, 0, 250);
573  }
574  if ($a_remarks == '')
575  {
576  unset($a_remarks);
577  }
578 
579  if (isset($a_value))
580  {
581  $a_value = substr($a_value, 0, 4000);
582  }
583  if ($a_value == '')
584  {
585  unset($a_value);
586  }
587 
588  $ilDB->replace(
589  'lng_data',
590  array(
591  'module' => array('text',$a_module),
592  'identifier' => array('text',$a_identifier),
593  'lang_key' => array('text',$a_lang_key)
594  ),
595  array(
596  'value' => array('text',$a_value),
597  'local_change' => array('timestamp',$a_local_change),
598  'remarks' => array('text', $a_remarks)
599  )
600  );
601  return true;
602 
603  /*
604  $ilDB->manipulate(sprintf("DELETE FROM lng_data WHERE module = %s AND ".
605  "identifier = %s AND lang_key = %s",
606  $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
607  $ilDB->quote($a_lang_key, "text")));
608 
609 
610  $ilDB->manipulate(sprintf("INSERT INTO lng_data " .
611  "(module, identifier, lang_key, value, local_change) " .
612  "VALUES (%s,%s,%s,%s,%s)",
613  $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
614  $ilDB->quote($a_lang_key, "text"), $ilDB->quote($a_value, "text"),
615  $ilDB->quote($a_local_change, "timestamp")));
616  */
617  }
+ Here is the caller graph for this function:

◆ replaceLangModule()

static ilObjLanguage::replaceLangModule (   $a_key,
  $a_module,
  $a_array 
)
staticfinal

Replace language module array.

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

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

544  {
545  global $ilDB;
546 
547  $ilDB->manipulate(sprintf("DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
548  $ilDB->quote($a_key, "text"), $ilDB->quote($a_module, "text")));
549 
550  /*$ilDB->manipulate(sprintf("INSERT INTO lng_modules (lang_key, module, lang_array) VALUES ".
551  "(%s,%s,%s)", $ilDB->quote($a_key, "text"),
552  $ilDB->quote($a_module, "text"),
553  $ilDB->quote(serialize($a_array), "clob")));*/
554  $ilDB->insert("lng_modules", array(
555  "lang_key" => array("text", $a_key),
556  "module" => array("text", $a_module),
557  "lang_array" => array("clob", serialize($a_array))
558  ));
559  }
+ 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 678 of file class.ilObjLanguage.php.

References $query.

Referenced by uninstall().

679  {
680  global $ilDB;
681 
682  $query = "UPDATE usr_pref SET " .
683  "value = ".$ilDB->quote($this->lang_default, "text")." " .
684  "WHERE keyword = ".$ilDB->quote('language', "text")." ".
685  "AND value = ".$ilDB->quote($lang_key, "text");
686  $ilDB->manipulate($query);
687  }
+ Here is the caller graph for this function:

◆ uninstall()

ilObjLanguage::uninstall ( )

uninstall current language

Returns
string uninstalled language key

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

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

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

624  {
625  global $ilDB;
626 
627  if (isset($a_remarks))
628  {
629  $a_remarks = substr($a_remarks, 0, 250);
630  }
631  if ($a_remarks == '')
632  {
633  unset($a_remarks);
634  }
635 
636  if (isset($a_value))
637  {
638  $a_value = substr($a_value, 0, 4000);
639  }
640  if ($a_value == '')
641  {
642  unset($a_value);
643  }
644 
645  $ilDB->manipulate(sprintf("UPDATE lng_data " .
646  "SET value = %s, local_change = %s, remarks = %s ".
647  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
648  $ilDB->quote($a_value, "text"), $ilDB->quote($a_local_change, "timestamp"),
649  $ilDB->quote($a_remarks, "text"),
650  $ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
651  $ilDB->quote($a_lang_key, "text")));
652  }

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: