ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public More...
 
 applyDidacticTemplate ($a_tpl_id)
 Apply template. More...
 
 setRegisterMode ($a_bool)
 
 isUserRegistered ($a_user_id=0)
 
 requireRegistration ()
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ... More...
 
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies. More...
 
 cloneMetaData ($target_obj)
 Copy meta data. More...
 
 getPossibleSubObjects ($a_filter=true)
 get all possible subobjects of this type the object can decide which types of subobjects are possible jut in time overwrite if the decision distinguish from standard model More...
 

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
 
 $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
 

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...
 

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 196 of file class.ilObjLanguageFolder.php.

References array.

Referenced by getLanguages().

197  {
198  if (count($a_languages) > 0)
199  {
200  foreach ($a_languages as $lang_key => $lang_data)
201  {
202  if ($lang_data["info"] == "new_language")
203  {
204  include_once("./Services/Language/classes/class.ilObjLanguage.php");
205  $lngObj = new ilObjLanguage();
206  $lngObj->setTitle($lang_key);
207  $lngObj->setDescription("not_installed");
208  $lngObj->create();
209 
210  // must get OOP through the whole class some time
211  // (no arrays with db fields! this class doesn't know anything about table object!)
212  $a_languages[$lang_key] = array("obj_id" => $lngObj->getId(),
213  "type" => $lngObj->getType(),
214  "description" => $lngObj->getDescription(),
215  "desc" => $lngObj->getDescription(),
216  "owner" => $lngObj->getOwner(),
217  "create_date" => $lngObj->getCreateDate(),
218  "last_update" => $lngObj->getLastUpdateDate());
219 
220  $a_languages[$lang_key]["info"] = "new_language";
221  unset($lngObj); // better: the objects should be resident in an member array of this class
222  }
223  }
224  }
225 
226  return $a_languages;
227  }
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 269 of file class.ilObjLanguageFolder.php.

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

270  {
271  // TODO: lng object should not be used in this class
272  global $lng;
273 
274  // set path to directory where lang-files reside
275  $d = dir($this->lang_path);
276  $tmpPath = getcwd();
277  chdir ($this->lang_path);
278 
279  // for giving a message when no lang-file was found
280  $found = false;
281 
282  // get available lang-files
283  while ($entry = $d->read())
284  {
285  if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang$)~", $entry)))
286  {
287  // textmeldung, wenn langfile gefunden wurde
288  $output .= "<br/><br/>".$lng->txt("langfile_found").": ".$entry;
289  $content = file ($entry);
290 
291  $found = true;
292  $error = false;
293 
294  if ($content = ilObjLanguage::cut_header($content))
295  {
296  foreach ($content as $key => $val)
297  {
298  $separated = explode ($this->separator,trim($val));
299  $num = count($separated);
300 
301  if ($num != 3)
302  {
303  $error = true;
304  $line = $key + 37;
305 
306  $output .= "<br/><b/>".$lng->txt("err_in_line")." ".$line." !</b>&nbsp;&nbsp;";
307  $output .= $lng->txt("module").": ".$separated[0];
308  $output .= ", ".$lng->txt("identifier").": ".$separated[1];
309  $output .= ", ".$lng->txt("value").": ".$separated[2];
310 
311  switch ($num)
312  {
313  case 1:
314  if (empty($separated[0]))
315  {
316  $output .= "<br/>".$lng->txt("err_no_param")." ".$lng->txt("check_langfile");
317  }
318  else
319  {
320  $output .= "<br/>".$lng->txt("err_1_param")." ".$lng->txt("check_langfile");
321  }
322  break;
323 
324  case 2:
325  $output .= "<br/>".$lng->txt("err_2_param")." ".$lng->txt("check_langfile");
326  break;
327 
328  default:
329  $output .= "<br/>".$lng->txt("err_over_3_param")." ".$lng->txt("check_langfile");
330  break;
331  }
332  }
333  }
334 
335  if ($error) {
336  $output .= "<br/>".$lng->txt("file_not_valid")." ".$lng->txt("err_count_param");
337  }
338  else {
339  $output .= "<br/>".$lng->txt("file_valid");
340  }
341  }
342  else {
343  $output .= "<br/>".$lng->txt("file_not_valid")." ".$lng->txt("err_wrong_header");
344  }
345  }
346  }
347 
348  $d->close();
349 
350  if (!$found) {
351  $output .= "<br/>".$lng->txt("err_no_langfile_found");
352  }
353 
354  chdir($tmpPath);
355  return $output;
356  }
$error
Definition: Error.php:17
for($col=0; $col< 50; $col++) $d
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Reload workbook from saved file
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  {
111  if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang$)~", $entry)))
112  {
113  $lang_key = substr($entry,6,2);
114  $languages[$lang_key] = ""; // long names will be set in class Out
115  }
116  }
117 
118  // ensure that arrays are initiated when no lang file was found
119  if (!array($languages))
120  {
121  $language = array();
122  $tmp_array = array();
123  }
124 
125  $tmp_array = array_keys($languages);
126  $lang_keys = array();
127 
128  // now get languages from database
129  if ($lang_db = ilObject::_getObjectsByType("lng"))
130  {
131  foreach ($lang_db as $lang)
132  {
133  // set values
134  $lang_key = $lang["title"];
135  $languages[$lang_key] = $lang;
136  $lang_keys[] = $lang_key;
137 
138  // determine default language and language of current user
139  if ($lang_key == $this->lang_user)
140  {
141  $languages[$lang_key]["status"] = "in_use";
142  }
143 
144  if ($lang_key == $this->lang_default)
145  {
146  $languages[$lang_key]["status"] = "system_language";
147  }
148 
149  // check if files are missing
150  if ((count($tmp_array) > 0) && (!in_array($lang_key,$tmp_array)))
151  {
152  $languages[$lang_key]["info"] = "file_not_found";
153  }
154  }
155  }
156 
157  // compute new languages
158  foreach ($languages as $lang_key => $lang_data)
159  {
160  if (!in_array($lang_key,$lang_keys))
161  {
162  $languages[$lang_key]["info"] = "new_language";
163  //$languages[$lang_key]["desc"] = "not_installed";
164  }
165  }
166 
167  chdir($tmpPath);
168 
169  // Insert languages with files new found into table language
171 
172  // Remove from array & db languages which are not installed and no lang-files
174 
175  // setting language's full names
176  foreach ($languages as $lang_key => $lang_data)
177  {
178  $languages[$lang_key]["name"] = $lng->txt("meta_l_".$lang_key);
179  }
180 
181  $this->languages = $languages;
182 
183  return $this->languages;
184  }
addNewLanguages($a_languages)
add new languages
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
for($col=0; $col< 50; $col++) $d
Create styles array
The data for the language used.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
removeLanguages($a_languages)
remove languages which are not installed AND has no lang-file
+ 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 239 of file class.ilObjLanguageFolder.php.

References $ilDB, and $query.

Referenced by getLanguages().

240  {
241  global $ilDB;
242 
243  foreach ($a_languages as $lang_key => $lang_data)
244  {
245  if ($lang_data["desc"] == "not_installed" && $lang_data["info"] == "file_not_found")
246  {
247  // update languages array
248  unset($a_languages[$lang_key]);
249 
250  // update object_data table
251  $query = "DELETE FROM object_data ".
252  "WHERE type = ".$ilDB->quote("lng", "text")." ".
253  "AND title = ".$ilDB->quote($lang_key, "text");
254  $ilDB->manipulate($query);
255  }
256  }
257 
258  return $a_languages;
259  }
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: