51    public $text = array();
 
  102        $this->lang_key = ($a_lang_key) ? $a_lang_key : $this->lang_default;
 
  103        $this->lang_path = ILIAS_ABSOLUTE_PATH . 
"/lang";
 
  104        $this->cust_lang_path = ILIAS_ABSOLUTE_PATH . 
"/Customizing/global/lang";
 
  107        $txt = file($this->lang_path . 
"/setup_lang_sel_multi.lang");
 
  110        if (is_array(
$txt)) {
 
  112                if (
$row[0] != 
"#") {
 
  113                    $a = explode($this->separator, trim(
$row));
 
  114                    $this->text[trim($a[0])] = trim($a[1]);
 
  120        $txt = file($this->lang_path . 
"/setup_" . $this->lang_key . 
".lang");
 
  123        if (is_array(
$txt)) {
 
  125                if (
$row[0] != 
"#") {
 
  126                    $a = explode($this->separator, trim(
$row));
 
  127                    $this->text[trim($a[0])] = trim($a[1]);
 
  145    public function txt($a_topic)
 
  149        if (empty($a_topic)) {
 
  153        $translation = $this->text[$a_topic];
 
  156        $pos = strpos($translation, $this->comment_separator);
 
  158        if ($pos !== 
false) {
 
  160            $translation = substr($translation, 0, $pos);
 
  163        if ($translation == 
"") {
 
  164            $log->writeLanguageLog($a_topic, $this->lang_key);
 
  165            return "-" . $a_topic . 
"-";
 
  180        $d = dir($this->lang_path);
 
  182        chdir($this->lang_path);
 
  185        while ($entry = 
$d->read()) {
 
  186            if (is_file($entry) && (preg_match(
'/(^setup_.{2}\.lang$)/', $entry))) {
 
  207        if (empty($a_lang_keys)) {
 
  208            $a_lang_keys = array();
 
  211        if (empty($a_local_keys)) {
 
  212            $a_local_keys = array();
 
  224                if (in_array(
$lang_key, $a_local_keys)) {
 
  233                if (!array_key_exists(
$lang_key, $db_langs)) {
 
  234                    if (in_array(
$lang_key, $a_local_keys)) {
 
  235                        $itype = 
'installed_local';
 
  237                        $itype = 
'installed';
 
  239                    $lid = 
$ilDB->nextId(
"object_data");
 
  240                    $query = 
"INSERT INTO object_data " .
 
  241                            "(obj_id,type,title,description,owner,create_date,last_update) " .
 
  244                            $ilDB->quote($lid, 
"integer") . 
"," .
 
  245                            $ilDB->quote(
"lng", 
"text") . 
"," .
 
  247                            $ilDB->quote($itype, 
"text") . 
"," .
 
  248                            $ilDB->quote(
'-1', 
"integer") . 
"," .
 
  252                    $this->db->manipulate(
$query);
 
  259        foreach ($db_langs as 
$key => $val) {
 
  260            if (!in_array(
$key, $err_lang)) {
 
  261                if (in_array(
$key, $a_lang_keys)) {
 
  262                    if (in_array(
$key, $a_local_keys)) {
 
  263                        $ld = 
'installed_local';
 
  267                    $query = 
"UPDATE object_data SET " .
 
  268                            "description = " . 
$ilDB->quote(
$ld, 
"text") . 
", " .
 
  269                            "last_update = " . 
$ilDB->now() . 
" " .
 
  270                            "WHERE obj_id = " . 
$ilDB->quote($val[
"obj_id"], 
"integer") . 
" " .
 
  271                            "AND type = " . 
$ilDB->quote(
"lng", 
"text");
 
  276                    if (substr($val[
"status"], 0, 9) == 
"installed") {
 
  277                        $query = 
"UPDATE object_data SET " .
 
  278                                "description = " . 
$ilDB->quote(
"not_installed", 
"text") . 
", " .
 
  279                                "last_update = " . 
$ilDB->now() . 
" " .
 
  280                                "WHERE obj_id = " . 
$ilDB->quote($val[
"obj_id"], 
"integer") . 
" " .
 
  281                                "AND type = " . 
$ilDB->quote(
"lng", 
"text");
 
  288        return ($err_lang) ? $err_lang : 
true;
 
  304        $query = 
"SELECT * FROM object_data " .
 
  305                "WHERE type = " . 
$ilDB->quote(
"lng", 
"text") . 
" " .
 
  306                "AND " . 
$ilDB->like(
"description", 
"text", 
'installed%');
 
  310            $arr[] = 
$row->title;
 
  327        $query = 
"SELECT * FROM object_data " .
 
  328                "WHERE type = " . 
$ilDB->quote(
"lng", 
"text") . 
" " .
 
  329                "AND description = " . 
$ilDB->quote(
'installed_local', 
"text");
 
  333            $arr[] = 
$row->title;
 
  349        $query = 
"SELECT * FROM object_data " .
 
  350                "WHERE type = " . 
$ilDB->quote(
"lng", 
"text");
 
  354            $arr[
$row->title][
"obj_id"] = 
$row->obj_id;
 
  355            $arr[
$row->title][
"status"] = 
$row->description;
 
  374        if (!empty($scope)) {
 
  375            if ($scope == 
'global') {
 
  378                $scopeExtension = 
'.' . $scope;
 
  383        if ($scope == 
"local") {
 
  384            $path = $this->cust_lang_path;
 
  391        $lang_file = 
"ilias_" . $a_lang_key . 
".lang" . $scopeExtension;
 
  394        if (!is_file($lang_file)) {
 
  400        if (!$content = $this->
cut_header(file($lang_file))) {
 
  406        foreach ($content as 
$key => $val) {
 
  407            $separated = explode($this->separator, trim($val));
 
  408            $num = count($separated);
 
  434        foreach ($content as 
$key => $val) {
 
  435            if (trim($val) == 
"<!-- language file start -->") {
 
  436                return array_slice($content, 
$key + 1);
 
  455        if ($a_mode == 
'all') {
 
  456            $ilDB->manipulate(
"DELETE FROM lng_modules WHERE lang_key = " .
 
  457                $ilDB->quote($a_lang_key, 
"text"));
 
  470        if (!$a_keep_local_change) {
 
  471            $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = " .
 
  472                $ilDB->quote($a_lang_key, 
"text"));
 
  474            $ilDB->manipulate(
"DELETE FROM lng_data WHERE lang_key = " .
 
  475                $ilDB->quote($a_lang_key, 
"text") .
 
  476                " AND local_change IS NULL");
 
  491        if ($a_min_date == 
"") {
 
  492            $a_min_date = 
"1980-01-01 00:00:00";
 
  494        if ($a_max_date == 
"") {
 
  495            $a_max_date = 
"2200-01-01 00:00:00";
 
  499            "SELECT * FROM lng_data WHERE lang_key = %s " .
 
  500            "AND local_change >= %s AND local_change <= %s",
 
  501            $ilDB->quote($a_lang_key, 
"text"),
 
  502            $ilDB->quote($a_min_date, 
"timestamp"),
 
  503            $ilDB->quote($a_max_date, 
"timestamp")
 
  509            $changes[
$row[
"module"]][
$row[
"identifier"]] = 
$row[
"value"];
 
  527        $lang_array = array();
 
  529        if (!empty($scope)) {
 
  530            if ($scope == 
'global') {
 
  533                $scopeExtension = 
'.' . $scope;
 
  538        if ($scope == 
"local") {
 
  539            $path = $this->cust_lang_path;
 
  545        $lang_file = 
"ilias_" . 
$lang_key . 
".lang" . $scopeExtension;
 
  547        if (is_file($lang_file)) {
 
  549            $lang_array = array();
 
  550            $lang_array[
"common"] = array();
 
  553            if ($content = $this->
cut_header(file($lang_file))) {
 
  557                } elseif ($scope == 
'local') {
 
  561                    $change_date = date(
"Y-m-d H:i:s", time());
 
  562                    $min_date = date(
"Y-m-d H:i:s", filemtime($lang_file));
 
  566                foreach ($content as 
$key => $val) {
 
  572                    $separated = explode($this->separator, trim($val));
 
  575                    $pos = strpos($separated[2], $this->comment_separator);
 
  577                    if ($pos !== 
false) {
 
  579                        $separated[2] = substr($separated[2], 0, $pos);
 
  583                    $local_value = $local_changes[$separated[0]][$separated[1]];
 
  586                        if ($local_value != 
"" and $local_value != $separated[2]) {
 
  588                            $lang_array[$separated[0]][$separated[1]] = $local_value;
 
  599                            $lang_array[$separated[0]][$separated[1]] = $separated[2];
 
  601                    } elseif ($scope == 
'local') {
 
  602                        if ($local_value != 
"") {
 
  604                            $lang_array[$separated[0]][$separated[1]] = $local_value;
 
  614                            $lang_array[$separated[0]][$separated[1]] = $separated[2];
 
  620            foreach ($lang_array as 
$module => $lang_arr) {
 
  621                if ($scope == 
"local") {
 
  622                    $q = 
"SELECT * FROM lng_modules WHERE " .
 
  625                    $set = 
$ilDB->query($q);
 
  627                    $arr2 = unserialize(
$row[
"lang_array"]);
 
  628                    if (is_array($arr2)) {
 
  629                        $lang_arr = array_merge($arr2, $lang_arr);
 
  646        $ilDB->manipulate(sprintf(
 
  647            "DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
 
  648            $ilDB->quote($a_key, 
"text"),
 
  649            $ilDB->quote($a_module, 
"text")
 
  655        $ilDB->insert(
"lng_modules", array(
 
  656            "lang_key" => array(
"text", $a_key),
 
  657            "module" => array(
"text", $a_module),
 
  658            "lang_array" => array(
"clob", serialize($a_array))
 
  670        $a_local_change = 
null 
  674        $ilDB->manipulate(sprintf(
 
  675            "DELETE FROM lng_data WHERE module = %s AND " .
 
  676            "identifier = %s AND lang_key = %s",
 
  677            $ilDB->quote($a_module, 
"text"),
 
  678            $ilDB->quote($a_identifier, 
"text"),
 
  679            $ilDB->quote($a_lang_key, 
"text")
 
  684        $ilDB->manipulate(sprintf(
 
  685            "INSERT INTO lng_data " .
 
  686            "(module, identifier, lang_key, value, local_change) " .
 
  687            "VALUES (%s,%s,%s,%s,%s)",
 
  688            $ilDB->quote($a_module, 
"text"),
 
  689            $ilDB->quote($a_identifier, 
"text"),
 
  690            $ilDB->quote($a_lang_key, 
"text"),
 
  691            $ilDB->quote($a_value, 
"text"),
 
  692            $ilDB->quote($a_local_change, 
"timestamp")
 
  704        $a_local_change = 
null 
  708        $ilDB->manipulate(sprintf(
 
  710            "SET value = %s, local_change = %s " .
 
  711            "WHERE module = %s AND identifier = %s AND lang_key = %s ",
 
  712            $ilDB->quote($a_value, 
"text"),
 
  713            $ilDB->quote($a_local_change, 
"timestamp"),
 
  714            $ilDB->quote($a_module, 
"text"),
 
  715            $ilDB->quote($a_identifier, 
"text"),
 
  716            $ilDB->quote($a_lang_key, 
"text")
 
  727        $local_langs = array();
 
  728        if (is_dir($this->cust_lang_path)) {
 
  729            $d = dir($this->cust_lang_path);
 
  731            chdir($this->cust_lang_path);
 
  734            while ($entry = 
$d->read()) {
 
  735                if (is_file($entry) && (preg_match(
"~(^ilias_.{2}\.lang.local$)~", $entry))) {
 
  751        $d = dir($this->lang_path);
 
  753        chdir($this->lang_path);
 
  756        while ($entry = 
$d->read()) {
 
  757            if (is_file($entry) && (preg_match(
"~(^ilias_.{2}\.lang$)~", $entry))) {
 
  777        if (empty($a_db_handler) or !is_object($a_db_handler)) {
 
  781        $this->db = &$a_db_handler;
 
An exception for terminatinating execution or to throw for unit testing.
getInstalledLocalLanguages()
get already installed local languages (in db)
static updateLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
Update lang entry.
getAvailableLanguages()
get already registered languages (in db)
getLocalChanges($a_lang_key, $a_min_date="", $a_max_date="")
get locally changed language entries
static _deleteLangData($a_lang_key, $a_keep_local_change)
Delete languge data.
txt($a_topic)
gets the text for a given topic
static replaceLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
Replace lang entry.
static replaceLangModule($a_key, $a_module, $a_array)
Replace language module array.
flushLanguage($a_lang_key, $a_mode='all')
remove language data from database
getInstalledLanguages()
get already installed languages (in db)
insertLanguage($lang_key, $scope='')
insert language data from file in database
getLanguages()
get all setup languages in the system
checkLanguage($a_lang_key, $scope='')
validate the logical structure of a lang-file
__construct($a_lang_key)
Constructor read the single-language file and put this in an array text.
cut_header($content)
Remove *.lang header information from '$content'.
setDbHandler($a_db_handler)
set db handler object @string object db handler
getInstallableLanguages()
installLanguages($a_lang_keys, $a_local_keys)
install languages
getLocalLanguages()
Searches for the existence of *.lang.local files.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
if($modEnd===false) $module