117    public function __construct($a_file, $a_key = 
"", $a_scope = 
'global')
 
  122        $this->separator = 
$lng->separator;
 
  123        $this->comment_separator = 
$lng->comment_separator;
 
  125        $this->lang_file = $a_file;
 
  126        $this->lang_key = $a_key;
 
  127        $this->scope = $a_scope;
 
  135        $this->params[
"module"] = 
"language file";
 
  136        $this->params[
"modulegroup"] = 
"language";
 
  138        if ($this->scope == 
"local") {
 
  139            $this->params[
"based_on"] = 
"";
 
  141            $this->params[
"author"] = 
"";
 
  142            $this->params[
"version"] = 
"";
 
  145        $this->params[
"il_server"] = ILIAS_HTTP_PATH;
 
  147        $this->params[
"created"] = 
"";
 
  148        $this->params[
"created_by"] = 
"";
 
  161        $this->params = array();
 
  162        $this->values = array();
 
  163        $this->comments = array();
 
  164        $this->error_message = 
"";
 
  166        $content = file($this->lang_file);
 
  169        foreach ($content as $line_num => $line) {
 
  172                $this->header .= $line . 
"\n";
 
  175                if (trim($line) == $this->file_start) {
 
  180                    $pos_par = strpos($line, 
"* @");
 
  182                    if ($pos_par !== 
false) {
 
  184                        $pos_space = strpos($line, 
" ", $pos_par);
 
  185                        $pos_tab = strpos($line, 
"\t", $pos_par);
 
  186                        if ($pos_space !== 
false and $pos_tab !== 
false) {
 
  187                            $pos_white = min($pos_space, $pos_tab);
 
  188                        } elseif ($pos_space !== 
false) {
 
  189                            $pos_white = $pos_space;
 
  190                        } elseif ($pos_tab !== 
false) {
 
  191                            $pos_white = $pos_tab;
 
  196                            $param = substr($line, $pos_par, $pos_white - $pos_par);
 
  197                            $value = trim(substr($line, $pos_white));
 
  199                            $this->params[$param] = $value;
 
  205                $separated = explode($this->separator, trim($line));
 
  208                if (count($separated) != 3) {
 
  209                    $this->error_message =
 
  210                            $lng->txt(
"file_not_valid") . 
" " 
  211                            . 
$lng->txt(
"err_in_line") . 
" " . $line_num . 
". " 
  212                            . 
$lng->txt(
"err_count_param");
 
  215                    $key = $separated[0] . $this->separator . $separated[1];
 
  216                    $value = $separated[2];
 
  219                    $pos = strpos($value, $this->comment_separator);
 
  220                    if ($pos !== 
false) {
 
  221                        $this->comments[
$key]
 
  222                            = substr($value, $pos + strlen($this->comment_separator));
 
  224                        $value = substr($value, 0, $pos);
 
  226                    $this->values[
$key] = $value;
 
  232            $this->error_message = 
$lng->txt(
"file_not_valid") . 
" " . 
$lng->txt(
"err_wrong_header");
 
  244    public function write($a_header = 
'')
 
  246        $fp = fopen($this->lang_file, 
"w");
 
  247        fwrite($fp, $this->
build($a_header));
 
  257    public function build($a_header = 
'')
 
  265            $content = $a_header;
 
  268            $lng->loadLanguageModule(
'meta');
 
  269            $lang_name = 
$lng->txtlng(
'meta', 
'meta_l_' . $this->lang_key, 
'en');
 
  270            $this->params[
"module"] = 
"language file " . $lang_name;
 
  271            $this->params[
"created"] = date(
'Y-m-d H:i:s');
 
  272            $this->params[
"created_by"] = 
$ilUser->getFullname() . 
" <" . 
$ilUser->getEmail() . 
">";
 
  275            $tpl = 
new ilTemplate(
"tpl.lang_file_header.html", 
true, 
true, 
"Services/Language");
 
  280                $tpl->setCurrentBlock(
'param');
 
  282                $tpl->setVariable(
'PAR_SPACE', str_repeat(
"\t", 
$tabs));
 
  283                $tpl->setVariable(
'PAR_VALUE', $value);
 
  284                $tpl->parseCurrentBlock();
 
  286            $txt_scope = 
$lng->txtlng(
'administration', 
'language_scope_' . $this->scope, 
'en');
 
  287            $tpl->setVariable(
'SCOPE', $txt_scope);
 
  289            $content = 
$tpl->get();
 
  293        $add_newline = (substr($content, strlen($content) - 1, 1) != 
"\n");
 
  296        foreach ($this->values as 
$key => $value) {
 
  304            $content .= 
$key . $this->separator . $value;
 
  306            if ($this->comments[
$key]) {
 
  307                $content .= $this->comment_separator . $this->comments[
$key];
 
  368        return $this->params[$a_name];
 
  379        return $this->values[$a_module . $this->separator . $a_identifier];
 
  390        return $this->comments[$a_module . $this->separator . $a_identifier];
 
  400        $this->params[$a_name] = $a_value;
 
  409    public function setValue($a_module, $a_identifier, $a_value)
 
  411        $this->values[$a_module . $this->separator . $a_identifier] = $a_value;
 
  420        $this->values = $a_values;
 
  429        $this->comments = $a_comments;
 
  439    public function setComment($a_module, $a_identifier, $a_value)
 
  441        return $this->comments[$a_module . $this->separator . $a_identifier] = $a_comment;
 
  454        if (!isset(self::$global_file_objects[$a_lang_key])) {
 
  456                $lng->lang_path . 
"/ilias_" . $a_lang_key . 
".lang",
 
  460            $file_object->read();
 
  462            self::$global_file_objects[$a_lang_key] = $file_object;
 
  465        return self::$global_file_objects[$a_lang_key];
 
An exception for terminatinating execution or to throw for unit testing.
getAllParams()
Get array of all parameters.
setComment($a_module, $a_identifier, $a_value)
Set a single comment.
getComment($a_module, $a_identifier)
Get a single comment.
__construct($a_file, $a_key="", $a_scope='global')
Constructor.
getAllComments()
Get array of all comments.
getAllValues()
Get array of all values.
getValue($a_module, $a_identifier)
Get a single value.
static _getGlobalLanguageFile($a_lang_key)
Read and get a global language file as a singleton object.
read()
Read a language file.
setParam($a_name, $a_value)
Set a parameter.
getHeader()
Get the header of the original file.
setAllValues($a_values)
Set all values.
build($a_header='')
Build and get the file content.
static $global_file_objects
Created global file objects array.
getErrorMessage()
Get the error message of the last read/write operation.
write($a_header='')
Write a language file.
setValue($a_module, $a_identifier, $a_value)
Set a single value.
getParam($a_name)
Get a single parameter.
setAllComments($a_comments)
Set all comments.
special template class to simplify handling of ITX/PEAR
if(!empty($this->data['faventry'])) $tabs