Inheritance diagram for ilObjLanguage:
Collaboration diagram for ilObjLanguage:Public Member Functions | |
| ilObjLanguage ($a_id=0, $a_call_by_reference=false) | |
| Constructor public. | |
| getKey () | |
| get language key | |
| getStatus () | |
| get language status | |
| isSystemLanguage () | |
| check if language is system language | |
| isUserLanguage () | |
| check if language is system language | |
| install () | |
| install current language | |
| uninstall () | |
| uninstall current language | |
| flush () | |
| remove language data from database | |
| insert () | |
| insert language data from file into database | |
| resetUserLanguage ($lang_key) | |
| search ILIAS for users which have selected '$lang_key' as their prefered language and reset them to default language (english). | |
| cut_header ($content) | |
| remove lang-file haeder information from '$content' | |
| optimizeData () | |
| optimizes the db-table langdata | |
| check () | |
| validate the logical structure the lang file | |
Data Fields | |
| $separator | |
| $comment_separator | |
| $lang_default | |
| $lang_user | |
| $lang_path | |
| $key | |
| $status | |
Definition at line 37 of file class.ilObjLanguage.php.
| ilObjLanguage::check | ( | ) |
validate the logical structure the lang file
This function checks if a lang-file exists, the file has a header and each lang-entry consist of exact three elements (module,identifier,value)
Definition at line 291 of file class.ilObjLanguage.php.
References $key, $num, and cut_header().
Referenced by install().
{
$tmpPath = getcwd();
chdir ($this->lang_path);
// compute lang-file name format
$lang_file = "ilias_".$this->key.".lang";
// file check
if (!is_file($lang_file))
{
$this->ilias->raiseError("File not found: ".$lang_file,$this->ilias->error_obj->MESSAGE);
}
// header check
if (!$content = $this->cut_header(file($lang_file)))
{
$this->ilias->raiseError("Wrong Header in ".$lang_file,$this->ilias->error_obj->MESSAGE);
}
// check (counting) elements of each lang-entry
foreach ($content as $key => $val)
{
$separated = explode ($this->separator,trim($val));
$num = count($separated);
if ($num != 3)
{
$this->ilias->raiseError("Wrong parameter count in ".$lang_file."! Please check your language file!",$this->ilias->error_obj->MESSAGE);
}
}
chdir($tmpPath);
// no error occured
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| 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
| string | $content expecting an ILIAS lang-file |
Definition at line 255 of file class.ilObjLanguage.php.
References $key.
Referenced by check(), ilObjLanguageFolder::checkAllLanguages(), and insert().
{
foreach ($content as $key => $val)
{
if (trim($val) == "<!-- language file start -->")
{
return array_slice($content,$key +1);
}
}
return false;
}
Here is the caller graph for this function:| ilObjLanguage::flush | ( | ) |
remove language data from database
Definition at line 176 of file class.ilObjLanguage.php.
References $query.
Referenced by install(), and uninstall().
{
$query = "DELETE FROM lng_data WHERE lang_key='".$this->key."'";
$this->ilias->db->query($query);
}
Here is the caller graph for this function:| ilObjLanguage::getKey | ( | ) |
get language key
Definition at line 84 of file class.ilObjLanguage.php.
Referenced by install().
{
return $this->key;
}
Here is the caller graph for this function:| ilObjLanguage::getStatus | ( | ) |
get language status
Definition at line 94 of file class.ilObjLanguage.php.
Referenced by install().
{
return $this->status;
}
Here is the caller graph for this function:| ilObjLanguage::ilObjLanguage | ( | $ | a_id = 0, |
|
| $ | a_call_by_reference = false | |||
| ) |
Constructor public.
| integer | reference_id or object_id | |
| boolean | treat the id as reference_id (true) or object_id (false) |
Definition at line 62 of file class.ilObjLanguage.php.
References ilObject::$lng, and ilObject::ilObject().
{
global $lng;
$this->type = "lng";
$this->ilObject($a_id,$a_call_by_reference);
$this->type = "lng";
$this->key = $this->title;
$this->status = $this->desc;
$this->lang_default = $lng->lang_default;
$this->lang_user = $lng->lang_user;
$this->lang_path = $lng->lang_path;
$this->separator = $lng->separator;
$this->comment_separator = $lng->comment_separator;
}
Here is the call graph for this function:| ilObjLanguage::insert | ( | ) |
insert language data from file into database
Definition at line 186 of file class.ilObjLanguage.php.
References $key, $num, $pos, $query, and cut_header().
Referenced by install().
{
$tmpPath = getcwd();
chdir($this->lang_path);
$lang_file = "ilias_".$this->key.".lang";
if ($lang_file)
{
// remove header first
if ($content = $this->cut_header(file($lang_file)))
{
foreach ($content as $key => $val)
{
$separated = explode ($this->separator,trim($val));
//get position of the comment_separator
$pos = strpos($separated[2], $this->comment_separator);
if ($pos !== false)
{
//cut comment of
$separated[2] = substr($separated[2] , 0 , $pos);
}
$num = count($separated);
$query = "INSERT INTO lng_data ".
"(module,identifier,lang_key,value) ".
"VALUES ".
"('".$separated[0]."','".$separated[1]."','".$this->key."','".addslashes($separated[2])."')";
$this->ilias->db->query($query);
}
$query = "UPDATE object_data SET ".
"last_update = now() ".
"WHERE title = '".$this->key."' ".
"AND type = 'lng'";
$this->ilias->db->query($query);
}
}
chdir($tmpPath);
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjLanguage::install | ( | ) |
install current language
Definition at line 131 of file class.ilObjLanguage.php.
References check(), flush(), getKey(), getStatus(), insert(), optimizeData(), ilObject::setDescription(), and ilObject::update().
{
if ($this->getStatus() != "installed")
{
if ($this->check())
{
// lang-file is ok. Flush data in db and...
$this->flush();
// ...re-insert data from lang-file
$this->insert();
// update information in db-table about available/installed languages
$this->setDescription("installed");
$this->update();
$this->optimizeData();
return $this->getKey();
}
}
return "";
}
Here is the call graph for this function:| ilObjLanguage::isSystemLanguage | ( | ) |
check if language is system language
Definition at line 102 of file class.ilObjLanguage.php.
{
if ($this->key == $this->lang_default)
return true;
else
return false;
}
| ilObjLanguage::isUserLanguage | ( | ) |
check if language is system language
Definition at line 113 of file class.ilObjLanguage.php.
{
if ($this->key == $this->lang_user)
{
return true;
}
else
{
return false;
}
}
| ilObjLanguage::optimizeData | ( | ) |
| 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
| string | $lang_key international language key (2 digits) |
Definition at line 237 of file class.ilObjLanguage.php.
References $q.
Referenced by uninstall().
{
$q = "UPDATE usr_pref SET ".
"value = '".$this->lang_default."' ".
"WHERE keyword = 'language' ".
"AND value = '".$lang_key."'";
$this->ilias->db->query($q);
}
Here is the caller graph for this function:| ilObjLanguage::uninstall | ( | ) |
uninstall current language
Definition at line 157 of file class.ilObjLanguage.php.
References flush(), resetUserLanguage(), ilObject::setDescription(), ilObject::setTitle(), and ilObject::update().
{
if (($this->status == "installed") && ($this->key != $this->lang_default) && ($this->key != $this->lang_user))
{
$this->flush();
$this->setTitle($this->key);
$this->setDescription("not_installed");
$this->update();
$this->resetUserLanguage($this->key);
return $this->key;
}
return "";
}
Here is the call graph for this function:| ilObjLanguage::$comment_separator |
Definition at line 47 of file class.ilObjLanguage.php.
| ilObjLanguage::$key |
Definition at line 52 of file class.ilObjLanguage.php.
Referenced by check(), cut_header(), and insert().
| ilObjLanguage::$lang_default |
Definition at line 48 of file class.ilObjLanguage.php.
| ilObjLanguage::$lang_path |
Definition at line 50 of file class.ilObjLanguage.php.
| ilObjLanguage::$lang_user |
Definition at line 49 of file class.ilObjLanguage.php.
| ilObjLanguage::$separator |
Definition at line 46 of file class.ilObjLanguage.php.
| ilObjLanguage::$status |
Definition at line 53 of file class.ilObjLanguage.php.
1.7.1