ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjLanguageFolder Class Reference

Class ilObjLanguageFolder contains all function to manage language support for ILIAS3 install, uninstall, checkfiles .... More...

+ Inheritance diagram for ilObjLanguageFolder:
+ Collaboration diagram for ilObjLanguageFolder:

Public Member Functions

 __construct ($a_id, $a_call_by_reference=true)
 Constructor public. More...
 
 getLanguages ()
 gather all information about available languages More...
 
 addNewLanguages ($a_languages)
 add new languages More...
 
 removeLanguages ($a_languages)
 remove languages which are not installed AND has no lang-file More...
 
 checkAllLanguages ()
 validate the logical structure of a lang-file More...
 
- Public Member Functions inherited from ilObject
 __construct ($a_id=0, $a_reference=true)
 Constructor public. More...
 
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not) More...
 
 read ()
 read object data from db into object More...
 
 getId ()
 get object id public More...
 
 setId ($a_id)
 set object id public More...
 
 setRefId ($a_id)
 set reference id public More...
 
 getRefId ()
 get reference id public More...
 
 getType ()
 get object type public More...
 
 setType ($a_type)
 set object type public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title public More...
 
 getUntranslatedTitle ()
 get untranslated object title public More...
 
 setTitle ($a_title)
 set object title More...
 
 getDescription ()
 get object description More...
 
 setDescription ($a_desc)
 set object description More...
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 get import id More...
 
 setImportId ($a_import_id)
 set import id More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date public More...
 
 getLastUpdateDate ()
 get last update date public More...
 
 getDiskUsage ()
 Gets the disk usage of the object in bytes. More...
 
 create ()
 create More...
 
 update ()
 update object in db More...
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!? More...
 
 setPermissions ($a_parent_ref)
 set permissions of object More...
 
 setParentRolePermissions ($a_parent_ref)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g courses, groups for building permission intersections with non_member templates. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 count references of object More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Data Fields

 $lang_default
 
 $lang_user
 
 $lang_path
 
 $separator
 
 $languages
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 max length of object title More...
 
const DESC_LENGTH = 128
 
 $lng
 
 $id
 
 $ref_id
 
 $type
 
 $title
 
 $untranslatedTitle
 
 $desc
 
 $long_desc
 
 $owner
 
 $create_date
 
 $last_update
 
 $import_id
 
 $register = false
 
 $referenced
 
 $objectList
 
 $max_title
 
 $max_desc
 
 $add_dots
 

Additional Inherited Members

- 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...
 
- Protected Attributes inherited from ilObject
 $objDefinition
 
 $db
 
 $log
 
 $error
 
 $tree
 
 $app_event_handler
 
 $rbacadmin
 
 $rbacreview
 

Detailed Description

Class ilObjLanguageFolder contains all function to manage language support for ILIAS3 install, uninstall, checkfiles ....

Author
Sascha Hofmann shofm.nosp@m.ann@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 18 of file class.ilObjLanguageFolder.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjLanguageFolder::__construct (   $a_id,
  $a_call_by_reference = true 
)

Constructor public.

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

Definition at line 69 of file class.ilObjLanguageFolder.php.

References ilObject\$lng.

70  {
71  $this->type = "lngf";
72  parent::__construct($a_id, $a_call_by_reference);
73 
74  // init language support
75  global $lng;
76 
77  $this->lang_path = $lng->lang_path;
78  $this->lang_default = $lng->lang_default;
79  $this->lang_user = $lng->lang_user;
80  $this->separator = $lng->separator;
81  }

Member Function Documentation

◆ addNewLanguages()

ilObjLanguageFolder::addNewLanguages (   $a_languages)

add new languages

This functions checks in $languages for languages with the attribute 'new' and insert these languages in db-table 'languages'

Parameters
array$languagesexpect $languages
Returns
boolean true: language array is not empty, otherwise false

Definition at line 186 of file class.ilObjLanguageFolder.php.

References array.

Referenced by getLanguages().

187  {
188  if (count($a_languages) > 0) {
189  foreach ($a_languages as $lang_key => $lang_data) {
190  if ($lang_data["info"] == "new_language") {
191  include_once("./Services/Language/classes/class.ilObjLanguage.php");
192  $lngObj = new ilObjLanguage();
193  $lngObj->setTitle($lang_key);
194  $lngObj->setDescription("not_installed");
195  $lngObj->create();
196 
197  // must get OOP through the whole class some time
198  // (no arrays with db fields! this class doesn't know anything about table object!)
199  $a_languages[$lang_key] = array("obj_id" => $lngObj->getId(),
200  "type" => $lngObj->getType(),
201  "description" => $lngObj->getDescription(),
202  "desc" => $lngObj->getDescription(),
203  "owner" => $lngObj->getOwner(),
204  "create_date" => $lngObj->getCreateDate(),
205  "last_update" => $lngObj->getLastUpdateDate());
206 
207  $a_languages[$lang_key]["info"] = "new_language";
208  unset($lngObj); // better: the objects should be resident in an member array of this class
209  }
210  }
211  }
212 
213  return $a_languages;
214  }
Class ilObjLanguage.
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ checkAllLanguages()

ilObjLanguageFolder::checkAllLanguages ( )

validate the logical structure of a lang-file

This function is similar to function checkLanguage() (see below) but checks for all lang-files and outputs more helpful information.

Returns
string system message

Definition at line 254 of file class.ilObjLanguageFolder.php.

References $d, ilObject\$error, $key, ilObject\$lng, $output, ilObjLanguage\cut_header(), and file.

255  {
256  // TODO: lng object should not be used in this class
257  global $lng;
258 
259  // set path to directory where lang-files reside
260  $d = dir($this->lang_path);
261  $tmpPath = getcwd();
262  chdir($this->lang_path);
263 
264  // for giving a message when no lang-file was found
265  $found = false;
266 
267  // get available lang-files
268  while ($entry = $d->read()) {
269  if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang$)~", $entry))) {
270  // textmeldung, wenn langfile gefunden wurde
271  $output .= "<br/><br/>" . $lng->txt("langfile_found") . ": " . $entry;
272  $content = file($entry);
273 
274  $found = true;
275  $error = false;
276 
277  if ($content = ilObjLanguage::cut_header($content)) {
278  foreach ($content as $key => $val) {
279  $separated = explode($this->separator, trim($val));
280  $num = count($separated);
281 
282  if ($num != 3) {
283  $error = true;
284  $line = $key + 37;
285 
286  $output .= "<br/><b/>" . $lng->txt("err_in_line") . " " . $line . " !</b>&nbsp;&nbsp;";
287  $output .= $lng->txt("module") . ": " . $separated[0];
288  $output .= ", " . $lng->txt("identifier") . ": " . $separated[1];
289  $output .= ", " . $lng->txt("value") . ": " . $separated[2];
290 
291  switch ($num) {
292  case 1:
293  if (empty($separated[0])) {
294  $output .= "<br/>" . $lng->txt("err_no_param") . " " . $lng->txt("check_langfile");
295  } else {
296  $output .= "<br/>" . $lng->txt("err_1_param") . " " . $lng->txt("check_langfile");
297  }
298  break;
299 
300  case 2:
301  $output .= "<br/>" . $lng->txt("err_2_param") . " " . $lng->txt("check_langfile");
302  break;
303 
304  default:
305  $output .= "<br/>" . $lng->txt("err_over_3_param") . " " . $lng->txt("check_langfile");
306  break;
307  }
308  }
309  }
310 
311  if ($error) {
312  $output .= "<br/>" . $lng->txt("file_not_valid") . " " . $lng->txt("err_count_param");
313  } else {
314  $output .= "<br/>" . $lng->txt("file_valid");
315  }
316  } else {
317  $output .= "<br/>" . $lng->txt("file_not_valid") . " " . $lng->txt("err_wrong_header");
318  }
319  }
320  }
321 
322  $d->close();
323 
324  if (!$found) {
325  $output .= "<br/>" . $lng->txt("err_no_langfile_found");
326  }
327 
328  chdir($tmpPath);
329  return $output;
330  }
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Reload workbook from saved file
$key
Definition: croninfo.php:18
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
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:

◆ getLanguages()

ilObjLanguageFolder::getLanguages ( )

gather all information about available languages

This function builds an array with the following structure: $languages[lang_key][long][installed][update][info]

lang_key: string international language key (2 digits, i.e. de,en,dk...) long: string full language name in the chosen user language installed: boolean is the language installed (true) or not (false)? update: int contains the timestamp of last db-modification info: string optional information. valid is: 'notfound','new'

Returns
array $languages status information about available languages

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

References $d, $lang, $languages, ilObject\$lng, ilObject\_getObjectsByType(), addNewLanguages(), array, and removeLanguages().

98  {
99  global $lng;
100 
101  $lng->loadLanguageModule("meta");
102 
103  // set path to directory where lang-files reside
104  $d = dir($this->lang_path);
105  $tmpPath = getcwd();
106  chdir($this->lang_path);
107 
108  // get available lang-files
109  while ($entry = $d->read()) {
110  if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang$)~", $entry))) {
111  $lang_key = substr($entry, 6, 2);
112  $languages[$lang_key] = ""; // long names will be set in class Out
113  }
114  }
115 
116  // ensure that arrays are initiated when no lang file was found
117  if (!array($languages)) {
118  $language = array();
119  $tmp_array = array();
120  }
121 
122  $tmp_array = array_keys($languages);
123  $lang_keys = array();
124 
125  // now get languages from database
126  if ($lang_db = ilObject::_getObjectsByType("lng")) {
127  foreach ($lang_db as $lang) {
128  // set values
129  $lang_key = $lang["title"];
130  $languages[$lang_key] = $lang;
131  $lang_keys[] = $lang_key;
132 
133  // determine default language and language of current user
134  if ($lang_key == $this->lang_user) {
135  $languages[$lang_key]["status"] = "in_use";
136  }
137 
138  if ($lang_key == $this->lang_default) {
139  $languages[$lang_key]["status"] = "system_language";
140  }
141 
142  // check if files are missing
143  if ((count($tmp_array) > 0) && (!in_array($lang_key, $tmp_array))) {
144  $languages[$lang_key]["info"] = "file_not_found";
145  }
146  }
147  }
148 
149  // compute new languages
150  foreach ($languages as $lang_key => $lang_data) {
151  if (!in_array($lang_key, $lang_keys)) {
152  $languages[$lang_key] = array();
153  $languages[$lang_key]["info"] = "new_language";
154  //$languages[$lang_key]["desc"] = "not_installed";
155  }
156  }
157 
158  chdir($tmpPath);
159 
160  // Insert languages with files new found into table language
162 
163  // Remove from array & db languages which are not installed and no lang-files
165 
166  // setting language's full names
167  foreach ($languages as $lang_key => $lang_data) {
168  $languages[$lang_key]["name"] = $lng->txt("meta_l_" . $lang_key);
169  }
170 
171  $this->languages = $languages;
172 
173  return $this->languages;
174  }
addNewLanguages($a_languages)
add new languages
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
Create styles array
The data for the language used.
removeLanguages($a_languages)
remove languages which are not installed AND has no lang-file
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
+ Here is the call graph for this function:

◆ removeLanguages()

ilObjLanguageFolder::removeLanguages (   $a_languages)

remove languages which are not installed AND has no lang-file

This function removes only the entry in db-table 'languages' and in the array $languages. Does not uninstall a language (see: function flushLanguage())

public

Parameters
array$languages
Returns
array $languages updated status information about available languages

Definition at line 226 of file class.ilObjLanguageFolder.php.

References $ilDB, and $query.

Referenced by getLanguages().

227  {
228  global $ilDB;
229 
230  foreach ($a_languages as $lang_key => $lang_data) {
231  if ($lang_data["desc"] == "not_installed" && $lang_data["info"] == "file_not_found") {
232  // update languages array
233  unset($a_languages[$lang_key]);
234 
235  // update object_data table
236  $query = "DELETE FROM object_data " .
237  "WHERE type = " . $ilDB->quote("lng", "text") . " " .
238  "AND title = " . $ilDB->quote($lang_key, "text");
239  $ilDB->manipulate($query);
240  }
241  }
242 
243  return $a_languages;
244  }
$query
global $ilDB
+ Here is the caller graph for this function:

Field Documentation

◆ $lang_default

ilObjLanguageFolder::$lang_default

Definition at line 26 of file class.ilObjLanguageFolder.php.

◆ $lang_path

ilObjLanguageFolder::$lang_path

Definition at line 46 of file class.ilObjLanguageFolder.php.

◆ $lang_user

ilObjLanguageFolder::$lang_user

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

◆ $languages

ilObjLanguageFolder::$languages

Definition at line 61 of file class.ilObjLanguageFolder.php.

Referenced by getLanguages().

◆ $separator

ilObjLanguageFolder::$separator

Definition at line 53 of file class.ilObjLanguageFolder.php.


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