improve code
This commit is contained in:
parent
c6496efc62
commit
192a9aa52d
@ -53,6 +53,7 @@ use O3\TinyMCE\Application\Core\TinyMCE\Options\ToolbarSticky;
|
|||||||
class Configuration
|
class Configuration
|
||||||
{
|
{
|
||||||
protected Loader $loader;
|
protected Loader $loader;
|
||||||
|
/** @var array<String, String> */
|
||||||
protected array $options = [];
|
protected array $options = [];
|
||||||
|
|
||||||
public function __construct(Loader $loader)
|
public function __construct(Loader $loader)
|
||||||
@ -89,6 +90,10 @@ class Configuration
|
|||||||
{
|
{
|
||||||
$sConfig = '';
|
$sConfig = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string $param
|
||||||
|
* @var string $value
|
||||||
|
*/
|
||||||
foreach ($this->options as $param => $value) {
|
foreach ($this->options as $param => $value) {
|
||||||
$sConfig .= "$param: $value, ";
|
$sConfig .= "$param: $value, ";
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,11 @@ class Loader
|
|||||||
{
|
{
|
||||||
if (!$this->isEnabledForCurrentController()) return '';
|
if (!$this->isEnabledForCurrentController()) return '';
|
||||||
|
|
||||||
if ($this->contentIsPlain()) return $this->language->translateString('TINYMCE_PLAINCMS');
|
if ($this->contentIsPlain()) {
|
||||||
|
/** @var string $message */
|
||||||
|
$message = $this->language->translateString('TINYMCE_PLAINCMS');
|
||||||
|
return $message;
|
||||||
|
}
|
||||||
|
|
||||||
$configuration = oxNew(Configuration::class, $this);
|
$configuration = oxNew(Configuration::class, $this);
|
||||||
$configuration->build();
|
$configuration->build();
|
||||||
@ -66,6 +70,7 @@ class Loader
|
|||||||
*/
|
*/
|
||||||
protected function isEnabledForCurrentController(): bool
|
protected function isEnabledForCurrentController(): bool
|
||||||
{
|
{
|
||||||
|
/** @var string[] $aEnabledClasses */
|
||||||
$aEnabledClasses = $this->getShopConfig()->getConfigParam( "aTinyMCE_classes", []);
|
$aEnabledClasses = $this->getShopConfig()->getConfigParam( "aTinyMCE_classes", []);
|
||||||
|
|
||||||
return in_array( $this->getShopConfig()->getActiveView()->getClassKey(), $aEnabledClasses);
|
return in_array( $this->getShopConfig()->getActiveView()->getClassKey(), $aEnabledClasses);
|
||||||
@ -109,7 +114,7 @@ class Loader
|
|||||||
$sInit = str_replace(
|
$sInit = str_replace(
|
||||||
"'CONFIG':'VALUES'",
|
"'CONFIG':'VALUES'",
|
||||||
$configuration->getConfig(),
|
$configuration->getConfig(),
|
||||||
file_get_contents(__DIR__.'/../../../out/scripts/init.js')
|
(string) file_get_contents(__DIR__.'/../../../out/scripts/init.js')
|
||||||
);
|
);
|
||||||
$smarty = Registry::getUtilsView()->getSmarty();
|
$smarty = Registry::getUtilsView()->getSmarty();
|
||||||
$sSufix = ($smarty->_tpl_vars["__oxid_include_dynamic"]) ? '_dynamic' : '';
|
$sSufix = ($smarty->_tpl_vars["__oxid_include_dynamic"]) ? '_dynamic' : '';
|
||||||
@ -131,6 +136,7 @@ class Loader
|
|||||||
$smarty = Registry::getUtilsView()->getSmarty();
|
$smarty = Registry::getUtilsView()->getSmarty();
|
||||||
$sSuffix = ($smarty->_tpl_vars["__oxid_include_dynamic"]) ? '_dynamic' : '';
|
$sSuffix = ($smarty->_tpl_vars["__oxid_include_dynamic"]) ? '_dynamic' : '';
|
||||||
|
|
||||||
|
/** @var array<int, string[]> $aInclude */
|
||||||
$aInclude = (array) Registry::getConfig()->getGlobalParameter('includes' . $sSuffix);
|
$aInclude = (array) Registry::getConfig()->getGlobalParameter('includes' . $sSuffix);
|
||||||
|
|
||||||
$aInclude[3][] = Registry::getConfig()->getActiveView()->getViewConfig()->getModuleUrl(
|
$aInclude[3][] = Registry::getConfig()->getActiveView()->getViewConfig()->getModuleUrl(
|
||||||
@ -138,14 +144,17 @@ class Loader
|
|||||||
'out/tinymce/tinymce.min.js'
|
'out/tinymce/tinymce.min.js'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** @var string[] $aExtjs */
|
||||||
$aExtjs = Registry::getConfig()->getConfigParam('aTinyMCE_extjs', []);
|
$aExtjs = Registry::getConfig()->getConfigParam('aTinyMCE_extjs', []);
|
||||||
foreach ($aExtjs as $js) {
|
foreach ($aExtjs as $js) {
|
||||||
$aInclude[3][] = $js;
|
$aInclude[3][] = $js;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(trim(Registry::getConfig()->getConfigParam('sTinyMCE_apikey', '')))) {
|
/** @var string $apiKey */
|
||||||
|
$apiKey = Registry::getConfig()->getConfigParam('sTinyMCE_apikey', '');
|
||||||
|
if (strlen(trim($apiKey))) {
|
||||||
$aInclude[3][] = "https://cdn.tiny.cloud/1/".
|
$aInclude[3][] = "https://cdn.tiny.cloud/1/".
|
||||||
trim(Registry::getConfig()->getConfigParam('sTinyMCE_apikey', '')).
|
trim($apiKey).
|
||||||
"/tinymce/6/plugins.min.js";
|
"/tinymce/6/plugins.min.js";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,12 +36,15 @@ class ContentCss extends AbstractOption
|
|||||||
|
|
||||||
public function get(): string
|
public function get(): string
|
||||||
{
|
{
|
||||||
|
/** @var string $theme */
|
||||||
|
$theme = Registry::getConfig()->getConfigParam('sTheme');
|
||||||
|
|
||||||
return implode(
|
return implode(
|
||||||
',',
|
',',
|
||||||
[
|
[
|
||||||
$this->darkMode ?
|
$this->darkMode ?
|
||||||
'dark' :
|
'dark' :
|
||||||
'/out/'.strtolower(Registry::getConfig()->getConfigParam('sTheme')).'/src/css/styles.min.css'
|
'/out/'.strtolower($theme).'/src/css/styles.min.css'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ class FilemanagerUrl extends AbstractOption
|
|||||||
|
|
||||||
public function get(): string
|
public function get(): string
|
||||||
{
|
{
|
||||||
|
/** @var string $sFilemanagerKey */
|
||||||
$sFilemanagerKey = md5_file(Registry::getConfig()->getConfigParam("sShopDir")."/config.inc.php");
|
$sFilemanagerKey = md5_file(Registry::getConfig()->getConfigParam("sShopDir")."/config.inc.php");
|
||||||
Registry::get(UtilsServer::class)->setOxCookie("filemanagerkey", $sFilemanagerKey);
|
Registry::get(UtilsServer::class)->setOxCookie("filemanagerkey", $sFilemanagerKey);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class Language extends AbstractOption
|
|||||||
"nl" => "nl",
|
"nl" => "nl",
|
||||||
"ru" => "ru"
|
"ru" => "ru"
|
||||||
);
|
);
|
||||||
return $aLang[ $oLang->getLanguageAbbr( $oLang->getTplLanguage() ) ] ?? "en";
|
return $aLang[ $oLang->getLanguageAbbr( (int) $oLang->getTplLanguage() ) ] ?? "en";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mustQuote(): bool
|
public function mustQuote(): bool
|
||||||
|
@ -31,9 +31,9 @@ class MinHeight extends AbstractOption
|
|||||||
|
|
||||||
public function get(): string
|
public function get(): string
|
||||||
{
|
{
|
||||||
$profile = Registry::getSession()->getVariable('profile');
|
$profile = (array) Registry::getSession()->getVariable('profile');
|
||||||
|
|
||||||
if (isset($profile) && $profile[1]) {
|
if (array_key_exists(1, $profile)) {
|
||||||
return (string) (max($profile[1] * 20, 350));
|
return (string) (max($profile[1] * 20, 350));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class Setup extends AbstractOption
|
|||||||
editor.options.register("filemanager_url", { processor: "string" });
|
editor.options.register("filemanager_url", { processor: "string" });
|
||||||
}
|
}
|
||||||
JS;
|
JS;
|
||||||
return trim(preg_replace('!\s+!', ' ', $js));
|
return trim((string) preg_replace('!\s+!', ' ', $js));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,11 @@ class Toolbar extends AbstractOption
|
|||||||
$this->getMultiLineToolbar($toolbarList);
|
$this->getMultiLineToolbar($toolbarList);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getSingleLineToolbar($toolbarList): string
|
/**
|
||||||
|
* @param ToolbarList $toolbarList
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getSingleLineToolbar(ToolbarList $toolbarList): string
|
||||||
{
|
{
|
||||||
$all = [];
|
$all = [];
|
||||||
|
|
||||||
@ -90,7 +94,11 @@ class Toolbar extends AbstractOption
|
|||||||
return $toolbarElements . ' | ' . $pluginToolbarElements;
|
return $toolbarElements . ' | ' . $pluginToolbarElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getMultiLineToolbar($toolbarList): string
|
/**
|
||||||
|
* @param ToolbarList $toolbarList
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getMultiLineToolbar(ToolbarList $toolbarList): string
|
||||||
{
|
{
|
||||||
$list = [];
|
$list = [];
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Lists;
|
|||||||
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Media;
|
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Media;
|
||||||
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Nonbreaking;
|
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Nonbreaking;
|
||||||
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Pagebreak;
|
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Pagebreak;
|
||||||
|
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\PluginInterface;
|
||||||
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Preview;
|
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Preview;
|
||||||
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Quickbars;
|
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Quickbars;
|
||||||
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Roxy;
|
use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Roxy;
|
||||||
@ -47,6 +48,9 @@ use O3\TinyMCE\Application\Core\TinyMCE\Plugins\WordCount;
|
|||||||
|
|
||||||
class PluginList
|
class PluginList
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, PluginInterface>
|
||||||
|
*/
|
||||||
public function get(): array
|
public function get(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -30,6 +30,9 @@ class Nonbreaking extends AbstractPlugin
|
|||||||
return 'nonbreaking';
|
return 'nonbreaking';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
public function getToolbarElements(): array
|
public function getToolbarElements(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -30,6 +30,9 @@ class Pagebreak extends AbstractPlugin
|
|||||||
return 'pagebreak';
|
return 'pagebreak';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
public function getToolbarElements(): array
|
public function getToolbarElements(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -27,6 +27,9 @@ interface PluginInterface
|
|||||||
{
|
{
|
||||||
public function getPluginName(): string;
|
public function getPluginName(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
public function getToolbarElements(): array;
|
public function getToolbarElements(): array;
|
||||||
|
|
||||||
public function getScriptPath(): ?string;
|
public function getScriptPath(): ?string;
|
||||||
|
@ -30,6 +30,9 @@ class Preview extends AbstractPlugin
|
|||||||
return 'preview';
|
return 'preview';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
public function getToolbarElements(): array
|
public function getToolbarElements(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -30,6 +30,9 @@ class SearchReplace extends AbstractPlugin
|
|||||||
return 'searchreplace';
|
return 'searchreplace';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
public function getToolbarElements(): array
|
public function getToolbarElements(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -30,6 +30,9 @@ class Table extends AbstractPlugin
|
|||||||
return 'table';
|
return 'table';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
public function getToolbarElements(): array
|
public function getToolbarElements(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -30,6 +30,9 @@ class Visualblocks extends AbstractPlugin
|
|||||||
return 'visualblocks';
|
return 'visualblocks';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
public function getToolbarElements(): array
|
public function getToolbarElements(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -30,6 +30,9 @@ class WordCount extends AbstractPlugin
|
|||||||
return 'wordcount';
|
return 'wordcount';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
public function getToolbarElements(): array
|
public function getToolbarElements(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
@ -25,5 +25,8 @@ namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar;
|
|||||||
|
|
||||||
interface ToolbarInterface
|
interface ToolbarInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
public function getButtons(): array;
|
public function getButtons(): array;
|
||||||
}
|
}
|
@ -25,6 +25,9 @@ namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar;
|
|||||||
|
|
||||||
class Undo extends AbstractToolbar
|
class Undo extends AbstractToolbar
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
public function getButtons(): array
|
public function getButtons(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -31,9 +31,13 @@ use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Blocks;
|
|||||||
use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Indent;
|
use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Indent;
|
||||||
use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Lists;
|
use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Lists;
|
||||||
use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\RemoveFormat;
|
use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\RemoveFormat;
|
||||||
|
use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\ToolbarInterface;
|
||||||
|
|
||||||
class ToolbarList
|
class ToolbarList
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return array<int, array<string, ToolbarInterface>>
|
||||||
|
*/
|
||||||
public function get(): array
|
public function get(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -25,7 +25,7 @@ namespace O3\TinyMCE\Application\Core\TinyMCE;
|
|||||||
|
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
public function quote($string): string
|
public function quote(string $string): string
|
||||||
{
|
{
|
||||||
return '"'.addslashes($string).'"';
|
return '"'.addslashes($string).'"';
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
function checkAccess($action)
|
function checkAccess(string $action): void
|
||||||
{
|
{
|
||||||
if($_COOKIE['filemanagerkey'] !== md5($_SERVER['DOCUMENT_ROOT'].$_COOKIE['admin_sid'])) die('Access Denied!!');
|
if($_COOKIE['filemanagerkey'] !== md5($_SERVER['DOCUMENT_ROOT'].$_COOKIE['admin_sid'])) die('Access Denied!!');
|
||||||
}
|
}
|
10
phpstan.neon
Normal file
10
phpstan.neon
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
parameters:
|
||||||
|
scanFiles:
|
||||||
|
- .ide-helper.php
|
||||||
|
- ../../o3-shop/shop-ce/source/oxfunctions.php
|
||||||
|
paths:
|
||||||
|
- Application
|
||||||
|
excludePaths:
|
||||||
|
- Application/fileman
|
||||||
|
level: 9
|
||||||
|
phpVersion: 70400
|
Loading…
Reference in New Issue
Block a user