remove webinterface

This commit is contained in:
Dennis Eichhorn 2020-11-25 01:00:27 +01:00
parent ba7737d0ad
commit b57e6ca305
5 changed files with 71 additions and 59 deletions

View File

@ -90,12 +90,9 @@ final class L11nManager
throw new \UnexpectedValueException($from);
}
if (!isset($this->language[$language][$from])) {
$this->language[$language][$from] = $translation[$from];
} else {
/** @noinspection PhpWrongStringConcatenationInspection */
$this->language[$language][$from] = $translation[$from] + $this->language[$language][$from];
}
$this->language[$language][$from] = !isset($this->language[$language][$from])
? $translation[$from]
: $translation[$from] + $this->language[$language][$from];
}
/**
@ -114,12 +111,12 @@ final class L11nManager
*/
public function loadLanguageFromFile(string $language, string $from, string $file) : void
{
$lang = [];
if (\is_file($file)) {
/** @noinspection PhpIncludeInspection */
$lang = include $file;
if (!\is_file($file)) {
return;
}
/** @noinspection PhpIncludeInspection */
$lang = include $file;
$this->loadLanguage($language, $from, $lang);
}
@ -159,33 +156,31 @@ final class L11nManager
*/
public function getText(string $code, string $module, string $theme, $translation, string $app = null) : string
{
if (!isset($this->language[$code][$module][$translation])) {
try {
/** @var ModuleAbstract $class */
$class = '\Modules\\' . $module . '\\Controller\\' . ($app ?? $this->appName) . 'Controller';
/** @var string $class */
if (!Autoloader::exists($class)) {
return 'ERROR';
}
$this->loadLanguage($code, $module, $class::getLocalization($code, $theme));
if (!isset($this->language[$code][$module][$translation])) {
return 'ERROR';
}
} catch (\Throwable $e) {
// @codeCoverageIgnoreStart
FileLogger::getInstance()->warning(FileLogger::MSG_FULL, [
'message' => 'Undefined translation for \'' . $code . '/' . $module . '/' . $translation . '\'.',
]);
return 'ERROR';
// @codeCoverageIgnoreEnd
}
if (isset($this->language[$code][$module][$translation])) {
return $this->language[$code][$module][$translation];
}
return $this->language[$code][$module][$translation];
try {
/** @var ModuleAbstract $class */
$class = '\Modules\\' . $module . '\\Controller\\' . ($app ?? $this->appName) . 'Controller';
/** @var string $class */
if (!Autoloader::exists($class)) {
return 'ERROR';
}
$this->loadLanguage($code, $module, $class::getLocalization($code, $theme));
} catch (\Throwable $e) {
// @codeCoverageIgnoreStart
FileLogger::getInstance()->warning(FileLogger::MSG_FULL, [
'message' => 'Undefined translation for \'' . $code . '/' . $module . '/' . $translation . '\'.',
]);
// @codeCoverageIgnoreEnd
}
return isset($this->language[$code][$module][$translation])
? $this->language[$code][$module][$translation]
: 'ERROR';
}
/**
@ -278,7 +273,13 @@ final class L11nManager
}
}
$money = new Money((int) ($currency / $divide), $l11n->getThousands(), $l11n->getDecimal(), $symbol ?? $l11n->getCurrency(), (int) $l11n->getCurrencyFormat());
$money = new Money(
(int) ($currency / $divide),
$l11n->getThousands(),
$l11n->getDecimal(),
$symbol ?? $l11n->getCurrency(),
(int) $l11n->getCurrencyFormat()
);
return $money->getCurrency($l11n->getPrecision()[$format ?? 'medium']);
}
@ -296,6 +297,8 @@ final class L11nManager
*/
public function getDateTime(Localization $l11n, \DateTimeInterface $datetime = null, string $format = null) : string
{
return $datetime === null ? '' : $datetime->format($l11n->getDateTime()[$format ?? 'medium']);
return $datetime === null
? ''
: $datetime->format($l11n->getDateTime()[$format ?? 'medium']);
}
}

View File

@ -28,6 +28,14 @@ use phpOMS\Utils\Converter\TemperatureType;
*/
class Localization implements \JsonSerializable
{
/**
* Definition path.
*
* @var string
* @since 1.0.0
*/
private const DEFINITIONS_PATH = __DIR__ . '/../Localization/Defaults/Definitions/';
/**
* Country ID.
*
@ -243,25 +251,19 @@ class Localization implements \JsonSerializable
$langCode = \strtolower($langCode);
$countryCode = \strtoupper($countryCode);
if (!ISO639x1Enum::isValidValue($langCode)) {
throw new InvalidEnumValue($langCode);
}
if ($countryCode !== '*'
&& !\is_file(__DIR__ . '/../Localization/Defaults/Definitions/' . $langCode . '_' . $countryCode . '.json')
&& !\is_file(self::DEFINITIONS_PATH . $langCode . '_' . $countryCode . '.json')
) {
$countryCode = '';
}
$files = \glob(__DIR__ . '/../Localization/Defaults/Definitions/' . $langCode . '_' . $countryCode . '*');
$files = \glob(self::DEFINITIONS_PATH . $langCode . '_' . $countryCode . '*');
if ($files === false) {
$files = []; // @codeCoverageIgnore
}
foreach ($files as $file) {
$fileContent = \file_get_contents($file);
if ($fileContent === false) {
break; // @codeCoverageIgnore
}
@ -271,8 +273,7 @@ class Localization implements \JsonSerializable
return;
}
$fileContent = \file_get_contents(__DIR__ . '/../Localization/Defaults/Definitions/en_US.json');
$fileContent = \file_get_contents(DEFINITIONS_PATH . 'en_US.json');
if ($fileContent === false) {
return; // @codeCoverageIgnore
}

View File

@ -49,7 +49,7 @@ abstract class ModuleAbstract
* @var string
* @since 1.0.0
*/
public const MODULE_PATH = __DIR__ . '/../../Modules';
public const MODULE_PATH = __DIR__ . '/../../Modules/';
/**
* Module version.
@ -124,7 +124,7 @@ abstract class ModuleAbstract
public static function getLocalization(string $language, string $destination) : array
{
$lang = [];
if (\is_file($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) {
if (\is_file($oldPath = self::MODULE_PATH . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) {
/** @noinspection PhpIncludeInspection */
return include $oldPath;
}

View File

@ -207,7 +207,7 @@ final class ModuleManager
$active = $sth->fetchAll(\PDO::FETCH_COLUMN);
foreach ($active as $module) {
$path = $this->modulePath . '/' . $module . '/info.json';
$path = $this->modulePath . $module . '/info.json';
if (!\is_file($path)) {
continue;
@ -274,7 +274,7 @@ final class ModuleManager
$c = $files === false ? 0 : \count($files);
for ($i = 0; $i < $c; ++$i) {
$path = $this->modulePath . '/' . $files[$i] . '/info.json';
$path = $this->modulePath . $files[$i] . '/info.json';
if (!\is_file($path)) {
continue;
@ -323,7 +323,7 @@ final class ModuleManager
$installed = $sth->fetchAll(\PDO::FETCH_COLUMN);
foreach ($installed as $module) {
$path = $this->modulePath . '/' . $module . '/info.json';
$path = $this->modulePath . $module . '/info.json';
if (!\is_file($path)) {
continue;
@ -347,7 +347,7 @@ final class ModuleManager
*/
private function loadInfo(string $module) : ModuleInfo
{
$path = \realpath($oldPath = $this->modulePath . '/' . $module . '/info.json');
$path = \realpath($oldPath = $this->modulePath . $module . '/info.json');
if ($path === false) {
throw new PathException($oldPath);
@ -507,7 +507,7 @@ final class ModuleManager
* @todo Orange-Management/Modules#193
* Implement online database and downloading api for modules and updates
*/
if (!\is_file($this->modulePath . '/' . $module . '/Admin/Installer.php')) {
if (!\is_file($this->modulePath . $module . '/Admin/Installer.php')) {
return false;
}
@ -557,7 +557,7 @@ final class ModuleManager
return false;
}
if (!\is_file($this->modulePath . '/' . $module . '/Admin/Uninstaller.php')) {
if (!\is_file($this->modulePath . $module . '/Admin/Uninstaller.php')) {
return false;
}
@ -650,7 +650,7 @@ final class ModuleManager
*/
public function installProviding(string $from, string $for) : void
{
if (\is_file($this->modulePath . '/' . $from . '/Admin/Install/' . $for . '.php')) {
if (\is_file($this->modulePath . $from . '/Admin/Install/' . $for . '.php')) {
$class = '\\Modules\\' . $from . '\\Admin\\Install\\' . $for;
$class::install($this->modulePath, $this->app->dbPool);
}
@ -669,11 +669,11 @@ final class ModuleManager
*/
public function installApplications(string $from) : void
{
if (!\is_dir($this->modulePath . '/' . $from . '/Application')) {
if (!\is_dir($this->modulePath . $from . '/Application')) {
return;
}
$dirs = \scandir($this->modulePath . '/' . $from . '/Application');
$dirs = \scandir($this->modulePath . $from . '/Application');
if ($dirs === false) {
return;

View File

@ -27,6 +27,14 @@ use phpOMS\System\File\PathException;
*/
abstract class ViewAbstract implements RenderableInterface
{
/**
* Base path.
*
* @var string
* @since 1.0.0
*/
private const BASE_PATH = __DIR__ . '/../..';
/**
* Template.
*
@ -67,7 +75,7 @@ abstract class ViewAbstract implements RenderableInterface
*/
public function setTemplate(string $template, string $extension = 'tpl.php') : void
{
$this->template = __DIR__ . '/../..' . $template . '.' . $extension;
$this->template = self::BASE_PATH . $template . '.' . $extension;
}
/**