mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-09 05:38:39 +00:00
remove webinterface
This commit is contained in:
parent
ba7737d0ad
commit
b57e6ca305
|
|
@ -90,12 +90,9 @@ final class L11nManager
|
||||||
throw new \UnexpectedValueException($from);
|
throw new \UnexpectedValueException($from);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($this->language[$language][$from])) {
|
$this->language[$language][$from] = !isset($this->language[$language][$from])
|
||||||
$this->language[$language][$from] = $translation[$from];
|
? $translation[$from]
|
||||||
} else {
|
: $translation[$from] + $this->language[$language][$from];
|
||||||
/** @noinspection PhpWrongStringConcatenationInspection */
|
|
||||||
$this->language[$language][$from] = $translation[$from] + $this->language[$language][$from];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -114,12 +111,12 @@ final class L11nManager
|
||||||
*/
|
*/
|
||||||
public function loadLanguageFromFile(string $language, string $from, string $file) : void
|
public function loadLanguageFromFile(string $language, string $from, string $file) : void
|
||||||
{
|
{
|
||||||
$lang = [];
|
if (!\is_file($file)) {
|
||||||
if (\is_file($file)) {
|
return;
|
||||||
/** @noinspection PhpIncludeInspection */
|
|
||||||
$lang = include $file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
|
$lang = include $file;
|
||||||
$this->loadLanguage($language, $from, $lang);
|
$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
|
public function getText(string $code, string $module, string $theme, $translation, string $app = null) : string
|
||||||
{
|
{
|
||||||
if (!isset($this->language[$code][$module][$translation])) {
|
if (isset($this->language[$code][$module][$translation])) {
|
||||||
try {
|
return $this->language[$code][$module][$translation];
|
||||||
/** @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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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']);
|
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
|
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']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,14 @@ use phpOMS\Utils\Converter\TemperatureType;
|
||||||
*/
|
*/
|
||||||
class Localization implements \JsonSerializable
|
class Localization implements \JsonSerializable
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Definition path.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private const DEFINITIONS_PATH = __DIR__ . '/../Localization/Defaults/Definitions/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Country ID.
|
* Country ID.
|
||||||
*
|
*
|
||||||
|
|
@ -243,25 +251,19 @@ class Localization implements \JsonSerializable
|
||||||
$langCode = \strtolower($langCode);
|
$langCode = \strtolower($langCode);
|
||||||
$countryCode = \strtoupper($countryCode);
|
$countryCode = \strtoupper($countryCode);
|
||||||
|
|
||||||
if (!ISO639x1Enum::isValidValue($langCode)) {
|
|
||||||
throw new InvalidEnumValue($langCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($countryCode !== '*'
|
if ($countryCode !== '*'
|
||||||
&& !\is_file(__DIR__ . '/../Localization/Defaults/Definitions/' . $langCode . '_' . $countryCode . '.json')
|
&& !\is_file(self::DEFINITIONS_PATH . $langCode . '_' . $countryCode . '.json')
|
||||||
) {
|
) {
|
||||||
$countryCode = '';
|
$countryCode = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = \glob(__DIR__ . '/../Localization/Defaults/Definitions/' . $langCode . '_' . $countryCode . '*');
|
$files = \glob(self::DEFINITIONS_PATH . $langCode . '_' . $countryCode . '*');
|
||||||
|
|
||||||
if ($files === false) {
|
if ($files === false) {
|
||||||
$files = []; // @codeCoverageIgnore
|
$files = []; // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$fileContent = \file_get_contents($file);
|
$fileContent = \file_get_contents($file);
|
||||||
|
|
||||||
if ($fileContent === false) {
|
if ($fileContent === false) {
|
||||||
break; // @codeCoverageIgnore
|
break; // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
@ -271,8 +273,7 @@ class Localization implements \JsonSerializable
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileContent = \file_get_contents(__DIR__ . '/../Localization/Defaults/Definitions/en_US.json');
|
$fileContent = \file_get_contents(DEFINITIONS_PATH . 'en_US.json');
|
||||||
|
|
||||||
if ($fileContent === false) {
|
if ($fileContent === false) {
|
||||||
return; // @codeCoverageIgnore
|
return; // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ abstract class ModuleAbstract
|
||||||
* @var string
|
* @var string
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public const MODULE_PATH = __DIR__ . '/../../Modules';
|
public const MODULE_PATH = __DIR__ . '/../../Modules/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module version.
|
* Module version.
|
||||||
|
|
@ -124,7 +124,7 @@ abstract class ModuleAbstract
|
||||||
public static function getLocalization(string $language, string $destination) : array
|
public static function getLocalization(string $language, string $destination) : array
|
||||||
{
|
{
|
||||||
$lang = [];
|
$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 */
|
/** @noinspection PhpIncludeInspection */
|
||||||
return include $oldPath;
|
return include $oldPath;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ final class ModuleManager
|
||||||
$active = $sth->fetchAll(\PDO::FETCH_COLUMN);
|
$active = $sth->fetchAll(\PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
foreach ($active as $module) {
|
foreach ($active as $module) {
|
||||||
$path = $this->modulePath . '/' . $module . '/info.json';
|
$path = $this->modulePath . $module . '/info.json';
|
||||||
|
|
||||||
if (!\is_file($path)) {
|
if (!\is_file($path)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -274,7 +274,7 @@ final class ModuleManager
|
||||||
|
|
||||||
$c = $files === false ? 0 : \count($files);
|
$c = $files === false ? 0 : \count($files);
|
||||||
for ($i = 0; $i < $c; ++$i) {
|
for ($i = 0; $i < $c; ++$i) {
|
||||||
$path = $this->modulePath . '/' . $files[$i] . '/info.json';
|
$path = $this->modulePath . $files[$i] . '/info.json';
|
||||||
|
|
||||||
if (!\is_file($path)) {
|
if (!\is_file($path)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -323,7 +323,7 @@ final class ModuleManager
|
||||||
$installed = $sth->fetchAll(\PDO::FETCH_COLUMN);
|
$installed = $sth->fetchAll(\PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
foreach ($installed as $module) {
|
foreach ($installed as $module) {
|
||||||
$path = $this->modulePath . '/' . $module . '/info.json';
|
$path = $this->modulePath . $module . '/info.json';
|
||||||
|
|
||||||
if (!\is_file($path)) {
|
if (!\is_file($path)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -347,7 +347,7 @@ final class ModuleManager
|
||||||
*/
|
*/
|
||||||
private function loadInfo(string $module) : ModuleInfo
|
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) {
|
if ($path === false) {
|
||||||
throw new PathException($oldPath);
|
throw new PathException($oldPath);
|
||||||
|
|
@ -507,7 +507,7 @@ final class ModuleManager
|
||||||
* @todo Orange-Management/Modules#193
|
* @todo Orange-Management/Modules#193
|
||||||
* Implement online database and downloading api for modules and updates
|
* 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -557,7 +557,7 @@ final class ModuleManager
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_file($this->modulePath . '/' . $module . '/Admin/Uninstaller.php')) {
|
if (!\is_file($this->modulePath . $module . '/Admin/Uninstaller.php')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -650,7 +650,7 @@ final class ModuleManager
|
||||||
*/
|
*/
|
||||||
public function installProviding(string $from, string $for) : void
|
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 = '\\Modules\\' . $from . '\\Admin\\Install\\' . $for;
|
||||||
$class::install($this->modulePath, $this->app->dbPool);
|
$class::install($this->modulePath, $this->app->dbPool);
|
||||||
}
|
}
|
||||||
|
|
@ -669,11 +669,11 @@ final class ModuleManager
|
||||||
*/
|
*/
|
||||||
public function installApplications(string $from) : void
|
public function installApplications(string $from) : void
|
||||||
{
|
{
|
||||||
if (!\is_dir($this->modulePath . '/' . $from . '/Application')) {
|
if (!\is_dir($this->modulePath . $from . '/Application')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dirs = \scandir($this->modulePath . '/' . $from . '/Application');
|
$dirs = \scandir($this->modulePath . $from . '/Application');
|
||||||
|
|
||||||
if ($dirs === false) {
|
if ($dirs === false) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,14 @@ use phpOMS\System\File\PathException;
|
||||||
*/
|
*/
|
||||||
abstract class ViewAbstract implements RenderableInterface
|
abstract class ViewAbstract implements RenderableInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Base path.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private const BASE_PATH = __DIR__ . '/../..';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template.
|
* Template.
|
||||||
*
|
*
|
||||||
|
|
@ -67,7 +75,7 @@ abstract class ViewAbstract implements RenderableInterface
|
||||||
*/
|
*/
|
||||||
public function setTemplate(string $template, string $extension = 'tpl.php') : void
|
public function setTemplate(string $template, string $extension = 'tpl.php') : void
|
||||||
{
|
{
|
||||||
$this->template = __DIR__ . '/../..' . $template . '.' . $extension;
|
$this->template = self::BASE_PATH . $template . '.' . $extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user