Inital commit

This commit is contained in:
2020-11-19 15:36:28 +01:00
parent 71f32f83d3
commit 66ce4ee218
18077 changed files with 2166122 additions and 35184 deletions

View File

@@ -15,10 +15,14 @@ namespace Tinymce\Smarty;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Model\Lang;
use TheliaSmarty\Template\AbstractSmartyPlugin;
use TheliaSmarty\Template\SmartyPluginDescriptor;
/**
* Class TinyMCELanguage
* @package Tinymce\Smarty
*/
class TinyMCELanguage extends AbstractSmartyPlugin
{
/** @var string $locale */
@@ -26,7 +30,11 @@ class TinyMCELanguage extends AbstractSmartyPlugin
public function __construct(Request $request)
{
$this->locale = $request->getSession()->getLang()->getLocale();
if ($request->getSession() != null) {
$this->locale = $request->getSession()->getLang()->getLocale();
} else {
$this->locale = Lang::getDefaultLanguage()->getLocale();
}
}
public function guessTinyMCELanguage($params, \Smarty_Internal_Template $template)
@@ -40,7 +48,7 @@ class TinyMCELanguage extends AbstractSmartyPlugin
// Find the best matching language
/** @var SplFileInfo $file */
foreach($files as $file) {
foreach ($files as $file) {
$lang = str_replace('.js', '', $file->getFilename());
if ($lang == $this->locale || $lang == $miniLocale) {
@@ -49,7 +57,7 @@ class TinyMCELanguage extends AbstractSmartyPlugin
}
return '';
}
}
/**
* Define the various smarty plugins hendled by this class
@@ -62,4 +70,4 @@ class TinyMCELanguage extends AbstractSmartyPlugin
new SmartyPluginDescriptor('function', 'tinymce_lang', $this, 'guessTinyMCELanguage'),
);
}
}
}