117 public function __construct($a_file, $a_key =
"", $a_scope =
'global')
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") {
137 $this->params[
"based_on"] =
"";
139 $this->params[
"author"] =
"";
140 $this->params[
"version"] =
"";
143 $this->params[
"il_server"] = ILIAS_HTTP_PATH;
145 $this->params[
"created"] =
"";
146 $this->params[
"created_by"] =
"";
158 $this->params = array();
159 $this->values = array();
160 $this->comments = array();
161 $this->error_message =
"";
163 $content = file($this->lang_file);
166 foreach ($content as $line_num => $line) {
169 $this->header .= $line .
"\n";
172 if (trim($line) == $this->file_start) {
177 $pos_par = strpos($line,
"* @");
179 if ($pos_par !==
false) {
181 $pos_space = strpos($line,
" ", $pos_par);
182 $pos_tab = strpos($line,
"\t", $pos_par);
183 if ($pos_space !==
false and $pos_tab !==
false) {
184 $pos_white = min($pos_space, $pos_tab);
185 } elseif ($pos_space !==
false) {
186 $pos_white = $pos_space;
187 } elseif ($pos_tab !==
false) {
188 $pos_white = $pos_tab;
193 $param = substr($line, $pos_par, $pos_white-$pos_par);
194 $value = trim(substr($line, $pos_white));
196 $this->params[$param] = $value;
202 $separated = explode($this->separator, trim($line));
205 if (count($separated) != 3) {
206 $this->error_message =
207 $lng->txt(
"file_not_valid") .
" "
208 .
$lng->txt(
"err_in_line") .
" " . $line_num .
". "
209 .
$lng->txt(
"err_count_param");
212 $key = $separated[0] . $this->separator . $separated[1];
213 $value = $separated[2];
216 $pos = strpos($value, $this->comment_separator);
217 if ($pos !==
false) {
218 $this->comments[
$key]
219 = substr($value, $pos + strlen($this->comment_separator));
221 $value = substr($value, 0, $pos);
223 $this->values[
$key] = $value;
229 $this->error_message =
$lng->txt(
"file_not_valid") .
" " .
$lng->txt(
"err_wrong_header");
241 public function write($a_header =
'')
243 $fp = fopen($this->lang_file,
"w");
244 fwrite($fp, $this->
build($a_header));
254 public function build($a_header =
'')
260 $content = $a_header;
263 $lng->loadLanguageModule(
'meta');
264 $lang_name =
$lng->txtlng(
'meta',
'meta_l_' . $this->lang_key,
'en');
265 $this->params[
"module"] =
"language file " . $lang_name;
266 $this->params[
"created"] =
date(
'Y-m-d H:i:s');
267 $this->params[
"created_by"] =
$ilUser->getFullname() .
" <" .
$ilUser->getEmail() .
">";
270 $tpl =
new ilTemplate(
"tpl.lang_file_header.html",
true,
true,
"Services/Language");
275 $tpl->setCurrentBlock(
'param');
277 $tpl->setVariable(
'PAR_SPACE', str_repeat(
"\t",
$tabs));
278 $tpl->setVariable(
'PAR_VALUE', $value);
279 $tpl->parseCurrentBlock();
281 $txt_scope =
$lng->txtlng(
'administration',
'language_scope_' . $this->scope,
'en');
282 $tpl->setVariable(
'SCOPE', $txt_scope);
284 $content =
$tpl->get();
288 $add_newline = (substr($content, strlen($content)-1, 1) !=
"\n");
291 foreach ($this->values as
$key => $value) {
299 $content .=
$key . $this->separator . $value;
301 if ($this->comments[
$key]) {
302 $content .= $this->comment_separator . $this->comments[
$key];
363 return $this->params[$a_name];
374 return $this->values[$a_module . $this->separator . $a_identifier];
385 return $this->comments[$a_module . $this->separator . $a_identifier];
395 $this->params[$a_name] = $a_value;
404 public function setValue($a_module, $a_identifier, $a_value)
406 $this->values[$a_module . $this->separator . $a_identifier] = $a_value;
415 $this->values = $a_values;
424 $this->comments = $a_comments;
434 public function setComment($a_module, $a_identifier, $a_value)
436 return $this->comments[$a_module . $this->separator . $a_identifier] = $a_comment;
448 if (!isset(self::$global_file_objects[$a_lang_key])) {
450 $lng->lang_path .
"/ilias_" . $a_lang_key .
".lang",
454 $file_object->read();
456 self::$global_file_objects[$a_lang_key] = $file_object;
459 return self::$global_file_objects[$a_lang_key];
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
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