From: Vincent Vanwaelscappel Date: Wed, 6 Sep 2023 07:11:51 +0000 (+0200) Subject: wip #6246 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8237c6f1c62df07b085701c90179564610ce9cd3;p=cubist_cms-back.git wip #6246 @0.25 --- diff --git a/src/app/Magic/Models/Translate.php b/src/app/Magic/Models/Translate.php index e309d10..76c8bb3 100644 --- a/src/app/Magic/Models/Translate.php +++ b/src/app/Magic/Models/Translate.php @@ -218,4 +218,29 @@ class Translate extends CubistMagicTranslatableModel { return []; } + + + /** + * @param $key string + * @return string + */ + public static function keyToStr($key) + { + if (self::isKey($key)) { + return base64_decode(substr($key, 2)); + } + return $key; + } + + /** + * @param $key string + * @return bool + */ + public static function isKey($key) + { + if (!$key) { + return false; + } + return (bool)preg_match("/^t_[a-zA-Z0-9\/\+]*={0,2}$/", $key); + } }