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