mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 14:58:42 +00:00
Localization fix
This commit is contained in:
parent
20b07d5959
commit
a4733c7728
|
|
@ -16,6 +16,8 @@
|
||||||
namespace phpOMS\Localization;
|
namespace phpOMS\Localization;
|
||||||
|
|
||||||
use phpOMS\Datatypes\Exception\InvalidEnumValue;
|
use phpOMS\Datatypes\Exception\InvalidEnumValue;
|
||||||
|
use phpOMS\Utils\Converter\AngleType;
|
||||||
|
use phpOMS\Utils\Converter\TemperatureType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Localization class.
|
* Localization class.
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use phpOMS\Datatypes\Exception\InvalidEnumValue;
|
||||||
use phpOMS\System\File\Directory;
|
use phpOMS\System\File\Directory;
|
||||||
use phpOMS\System\File\File;
|
use phpOMS\System\File\File;
|
||||||
use phpOMS\System\File\PathException;
|
use phpOMS\System\File\PathException;
|
||||||
use phpOMS\Validation\Validator;
|
use phpOMS\Utils\StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logging class.
|
* Logging class.
|
||||||
|
|
@ -99,7 +99,7 @@ class FileLogger implements LoggerInterface
|
||||||
$path = realpath($lpath);
|
$path = realpath($lpath);
|
||||||
$this->verbose = $verbose;
|
$this->verbose = $verbose;
|
||||||
|
|
||||||
if ($path !== false && Validator::startsWith($path, ROOT_PATH) === false) {
|
if ($path !== false && StringUtils::startsWith($path, ROOT_PATH) === false) {
|
||||||
throw new PathException($lpath);
|
throw new PathException($lpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
namespace phpOMS\System\File;
|
namespace phpOMS\System\File;
|
||||||
|
|
||||||
use phpOMS\Utils\StringUtils;
|
use phpOMS\Utils\StringUtils;
|
||||||
use phpOMS\Validation\Validator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filesystem class.
|
* Filesystem class.
|
||||||
|
|
@ -193,7 +192,7 @@ class Directory extends FileAbstract implements \Iterator, \ArrayAccess
|
||||||
public static function deletePath($path) : bool
|
public static function deletePath($path) : bool
|
||||||
{
|
{
|
||||||
$path = realpath($oldPath = $path);
|
$path = realpath($oldPath = $path);
|
||||||
if ($path === false || !is_dir($path) || Validator::startsWith($path, ROOT_PATH)) {
|
if ($path === false || !is_dir($path) || StringUtils::startsWith($path, ROOT_PATH)) {
|
||||||
throw new PathException($oldPath);
|
throw new PathException($oldPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use phpOMS\Localization\Localization;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
use phpOMS\System\File\PathException;
|
use phpOMS\System\File\PathException;
|
||||||
use phpOMS\Validation\Validator;
|
use phpOMS\Utils\StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List view.
|
* List view.
|
||||||
|
|
@ -319,19 +319,35 @@ class View implements \Serializable
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
|
* @throws
|
||||||
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function getText(string $translation, string $module = null, string $theme = null)
|
public function getText(string $translation, string $module = null, string $theme = null)
|
||||||
{
|
{
|
||||||
if(!isset($module)) {
|
if (!isset($module)) {
|
||||||
$match = '/Theme/';
|
$match = '/Modules/';
|
||||||
$module = ($start = strripos($this->template, $match)) !== false ? substr($this->template, ($offset = $start+strlen($match)), strpos($this->template, '/', $offset)) : throw new \Exception('Unknown Theme');
|
|
||||||
|
if (($start = strripos($this->template, $match)) === false) {
|
||||||
|
throw new \Exception('Unknown Module');
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = $start + strlen($match);
|
||||||
|
$end = strpos($this->template, '/', $start);
|
||||||
|
$module = substr($this->template, $start, $end - $start);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($theme)) {
|
if (!isset($theme)) {
|
||||||
$match = '/Modules/';
|
$match = '/Theme/';
|
||||||
$module = ($start = strripos($this->template, $match)) !== false ? substr($this->template, ($offset = $start+strlen($match)), strpos($this->template, '/', $offset)) : throw new \Exception('Unknown Module');
|
|
||||||
|
if (($start = strripos($this->template, $match)) === false) {
|
||||||
|
throw new \Exception('Unknown Theme');
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = $start + strlen($match);
|
||||||
|
$end = strpos($this->template, '/', $start);
|
||||||
|
$theme = substr($this->template, $start, $end - $start);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->app->l11nManager->getText($this->l11n->getLanguage(), $module, $theme, $translation);
|
return $this->app->l11nManager->getText($this->l11n->getLanguage(), $module, $theme, $translation);
|
||||||
|
|
@ -368,7 +384,7 @@ class View implements \Serializable
|
||||||
{
|
{
|
||||||
$path = realpath($oldPath = __DIR__ . '/../..' . $this->template . '.tpl.php');
|
$path = realpath($oldPath = __DIR__ . '/../..' . $this->template . '.tpl.php');
|
||||||
|
|
||||||
if ($path === false || Validator::startsWith($path, ROOT_PATH) === false) {
|
if ($path === false || StringUtils::startsWith($path, ROOT_PATH) === false) {
|
||||||
throw new PathException($oldPath);
|
throw new PathException($oldPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user