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();
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) {
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;
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;
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];
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.
if(!empty($this->data['faventry'])) $tabs
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.