Reducing path repetition

This commit is contained in:
Dennis Eichhorn 2015-12-28 21:27:41 +01:00
parent 75622e46f7
commit a042552878
3 changed files with 9 additions and 9 deletions

View File

@ -133,12 +133,12 @@ abstract class ModuleAbstract
$lang = []; $lang = [];
if (isset(static::$localization[$destination])) { if (isset(static::$localization[$destination])) {
foreach (static::$localization[$destination] as $file) { foreach (static::$localization[$destination] as $file) {
if(($path = $path = realpath(__DIR__ . '/../../Modules/' . static::$module . '/Theme/lang/' . $file . '.' . $language . '.lang.php')) === false) { if(($path = realpath($oldPath = __DIR__ . '/../../Modules/' . static::$module . '/Theme/lang/' . $file . '.' . $language . '.lang.php')) === false) {
throw new FilePathException(__DIR__ . '/../../Modules/' . static::$module . '/Theme/lang/' . $file . '.' . $language . '.lang.php'); throw new FilePathException($oldPath);
} }
/** @noinspection PhpIncludeInspection */ /** @noinspection PhpIncludeInspection */
include realpath(__DIR__ . '/../../Modules/' . static::$module . '/Theme/lang/' . $file . '.' . $language . '.lang.php'); include realpath($path);
/** @var array $MODLANG */ /** @var array $MODLANG */
$lang += $MODLANG; $lang += $MODLANG;
} }

View File

@ -246,11 +246,11 @@ class ModuleManager
$c = count($files); $c = count($files);
for ($i = 0; $i < $c; $i++) { for ($i = 0; $i < $c; $i++) {
$path = realpath(self::MODULE_PATH . '/' . $files[$i] . '/info.json'); $path = realpath($oldPath = self::MODULE_PATH . '/' . $files[$i] . '/info.json');
if (file_exists($path)) { if (file_exists($path)) {
if(strpos($path, self::MODULE_PATH) === false) { if(strpos($path, self::MODULE_PATH) === false) {
throw new FilePathException(self::MODULE_PATH . '/' . $files[$i] . '/info.json'); throw new FilePathException($oldPath);
} }
$json = json_decode(file_get_contents($path), true); $json = json_decode(file_get_contents($path), true);
@ -296,11 +296,11 @@ class ModuleManager
// todo download; // todo download;
} }
$path = realpath(self::MODULE_PATH . '/' . $module . '/' . 'info.json'); $path = realpath($oldPath = self::MODULE_PATH . '/' . $module . '/' . 'info.json');
if ($path !== false) { if ($path !== false) {
if(strpos($path, self::MODULE_PATH) === false) { if(strpos($path, self::MODULE_PATH) === false) {
throw new FilePathException(self::MODULE_PATH . '/' . $module . '/' . 'info.json'); throw new FilePathException($oldPath);
} }
$info = json_decode(file_get_contents($path), true); $info = json_decode(file_get_contents($path), true);

View File

@ -279,10 +279,10 @@ class View implements RenderableInterface
public function render() : \string public function render() : \string
{ {
$this->l11n->setLang($this->app->l11nManager->getLanguage($this->response->getL11n()->getLanguage())); $this->l11n->setLang($this->app->l11nManager->getLanguage($this->response->getL11n()->getLanguage()));
$path = realpath(__DIR__ . '/../..' . $this->template . '.tpl.php'); $path = realpath($oldPath = __DIR__ . '/../..' . $this->template . '.tpl.php');
if (strpos($path, ROOT_PATH) === false) { if (strpos($path, ROOT_PATH) === false) {
throw new FilePathException(__DIR__ . '/../..' . $this->template . '.tpl.php'); throw new FilePathException($oldPath);
} }
ob_start(); ob_start();