mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-13 15:18:41 +00:00
Reducing path repetition
This commit is contained in:
parent
75622e46f7
commit
a042552878
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user