ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilSetupLanguage Class Reference

language handling for setup More...

+ Inheritance diagram for ilSetupLanguage:
+ Collaboration diagram for ilSetupLanguage:

Public Member Functions

 __construct ($a_lang_key)
 Constructor read the single-language file and put this in an array text. More...
 
 txt ($a_topic, $a_default_lang_fallback_mod='')
 gets the text for a given topic More...
 
 getLanguages ()
 get all setup languages in the system More...
 
 installLanguages ($a_lang_keys, $a_local_keys)
 install languages More...
 
 getInstalledLanguages ()
 get already installed languages (in db) More...
 
 getInstalledLocalLanguages ()
 get already installed local languages (in db) More...
 
 getLocalLanguages ()
 Searches for the existence of *.lang.local files. More...
 
 getInstallableLanguages ()
 
 setDbHandler ($a_db_handler)
 set db handler object @string object db handler More...
 
 loadLanguageModule ($a_module)
 
- Public Member Functions inherited from ilLanguage
 __construct ($a_lang_key)
 Constructor read the single-language file and put this in an array text. More...
 
 getLangKey ()
 
 getDefaultLanguage ()
 
 txtlng ($a_module, $a_topic, $a_language)
 gets the text for a given topic in a given language if the topic is not in the list, the topic itself with "-" will be returned More...
 
 txt ($a_topic, $a_default_lang_fallback_mod="")
 gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be returned More...
 
 exists ($a_topic)
 Check if language entry exists. More...
 
 loadLanguageModule ($a_module)
 
 getInstalledLanguages ()
 
 getUsedTopics ()
 
 getUsedModules ()
 
 getUserLanguage ()
 
 toJS ($a_lang_key, ilGlobalTemplateInterface $a_tpl=null)
 
 toJSMap ($a_map, ilGlobalTemplateInterface $a_tpl=null)
 Transfer text to Javascript. More...
 
 __destruct ()
 destructor saves all language usages to db if log is enabled and ilDB exists More...
 

Static Public Member Functions

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)
 Replace lang entry. More...
 
static updateLangEntry ( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
 Update lang entry. More...
 
- Static Public Member Functions inherited from ilLanguage
static _getInstalledLanguages ()
 
static _lookupEntry ($a_lang_key, $a_mod, $a_id)
 
static lookupId ($a_lang_key)
 Lookup obj_id of language @global ilDB $ilDB. More...
 
static getFallbackInstance ()
 Builds a global default language instance. More...
 
static getGlobalInstance ()
 Builds the global language object. More...
 

Data Fields

 $text = array()
 
 $lang_default = "en"
 
 $lang_path
 
 $lang_key
 
 $separator = "#:#"
 
 $comment_separator = "###"
 
- Data Fields inherited from ilLanguage
 $ilias
 
 $text
 
 $lang_default
 
 $lang_user
 
 $lang_path
 
 $lang_key
 
 $lang_name
 
 $separator = "#:#"
 
 $comment_separator = "###"
 
 $loaded_modules
 

Protected Member Functions

 getAvailableLanguages ()
 get already registered languages (in db) More...
 
 checkLanguage ($a_lang_key, $scope='')
 validate the logical structure of a lang-file More...
 
 cut_header ($content)
 Remove *.lang header information from '$content'. More...
 
 flushLanguage ($a_lang_key, $a_mode='all')
 remove language data from database More...
 
 getLocalChanges ($a_lang_key, $a_min_date="", $a_max_date="")
 get locally changed language entries More...
 
 insertLanguage ($lang_key, $scope='')
 insert language data from file in database More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from ilLanguage
static logUsage ($a_module, $a_identifier)
 saves tupel of language module and identifier More...
 
static isUsageLogEnabled ()
 checks if language usage log is enabled you need MySQL to use this function this function is automatically enabled if DEVMODE is on this function is also enabled if language_log is 1 More...
 
- Protected Attributes inherited from ilLanguage
 $cached_modules = array()
 
 $map_modules_txt = array()
 
 $usage_log_enabled = false
 
- Static Protected Attributes inherited from ilLanguage
static $used_topics = array()
 
static $used_modules = array()
 
static $lng_log = array()
 

Detailed Description

language handling for setup

this class offers the language handling for an application. the constructor is called with a small language abbreviation e.g. $lng = new Language("en"); the constructor reads the single-languagefile en.lang and puts this into an array. with e.g. $lng->txt("user_updated"); you can translate a lang-topic into the actual language

Author
Peter Gabriel pgabr.nosp@m.iel@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$
Todo:

The DATE field is not set correctly on changes of a language (update, install, your stable). The format functions do not belong in class.Language. Those are also applicable elsewhere. Therefore, they would be better placed in class.Format

This somehow needs to be reconciled with the base class and most probably be factored into two classes, one for management, one for retrieval.

Definition at line 47 of file class.ilSetupLanguage.php.

Constructor & Destructor Documentation

◆ __construct()

ilSetupLanguage::__construct (   $a_lang_key)

Constructor read the single-language file and put this in an array text.

the text array is two-dimensional. First dimension is the language. Second dimension is the languagetopic. Content is the translation. @access public

Parameters
stringlanguagecode (two characters), e.g. "de", "en", "in"
Returns
boolean false if reading failed

Reimplemented from ilLanguage.

Definition at line 103 of file class.ilSetupLanguage.php.

104 {
105 $this->lang_key = ($a_lang_key) ? $a_lang_key : $this->lang_default;
106
107 $il_absolute_path = realpath(dirname(__FILE__) . '/../../../../');
108 $this->lang_path = $il_absolute_path . "/lang";
109 $this->cust_lang_path = $il_absolute_path . "/Customizing/global/lang";
110
111 // set lang file...
112 $txt = file($this->lang_path . "/setup_lang_sel_multi.lang");
113
114 // ...and load langdata
115 if (is_array($txt)) {
116 foreach ($txt as $row) {
117 if ($row[0] != "#") {
118 $a = explode($this->separator, trim($row));
119 if (count($a) == 2) {
120 $this->text[trim($a[0])] = trim($a[1]);
121 }
122 }
123 }
124 }
125
126 // set lang file...
127 $txt = file($this->lang_path . "/setup_" . $this->lang_key . ".lang");
128
129 // ...and load langdata
130 if (is_array($txt)) {
131 foreach ($txt as $row) {
132 if ($row[0] != "#") {
133 $a = explode($this->separator, trim($row));
134 if (count($a) == 2) {
135 $this->text[trim($a[0])] = trim($a[1]);
136 }
137 }
138 }
139
140 return true;
141 }
142
143 return false;
144 }
$txt
Definition: error.php:13
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, and $txt.

Member Function Documentation

◆ _deleteLangData()

static ilSetupLanguage::_deleteLangData (   $a_lang_key,
  $a_keep_local_change 
)
static

Delete languge data.

Parameters
stringlang key

Definition at line 476 of file class.ilSetupLanguage.php.

477 {
478 global $ilDB;
479
480 if (!$a_keep_local_change) {
481 $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
482 $ilDB->quote($a_lang_key, "text"));
483 } else {
484 $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
485 $ilDB->quote($a_lang_key, "text") .
486 " AND local_change IS NULL");
487 }
488 }
global $ilDB

References $ilDB.

Referenced by flushLanguage().

+ Here is the caller graph for this function:

◆ checkLanguage()

ilSetupLanguage::checkLanguage (   $a_lang_key,
  $scope = '' 
)
protected

validate the logical structure of a lang-file

This function checks if a lang-file of a given lang_key exists, the file has a header, and each lang-entry consists of exactly three elements (module, identifier, value).

Parameters
string$a_lang_keyinternational language key (2 digits)
string$scopeempty (global) or "local"
Returns
string $info_text message about results of check OR "1" if all checks successfully passed

Definition at line 381 of file class.ilSetupLanguage.php.

382 {
383 $scopeExtension = "";
384 if (!empty($scope)) {
385 if ($scope == 'global') {
386 $scope = '';
387 } else {
388 $scopeExtension = '.' . $scope;
389 }
390 }
391
392 $path = $this->lang_path;
393 if ($scope == "local") {
394 $path = $this->cust_lang_path;
395 }
396
397 $tmpPath = getcwd();
398 chdir($path);
399
400 // compute lang-file name format
401 $lang_file = "ilias_" . $a_lang_key . ".lang" . $scopeExtension;
402
403 // file check
404 if (!is_file($lang_file)) {
405 chdir($tmpPath);
406 return false;
407 }
408
409 // header check
410 if (!$content = $this->cut_header(file($lang_file))) {
411 chdir($tmpPath);
412 return false;
413 }
414
415 // check (counting) elements of each lang-entry
416 foreach ($content as $key => $val) {
417 $separated = explode($this->separator, trim($val));
418 $num = count($separated);
419
420 if ($num != 3) {
421 chdir($tmpPath);
422 return false;
423 }
424 }
425
426 chdir($tmpPath);
427
428 // no error occured
429 return true;
430 }
cut_header($content)
Remove *.lang header information from '$content'.

References $lang_path, and cut_header().

Referenced by installLanguages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cut_header()

ilSetupLanguage::cut_header (   $content)
protected

Remove *.lang header 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$contentexpect an ILIAS lang-file
Returns
string $content content without header info OR false if no valid header was found @access private

Definition at line 442 of file class.ilSetupLanguage.php.

443 {
444 foreach ($content as $key => $val) {
445 if (trim($val) == "<!-- language file start -->") {
446 return array_slice($content, $key + 1);
447 }
448 }
449
450 return false;
451 }

Referenced by checkLanguage(), and insertLanguage().

+ Here is the caller graph for this function:

◆ flushLanguage()

ilSetupLanguage::flushLanguage (   $a_lang_key,
  $a_mode = 'all' 
)
protected

remove language data from database

Parameters
stringlanguage key
string"all" or "keep_local"

Definition at line 459 of file class.ilSetupLanguage.php.

460 {
461 $ilDB = $this->db;
462
463 ilSetupLanguage::_deleteLangData($a_lang_key, ($a_mode == 'keep_local'));
464
465 if ($a_mode == 'all') {
466 $ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = " .
467 $ilDB->quote($a_lang_key, "text"));
468 }
469 }
static _deleteLangData($a_lang_key, $a_keep_local_change)
Delete languge data.

References $ilDB, and _deleteLangData().

Referenced by installLanguages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableLanguages()

ilSetupLanguage::getAvailableLanguages ( )
protected

get already registered languages (in db)

Returns
array array with information about languages that has been registered in db

Definition at line 352 of file class.ilSetupLanguage.php.

353 {
354 global $ilDB;
355
356 $arr = array();
357
358 $query = "SELECT * FROM object_data " .
359 "WHERE type = " . $ilDB->quote("lng", "text");
360 $r = $ilDB->query($query);
361
362 while ($row = $ilDB->fetchObject($r)) {
363 $arr[$row->title]["obj_id"] = $row->obj_id;
364 $arr[$row->title]["status"] = $row->description;
365 }
366
367 return $arr;
368 }
$query

References $ilDB, and $query.

Referenced by installLanguages().

+ Here is the caller graph for this function:

◆ getInstallableLanguages()

ilSetupLanguage::getInstallableLanguages ( )

Definition at line 762 of file class.ilSetupLanguage.php.

763 {
764 $setup_langs = $this->getLanguages();
765
766 $d = dir($this->lang_path);
767 $tmpPath = getcwd();
768 chdir($this->lang_path);
769
770 // get available lang-files
771 while ($entry = $d->read()) {
772 if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang$)~", $entry))) {
773 $lang_key = substr($entry, 6, 2);
774 $languages1[] = $lang_key;
775 }
776 }
777
778 //$languages = array_intersect($languages1,$setup_langs);
779
780 chdir($tmpPath);
781
782 return $languages1;
783 }
getLanguages()
get all setup languages in the system
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296

References $d, $lang_key, and getLanguages().

+ Here is the call graph for this function:

◆ getInstalledLanguages()

ilSetupLanguage::getInstalledLanguages ( )

get already installed languages (in db)

Returns
array array with inforamtion about each installed language

Reimplemented from ilLanguage.

Definition at line 307 of file class.ilSetupLanguage.php.

308 {
309 global $ilDB;
310
311 $arr = array();
312
313 $query = "SELECT * FROM object_data " .
314 "WHERE type = " . $ilDB->quote("lng", "text") . " " .
315 "AND " . $ilDB->like("description", "text", 'installed%');
316 $r = $ilDB->query($query);
317
318 while ($row = $ilDB->fetchObject($r)) {
319 $arr[] = $row->title;
320 }
321
322 return $arr;
323 }

References $ilDB, and $query.

◆ getInstalledLocalLanguages()

ilSetupLanguage::getInstalledLocalLanguages ( )

get already installed local languages (in db)

Returns
array array with inforamtion about each installed language

Definition at line 330 of file class.ilSetupLanguage.php.

331 {
332 global $ilDB;
333
334 $arr = array();
335
336 $query = "SELECT * FROM object_data " .
337 "WHERE type = " . $ilDB->quote("lng", "text") . " " .
338 "AND description = " . $ilDB->quote('installed_local', "text");
339 $r = $ilDB->query($query);
340
341 while ($row = $ilDB->fetchObject($r)) {
342 $arr[] = $row->title;
343 }
344
345 return $arr;
346 }

References $ilDB, and $query.

◆ getLanguages()

ilSetupLanguage::getLanguages ( )

get all setup languages in the system

the functions looks for setup*.lang-files in the languagedirectory @access public

Returns
array langs

Definition at line 187 of file class.ilSetupLanguage.php.

188 {
189 $d = dir($this->lang_path);
190 $tmpPath = getcwd();
191 chdir($this->lang_path);
192
193 // get available setup-files
194 while ($entry = $d->read()) {
195 if (is_file($entry) && (preg_match('/(^setup_.{2}\.lang$)/', $entry))) {
196 $lang_key = substr($entry, 6, 2);
197 $languages[] = $lang_key;
198 }
199 }
200
201 chdir($tmpPath);
202
203 return $languages;
204 }

References $d, and $lang_key.

Referenced by getInstallableLanguages().

+ Here is the caller graph for this function:

◆ getLocalChanges()

ilSetupLanguage::getLocalChanges (   $a_lang_key,
  $a_min_date = "",
  $a_max_date = "" 
)
protected

get locally changed language entries

Parameters
stringlanguage key
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 497 of file class.ilSetupLanguage.php.

498 {
499 $ilDB = $this->db;
500
501 if ($a_min_date == "") {
502 $a_min_date = "1980-01-01 00:00:00";
503 }
504 if ($a_max_date == "") {
505 $a_max_date = "2200-01-01 00:00:00";
506 }
507
508 $q = sprintf(
509 "SELECT * FROM lng_data WHERE lang_key = %s " .
510 "AND local_change >= %s AND local_change <= %s",
511 $ilDB->quote($a_lang_key, "text"),
512 $ilDB->quote($a_min_date, "timestamp"),
513 $ilDB->quote($a_max_date, "timestamp")
514 );
515 $result = $ilDB->query($q);
516
517 $changes = array();
518 while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
519 $changes[$row["module"]][$row["identifier"]] = $row["value"];
520 }
521 return $changes;
522 }
$result

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

Referenced by insertLanguage().

+ Here is the caller graph for this function:

◆ getLocalLanguages()

ilSetupLanguage::getLocalLanguages ( )

Searches for the existence of *.lang.local files.

return $local_langs array of language keys

Definition at line 740 of file class.ilSetupLanguage.php.

741 {
742 $local_langs = array();
743 if (is_dir($this->cust_lang_path)) {
744 $d = dir($this->cust_lang_path);
745 $tmpPath = getcwd();
746 chdir($this->cust_lang_path);
747
748 // get available .lang.local files
749 while ($entry = $d->read()) {
750 if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang.local$)~", $entry))) {
751 $lang_key = substr($entry, 6, 2);
752 $local_langs[] = $lang_key;
753 }
754 }
755
756 chdir($tmpPath);
757 }
758
759 return $local_langs;
760 }

References $d, and $lang_key.

◆ insertLanguage()

ilSetupLanguage::insertLanguage (   $lang_key,
  $scope = '' 
)
protected

insert language data from file in database

Parameters
string$lang_keyinternational language key (2 digits)
string$scopeempty (global) or "local"
Returns
void

Definition at line 533 of file class.ilSetupLanguage.php.

534 {
535 $ilDB = &$this->db;
536
537 $lang_array = array();
538
539 $scopeExtension = "";
540 if (!empty($scope)) {
541 if ($scope == 'global') {
542 $scope = '';
543 } else {
544 $scopeExtension = '.' . $scope;
545 }
546 }
547
548 $path = $this->lang_path;
549 if ($scope == "local") {
550 $path = $this->cust_lang_path;
551 }
552
553 $tmpPath = getcwd();
554 chdir($path);
555
556 $lang_file = "ilias_" . $lang_key . ".lang" . $scopeExtension;
557
558 if (is_file($lang_file)) {
559 // initialize the array for updating lng_modules below
560 $lang_array = array();
561 $lang_array["common"] = array();
562
563 // remove header first
564 if ($content = $this->cut_header(file($lang_file))) {
565 // get the local changes from the database
566 if (empty($scope)) {
567 $local_changes = $this->getLocalChanges($lang_key);
568 } elseif ($scope == 'local') {
569 // set the change date to import time for a local file
570 // get the modification date of the local file
571 // get the newer local changes for a local file
572 $change_date = date("Y-m-d H:i:s", time());
573 $min_date = date("Y-m-d H:i:s", filemtime($lang_file));
574 $local_changes = $this->getLocalChanges($lang_key, $min_date);
575 }
576
577 foreach ($content as $key => $val) {
578 // split the line of the language file
579 // [0]: module
580 // [1]: identifier
581 // [2]: value
582 // [3]: comment (optional)
583 $separated = explode($this->separator, trim($val));
584
585 //get position of the comment_separator
586 $pos = strpos($separated[2], $this->comment_separator);
587
588 if ($pos !== false) {
589 //cut comment of
590 $separated[2] = substr($separated[2], 0, $pos);
591 }
592
593 // check if the value has a local change
594 if (isset($local_changes[$separated[0]])) {
595 $local_value = $local_changes[$separated[0]][$separated[1]];
596 } else {
597 $local_value = null;
598 }
599
600 if (empty($scope)) {
601 if ($local_value != "" and $local_value != $separated[2]) {
602 // keep the locally changed value
603 $lang_array[$separated[0]][$separated[1]] = $local_value;
604 } else {
605 // insert a new value if no local value exists
606 // reset local_change if the values are equal
608 $separated[0],
609 $separated[1],
610 $lang_key,
611 $separated[2]
612 );
613
614 $lang_array[$separated[0]][$separated[1]] = $separated[2];
615 }
616 } elseif ($scope == 'local') {
617 if ($local_value != "") {
618 // keep a locally changed value that is newer than the local file
619 $lang_array[$separated[0]][$separated[1]] = $local_value;
620 } else {
621 // UPDATE because the global values have already been INSERTed
623 $separated[0],
624 $separated[1],
625 $lang_key,
626 $separated[2],
627 $change_date
628 );
629 $lang_array[$separated[0]][$separated[1]] = $separated[2];
630 }
631 }
632 }
633 }
634
635 foreach ($lang_array as $module => $lang_arr) {
636 if ($scope == "local") {
637 $q = "SELECT * FROM lng_modules WHERE " .
638 " lang_key = " . $ilDB->quote($lang_key, "text") .
639 " AND module = " . $ilDB->quote($module, "text");
640 $set = $ilDB->query($q);
641 $row = $ilDB->fetchAssoc($set);
642 $arr2 = unserialize($row["lang_array"]);
643 if (is_array($arr2)) {
644 $lang_arr = array_merge($arr2, $lang_arr);
645 }
646 }
648 }
649 }
650
651 chdir($tmpPath);
652 }
static replaceLangModule($a_key, $a_module, $a_array)
Replace language module array.
static updateLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
Update lang entry.
getLocalChanges($a_lang_key, $a_min_date="", $a_max_date="")
get locally changed language entries
static replaceLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
Replace lang entry.

References $ilDB, $lang_key, $lang_path, cut_header(), getLocalChanges(), replaceLangEntry(), replaceLangModule(), and updateLangEntry().

Referenced by installLanguages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ installLanguages()

ilSetupLanguage::installLanguages (   $a_lang_keys,
  $a_local_keys 
)

install languages

Parameters
arrayarray with lang_keys of languages to install
Returns
boolean true on success

Definition at line 212 of file class.ilSetupLanguage.php.

213 {
214 global $ilDB;
215
216 if (empty($a_lang_keys)) {
217 $a_lang_keys = array();
218 }
219
220 if (empty($a_local_keys)) {
221 $a_local_keys = array();
222 }
223
224 $err_lang = array();
225
226 $db_langs = $this->getAvailableLanguages();
227
228 foreach ($a_lang_keys as $lang_key) {
229 if ($this->checkLanguage($lang_key)) {
230 $this->flushLanguage($lang_key, 'keep_local');
231 $this->insertLanguage($lang_key);
232
233 if (in_array($lang_key, $a_local_keys) && is_dir($this->cust_lang_path)) {
234 if ($this->checkLanguage($lang_key, "local")) {
235 $this->insertLanguage($lang_key, "local");
236 } else {
237 $err_lang[] = $lang_key;
238 }
239 }
240
241 // register language first time install
242 if (!array_key_exists($lang_key, $db_langs)) {
243 if (in_array($lang_key, $a_local_keys)) {
244 $itype = 'installed_local';
245 } else {
246 $itype = 'installed';
247 }
248 $lid = $ilDB->nextId("object_data");
249 $query = "INSERT INTO object_data " .
250 "(obj_id,type,title,description,owner,create_date,last_update) " .
251 "VALUES " .
252 "(" .
253 $ilDB->quote($lid, "integer") . "," .
254 $ilDB->quote("lng", "text") . "," .
255 $ilDB->quote($lang_key, "text") . "," .
256 $ilDB->quote($itype, "text") . "," .
257 $ilDB->quote('-1', "integer") . "," .
258 $ilDB->now() . "," .
259 $ilDB->now() .
260 ")";
261 $this->db->manipulate($query);
262 }
263 } else {
264 $err_lang[] = $lang_key;
265 }
266 }
267
268 foreach ($db_langs as $key => $val) {
269 if (!in_array($key, $err_lang)) {
270 if (in_array($key, $a_lang_keys)) {
271 if (in_array($key, $a_local_keys)) {
272 $ld = 'installed_local';
273 } else {
274 $ld = 'installed';
275 }
276 $query = "UPDATE object_data SET " .
277 "description = " . $ilDB->quote($ld, "text") . ", " .
278 "last_update = " . $ilDB->now() . " " .
279 "WHERE obj_id = " . $ilDB->quote($val["obj_id"], "integer") . " " .
280 "AND type = " . $ilDB->quote("lng", "text");
281 $ilDB->manipulate($query);
282 } else {
283 $this->flushLanguage($key, "all");
284
285 if (substr($val["status"], 0, 9) == "installed") {
286 $query = "UPDATE object_data SET " .
287 "description = " . $ilDB->quote("not_installed", "text") . ", " .
288 "last_update = " . $ilDB->now() . " " .
289 "WHERE obj_id = " . $ilDB->quote($val["obj_id"], "integer") . " " .
290 "AND type = " . $ilDB->quote("lng", "text");
291 $ilDB->manipulate($query);
292 }
293 }
294 }
295 }
296
297 return ($err_lang) ? $err_lang : true;
298 }
flushLanguage($a_lang_key, $a_mode='all')
remove language data from database
insertLanguage($lang_key, $scope='')
insert language data from file in database
getAvailableLanguages()
get already registered languages (in db)
checkLanguage($a_lang_key, $scope='')
validate the logical structure of a lang-file

References $ilDB, $lang_key, $query, checkLanguage(), flushLanguage(), getAvailableLanguages(), and insertLanguage().

+ Here is the call graph for this function:

◆ loadLanguageModule()

ilSetupLanguage::loadLanguageModule (   $a_module)

Reimplemented from ilLanguage.

Definition at line 801 of file class.ilSetupLanguage.php.

802 {
803 }

◆ replaceLangEntry()

static ilSetupLanguage::replaceLangEntry (   $a_module,
  $a_identifier,
  $a_lang_key,
  $a_value,
  $a_local_change = null 
)
staticfinal

Replace lang entry.

Definition at line 680 of file class.ilSetupLanguage.php.

686 {
687 global $ilDB;
688
689 $ilDB->manipulate(sprintf(
690 "DELETE FROM lng_data WHERE module = %s AND " .
691 "identifier = %s AND lang_key = %s",
692 $ilDB->quote($a_module, "text"),
693 $ilDB->quote($a_identifier, "text"),
694 $ilDB->quote($a_lang_key, "text")
695 ));
696
697 // insert a new value if no local value exists
698 // reset local_change if the values are equal
699 $ilDB->manipulate(sprintf(
700 "INSERT INTO lng_data " .
701 "(module, identifier, lang_key, value, local_change) " .
702 "VALUES (%s,%s,%s,%s,%s)",
703 $ilDB->quote($a_module, "text"),
704 $ilDB->quote($a_identifier, "text"),
705 $ilDB->quote($a_lang_key, "text"),
706 $ilDB->quote($a_value, "text"),
707 $ilDB->quote($a_local_change, "timestamp")
708 ));
709 }

References $ilDB.

Referenced by insertLanguage().

+ Here is the caller graph for this function:

◆ replaceLangModule()

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

Replace language module array.

Definition at line 657 of file class.ilSetupLanguage.php.

658 {
659 global $ilDB;
660
661 $ilDB->manipulate(sprintf(
662 "DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
663 $ilDB->quote($a_key, "text"),
664 $ilDB->quote($a_module, "text")
665 ));
666 /*$ilDB->manipulate(sprintf("INSERT INTO lng_modules (lang_key, module, lang_array) VALUES ".
667 "(%s,%s,%s)", $ilDB->quote($a_key, "text"),
668 $ilDB->quote($a_module, "text"),
669 $ilDB->quote(serialize($a_array), "clob")));*/
670 $ilDB->insert("lng_modules", array(
671 "lang_key" => array("text", $a_key),
672 "module" => array("text", $a_module),
673 "lang_array" => array("clob", serialize($a_array))
674 ));
675 }

References $ilDB.

Referenced by insertLanguage().

+ Here is the caller graph for this function:

◆ setDbHandler()

ilSetupLanguage::setDbHandler (   $a_db_handler)

set db handler object @string object db handler

Returns
boolean true on success

Definition at line 790 of file class.ilSetupLanguage.php.

791 {
792 if (empty($a_db_handler) or !is_object($a_db_handler)) {
793 return false;
794 }
795
796 $this->db = &$a_db_handler;
797
798 return true;
799 }

◆ txt()

ilSetupLanguage::txt (   $a_topic,
  $a_default_lang_fallback_mod = '' 
)

gets the text for a given topic

if the topic is not in the list, the topic itself with "-" will be returned @access public

Parameters
stringtopic
Returns
string text clear-text

Reimplemented from ilLanguage.

Definition at line 154 of file class.ilSetupLanguage.php.

155 {
156 global $log;
157
158 if (empty($a_topic)) {
159 return "";
160 }
161
162 $translation = $this->text[$a_topic];
163
164 //get position of the comment_separator
165 $pos = strpos($translation, $this->comment_separator);
166
167 if ($pos !== false) {
168 // remove comment
169 $translation = substr($translation, 0, $pos);
170 }
171
172 if ($translation == "") {
173 $log->writeLanguageLog($a_topic, $this->lang_key);
174 return "-" . $a_topic . "-";
175 } else {
176 return $translation;
177 }
178 }
$log
Definition: result.php:15

References $log.

◆ updateLangEntry()

static ilSetupLanguage::updateLangEntry (   $a_module,
  $a_identifier,
  $a_lang_key,
  $a_value,
  $a_local_change = null 
)
staticfinal

Update lang entry.

Definition at line 714 of file class.ilSetupLanguage.php.

720 {
721 global $ilDB;
722
723 $ilDB->manipulate(sprintf(
724 "UPDATE lng_data " .
725 "SET value = %s, local_change = %s " .
726 "WHERE module = %s AND identifier = %s AND lang_key = %s ",
727 $ilDB->quote($a_value, "text"),
728 $ilDB->quote($a_local_change, "timestamp"),
729 $ilDB->quote($a_module, "text"),
730 $ilDB->quote($a_identifier, "text"),
731 $ilDB->quote($a_lang_key, "text")
732 ));
733 }

References $ilDB.

Referenced by insertLanguage().

+ Here is the caller graph for this function:

Field Documentation

◆ $comment_separator

ilSetupLanguage::$comment_separator = "###"

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

◆ $lang_default

ilSetupLanguage::$lang_default = "en"

Definition at line 62 of file class.ilSetupLanguage.php.

◆ $lang_key

ilSetupLanguage::$lang_key

◆ $lang_path

ilSetupLanguage::$lang_path

Definition at line 71 of file class.ilSetupLanguage.php.

Referenced by checkLanguage(), and insertLanguage().

◆ $separator

ilSetupLanguage::$separator = "#:#"

Definition at line 85 of file class.ilSetupLanguage.php.

◆ $text

ilSetupLanguage::$text = array()

Definition at line 54 of file class.ilSetupLanguage.php.


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