Fixed $lng in ConfigParser
Signed-off-by: Florian Aders (EleRas) <eleras@froxlor.org>
This commit is contained in:
@@ -285,11 +285,16 @@ class ConfigDaemon {
|
|||||||
$content = preg_replace_callback('/\{\{(.*)\}\}/Ui', function ($matches) {
|
$content = preg_replace_callback('/\{\{(.*)\}\}/Ui', function ($matches) {
|
||||||
if (preg_match('/^settings\.(.*)$/', $matches[1], $match)) {
|
if (preg_match('/^settings\.(.*)$/', $matches[1], $match)) {
|
||||||
return Settings::Get($match[1]);
|
return Settings::Get($match[1]);
|
||||||
} elseif (preg_match('/^lng\.(.*)$/', $matches[1], $match)) {
|
} elseif (preg_match('/^lng\.(.*)(?:\.(.*)(?:\.(.*)))$/U', $matches[1], $match)) {
|
||||||
$lngvar = str_replace('.', '"]["', $match[1]);
|
global $lng;
|
||||||
$lngvar = str_replace('lng"]', 'lng', $lngvar);
|
if (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '' && isset($match[3]) && $match[3] != '') {
|
||||||
$lngvar .= '"]';
|
return $lng[$match[1]][$match[2]][$match[3]];
|
||||||
return ${$lngvar};
|
} elseif (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '') {
|
||||||
|
return $lng[$match[1]][$match[2]];
|
||||||
|
} elseif (isset($match[1]) && $match[1] != '') {
|
||||||
|
return $lng[$match[1]];
|
||||||
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}, $content);
|
}, $content);
|
||||||
return $content;
|
return $content;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class ConfigService {
|
|||||||
$service = $this->fullxml->xpath($this->xpath);
|
$service = $this->fullxml->xpath($this->xpath);
|
||||||
$attributes = $service[0]->attributes();
|
$attributes = $service[0]->attributes();
|
||||||
if ($attributes['title'] != '') {
|
if ($attributes['title'] != '') {
|
||||||
$this->title = (string)$attributes['title'];
|
$this->title = $this->_parseContent((string)$attributes['title']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +115,30 @@ class ConfigService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace placeholders with content
|
||||||
|
* @param string $content
|
||||||
|
* @return string $content w/o placeholder
|
||||||
|
*/
|
||||||
|
private function _parseContent($content) {
|
||||||
|
$content = preg_replace_callback('/\{\{(.*)\}\}/Ui', function ($matches) {
|
||||||
|
if (preg_match('/^settings\.(.*)$/', $matches[1], $match)) {
|
||||||
|
return Settings::Get($match[1]);
|
||||||
|
} elseif (preg_match('/^lng\.(.*)(?:\.(.*)(?:\.(.*)))$/U', $matches[1], $match)) {
|
||||||
|
global $lng;
|
||||||
|
if (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '' && isset($match[3]) && $match[3] != '') {
|
||||||
|
return $lng[$match[1]][$match[2]][$match[3]];
|
||||||
|
} elseif (isset($match[1]) && $match[1] != '' && isset($match[2]) && $match[2] != '') {
|
||||||
|
return $lng[$match[1]][$match[2]];
|
||||||
|
} elseif (isset($match[1]) && $match[1] != '') {
|
||||||
|
return $lng[$match[1]];
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}, $content);
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDaemons() {
|
public function getDaemons() {
|
||||||
$this->_parse();
|
$this->_parse();
|
||||||
return $this->daemons;
|
return $this->daemons;
|
||||||
|
|||||||
Reference in New Issue
Block a user