ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 @access 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 @access 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 @access public More...
 
 setId ($a_id)
 set object id @access public More...
 
 setRefId ($a_id)
 set reference id @access public More...
 
 getRefId ()
 get reference id @access public More...
 
 getType ()
 get object type @access public More...
 
 setType ($a_type)
 set object type @access public More...
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 get object title @access public More...
 
 getUntranslatedTitle ()
 get untranslated object title @access 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...
 
 setOfflineStatus ($a_status)
 Set offline status. More...
 
 getOfflineStatus ()
 Get offline status. More...
 
 supportsOfflineHandling ()
 Check whether object supports offline handling. More...
 
 getOwner ()
 get object owner More...
 
 getOwnerName ()
 
 setOwner ($a_owner)
 set object owner More...
 
 getCreateDate ()
 get create date @access public More...
 
 getLastUpdateDate ()
 get last update date @access 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) @access 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 lookupOfflineStatus ($a_obj_id)
 Lookup offline status using objectDataCache. 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. 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@access public 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 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 @access public.

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

Reimplemented from ilObject.

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

70 {
71 global $DIC;
72 $lng = $DIC->language();
73
74 $this->type = "lngf";
75 parent::__construct($a_id, $a_call_by_reference);
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 }
global $DIC
Definition: saml.php:7

References $DIC, and ilObject\$lng.

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

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

Referenced by getLanguages().

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

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

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

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

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

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

+ 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())

@access public

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

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

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

References $DIC, $ilDB, and $query.

Referenced by getLanguages().

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