120 $this->separator = $lng->separator;
121 $this->comment_separator = $lng->comment_separator;
123 $this->lang_file = $a_file;
124 $this->lang_key = $a_key;
125 $this->scope = $a_scope;
133 $this->params[
"module"] =
"language file";
134 $this->params[
"modulegroup"] =
"language";
136 if ($this->scope ==
"local")
138 $this->params[
"based_on"] =
"";
142 $this->params[
"author"] =
"";
143 $this->params[
"version"] =
"";
146 $this->params[
"il_server"] = ILIAS_HTTP_PATH;
148 $this->params[
"created"] =
"";
149 $this->params[
"created_by"] =
"";
161 $this->params =
array();
162 $this->values =
array();
164 $this->error_message =
"";
166 $content =
file($this->lang_file);
169 foreach ($content as $line_num => $line)
174 $this->
header .= $line .
"\n";
177 if (trim($line) == $this->file_start)
185 $pos_par = strpos($line,
"* @");
187 if ($pos_par !==
false)
190 $pos_space = strpos($line,
" ", $pos_par);
191 $pos_tab = strpos($line,
"\t", $pos_par);
192 if ($pos_space !==
false and $pos_tab !==
false)
194 $pos_white = min($pos_space, $pos_tab);
196 elseif ($pos_space !==
false)
198 $pos_white = $pos_space;
200 elseif ($pos_tab !==
false)
202 $pos_white = $pos_tab;
210 $param = substr($line, $pos_par, $pos_white-$pos_par);
211 $value = trim(substr($line, $pos_white));
213 $this->params[$param] = $value;
221 $separated = explode($this->separator, trim($line));
224 if (count($separated) != 3)
226 $this->error_message =
227 $lng->txt(
"file_not_valid").
" " 228 .$lng->txt(
"err_in_line").
" ". $line_num .
". " 229 .$lng->txt(
"err_count_param");
234 $key = $separated[0].$this->separator.$separated[1];
235 $value = $separated[2];
238 $pos = strpos($value, $this->comment_separator);
242 = substr($value , $pos + strlen($this->comment_separator));
244 $value = substr($value , 0 , $pos);
246 $this->values[$key] = $value;
253 $this->error_message = $lng->txt(
"file_not_valid").
" ".$lng->txt(
"err_wrong_header");
267 public function write($a_header =
'')
269 $fp = fopen($this->lang_file,
"w");
270 fwrite($fp, $this->
build($a_header));
280 public function build($a_header =
'')
287 $content = $a_header;
292 $lng->loadLanguageModule(
'meta');
293 $lang_name = $lng->txtlng(
'meta',
'meta_l_'.$this->lang_key,
'en');
294 $this->params[
"module"] =
"language file ". $lang_name;
295 $this->params[
"created"] =
date(
'Y-m-d H:i:s');
296 $this->params[
"created_by"] = $ilUser->getFullname().
" <".$ilUser->getEmail().
">";
299 $tpl =
new ilTemplate(
"tpl.lang_file_header.html",
true,
true,
"Services/Language");
302 $tabs = ceil((20 - 3 - strlen($name)) / 4);
303 $tabs = $tabs > 0 ? $tabs : 1;
305 $tpl->setCurrentBlock(
'param');
306 $tpl->setVariable(
'PAR_NAME', $name);
307 $tpl->setVariable(
'PAR_SPACE', str_repeat(
"\t", $tabs));
308 $tpl->setVariable(
'PAR_VALUE', $value);
309 $tpl->parseCurrentBlock();
311 $txt_scope = $lng->txtlng(
'administration',
'language_scope_'.$this->scope,
'en');
312 $tpl->setVariable(
'SCOPE', $txt_scope);
314 $content =
$tpl->get();
318 $add_newline = (substr($content, strlen($content)-1, 1) !=
"\n");
321 foreach ($this->values as $key => $value)
331 $content .= $key . $this->separator . $value;
335 $content .= $this->comment_separator . $this->
comments[$key];
396 return $this->params[$a_name];
407 return $this->values[$a_module.$this->separator.$a_identifier];
418 return $this->
comments[$a_module.$this->separator.$a_identifier];
428 $this->params[$a_name] = $a_value;
437 public function setValue($a_module, $a_identifier, $a_value)
439 $this->values[$a_module.$this->separator.$a_identifier] = $a_value;
448 $this->values = $a_values;
467 public function setComment($a_module, $a_identifier, $a_value)
469 return $this->
comments[$a_module.$this->separator.$a_identifier] = $a_comment;
481 if (!isset(self::$global_file_objects[$a_lang_key]))
484 $lng->lang_path .
"/ilias_" . $a_lang_key .
".lang",
485 $a_lang_key,
'global');
486 $file_object->read();
488 self::$global_file_objects[$a_lang_key] = $file_object;
491 return self::$global_file_objects[$a_lang_key];
setAllComments($a_comments)
Set all comments.
setParam($a_name, $a_value)
Set a parameter.
getErrorMessage()
Get the error message of the last read/write operation.
getAllComments()
Get array of all comments.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
special template class to simplify handling of ITX/PEAR
getComment($a_module, $a_identifier)
Get a single comment.
Reload workbook from saved file
Add a drawing to the header
getParam($a_name)
Get a single parameter.
getAllParams()
Get array of all parameters.
Create styles array
The data for the language used.
write($a_header='')
Write a language file.
getHeader()
Get the header of the original file.
getValue($a_module, $a_identifier)
Get a single value.
build($a_header='')
Build and get the file content.
setAllValues($a_values)
Set all values.
__construct($a_file, $a_key="", $a_scope='global')
Constructor.
static $global_file_objects
Created global file objects.
setValue($a_module, $a_identifier, $a_value)
Set a single value.
getAllValues()
Get array of all values.
static _getGlobalLanguageFile($a_lang_key)
Read and get a global language file as a singleton object.
setComment($a_module, $a_identifier, $a_value)
Set a single comment.
read()
Read a language file.