From efa900bb9179f26c727b81fe3a8a9924c50211a0 Mon Sep 17 00:00:00 2001 From: O3-Shop Date: Wed, 5 Apr 2023 08:27:08 +0200 Subject: [PATCH] refactoring --- Application/Core/TinyMCE/Configuration.php | 166 +++++++++ Application/Core/TinyMCE/Loader.php | 147 ++++++++ .../Core/TinyMCE/Options/AbstractOption.php | 48 +++ Application/Core/TinyMCE/Options/BaseUrl.php | 46 +++ .../Core/TinyMCE/Options/CacheSuffix.php | 43 +++ .../Core/TinyMCE/Options/ContentCss.php | 44 +++ .../Core/TinyMCE/Options/ContextMenu.php | 39 +++ .../Core/TinyMCE/Options/DocumentBaseUrl.php | 41 +++ .../Core/TinyMCE/Options/EntityEncoding.php | 43 +++ .../Core/TinyMCE/Options/ExternalPlugins.php | 63 ++++ .../Core/TinyMCE/Options/FilemanagerUrl.php | 60 ++++ .../Core/TinyMCE/Options/ImageAdvtab.php | 34 ++ Application/Core/TinyMCE/Options/Language.php | 58 ++++ .../Core/TinyMCE/Options/MaxHeight.php | 39 +++ Application/Core/TinyMCE/Options/MaxWidth.php | 39 +++ Application/Core/TinyMCE/Options/Menubar.php | 34 ++ .../Core/TinyMCE/Options/MinHeight.php | 34 ++ .../Core/TinyMCE/Options/OptionInterface.php | 37 ++ Application/Core/TinyMCE/Options/Plugins.php | 89 +++++ Application/Core/TinyMCE/Options/Protect.php | 36 ++ .../Options/QuickbarsInsertToolbar.php | 66 ++++ .../Core/TinyMCE/Options/RelativeUrls.php | 34 ++ Application/Core/TinyMCE/Options/Selector.php | 36 ++ Application/Core/TinyMCE/Options/Toolbar.php | 80 +++++ .../Core/TinyMCE/Options/ToolbarSticky.php | 34 ++ Application/Core/TinyMCE/PluginList.php | 80 +++++ .../Core/TinyMCE/Plugins/AbstractPlugin.php | 49 +++ Application/Core/TinyMCE/Plugins/Anchor.php | 39 +++ .../Core/TinyMCE/Plugins/AutoResize.php | 32 ++ Application/Core/TinyMCE/Plugins/Autolink.php | 32 ++ Application/Core/TinyMCE/Plugins/Charmap.php | 39 +++ Application/Core/TinyMCE/Plugins/Code.php | 39 +++ Application/Core/TinyMCE/Plugins/FullPage.php | 46 +++ .../Core/TinyMCE/Plugins/FullScreen.php | 49 +++ Application/Core/TinyMCE/Plugins/Hr.php | 39 +++ Application/Core/TinyMCE/Plugins/Image.php | 39 +++ .../Core/TinyMCE/Plugins/Legacyoutput.php | 39 +++ Application/Core/TinyMCE/Plugins/Link.php | 40 +++ Application/Core/TinyMCE/Plugins/Lists.php | 37 ++ Application/Core/TinyMCE/Plugins/Media.php | 39 +++ .../Core/TinyMCE/Plugins/Nonbreaking.php | 39 +++ .../Core/TinyMCE/Plugins/Pagebreak.php | 39 +++ Application/Core/TinyMCE/Plugins/Paste.php | 39 +++ .../Core/TinyMCE/Plugins/PluginInterface.php | 37 ++ Application/Core/TinyMCE/Plugins/Preview.php | 39 +++ .../Core/TinyMCE/Plugins/Quickbars.php | 32 ++ Application/Core/TinyMCE/Plugins/Roxy.php | 52 +++ .../Core/TinyMCE/Plugins/SearchReplace.php | 39 +++ Application/Core/TinyMCE/Plugins/Table.php | 39 +++ .../Core/TinyMCE/Plugins/Visualblocks.php | 39 +++ .../Core/TinyMCE/Plugins/WordCount.php | 37 ++ .../Core/TinyMCE/Toolbar/AbstractToolbar.php | 29 ++ Application/Core/TinyMCE/Toolbar/Align.php | 37 ++ .../Core/TinyMCE/Toolbar/Blockquote.php | 34 ++ Application/Core/TinyMCE/Toolbar/Color.php | 35 ++ .../Core/TinyMCE/Toolbar/CopyPaste.php | 36 ++ Application/Core/TinyMCE/Toolbar/Font.php | 37 ++ .../Core/TinyMCE/Toolbar/Formatselect.php | 34 ++ Application/Core/TinyMCE/Toolbar/Indent.php | 35 ++ Application/Core/TinyMCE/Toolbar/Lists.php | 35 ++ .../Core/TinyMCE/Toolbar/RemoveFormat.php | 34 ++ .../Core/TinyMCE/Toolbar/Subscript.php | 34 ++ .../Core/TinyMCE/Toolbar/Superscript.php | 34 ++ .../Core/TinyMCE/Toolbar/ToolbarInterface.php | 29 ++ Application/Core/TinyMCE/Toolbar/Undo.php | 35 ++ Application/Core/TinyMCE/ToolbarList.php | 96 ++++++ Application/Core/TinyMCE/Utils.php | 32 ++ Application/Core/ViewConfig.php | 317 ++---------------- Application/Core/config.php | 2 + Application/views/admin/de/module_options.php | 8 +- Application/views/admin/editorswitch.tpl | 8 + Application/views/admin/en/module_options.php | 8 +- metadata.php | 58 +--- out/scripts/copyLongDesc.js | 13 + out/scripts/init.js | 1 + out/scripts/urlConverter.js | 7 + 76 files changed, 3119 insertions(+), 368 deletions(-) create mode 100644 Application/Core/TinyMCE/Configuration.php create mode 100644 Application/Core/TinyMCE/Loader.php create mode 100644 Application/Core/TinyMCE/Options/AbstractOption.php create mode 100644 Application/Core/TinyMCE/Options/BaseUrl.php create mode 100644 Application/Core/TinyMCE/Options/CacheSuffix.php create mode 100644 Application/Core/TinyMCE/Options/ContentCss.php create mode 100644 Application/Core/TinyMCE/Options/ContextMenu.php create mode 100644 Application/Core/TinyMCE/Options/DocumentBaseUrl.php create mode 100644 Application/Core/TinyMCE/Options/EntityEncoding.php create mode 100644 Application/Core/TinyMCE/Options/ExternalPlugins.php create mode 100644 Application/Core/TinyMCE/Options/FilemanagerUrl.php create mode 100644 Application/Core/TinyMCE/Options/ImageAdvtab.php create mode 100644 Application/Core/TinyMCE/Options/Language.php create mode 100644 Application/Core/TinyMCE/Options/MaxHeight.php create mode 100644 Application/Core/TinyMCE/Options/MaxWidth.php create mode 100644 Application/Core/TinyMCE/Options/Menubar.php create mode 100644 Application/Core/TinyMCE/Options/MinHeight.php create mode 100644 Application/Core/TinyMCE/Options/OptionInterface.php create mode 100644 Application/Core/TinyMCE/Options/Plugins.php create mode 100644 Application/Core/TinyMCE/Options/Protect.php create mode 100644 Application/Core/TinyMCE/Options/QuickbarsInsertToolbar.php create mode 100644 Application/Core/TinyMCE/Options/RelativeUrls.php create mode 100644 Application/Core/TinyMCE/Options/Selector.php create mode 100644 Application/Core/TinyMCE/Options/Toolbar.php create mode 100644 Application/Core/TinyMCE/Options/ToolbarSticky.php create mode 100644 Application/Core/TinyMCE/PluginList.php create mode 100644 Application/Core/TinyMCE/Plugins/AbstractPlugin.php create mode 100644 Application/Core/TinyMCE/Plugins/Anchor.php create mode 100644 Application/Core/TinyMCE/Plugins/AutoResize.php create mode 100644 Application/Core/TinyMCE/Plugins/Autolink.php create mode 100644 Application/Core/TinyMCE/Plugins/Charmap.php create mode 100644 Application/Core/TinyMCE/Plugins/Code.php create mode 100644 Application/Core/TinyMCE/Plugins/FullPage.php create mode 100644 Application/Core/TinyMCE/Plugins/FullScreen.php create mode 100644 Application/Core/TinyMCE/Plugins/Hr.php create mode 100644 Application/Core/TinyMCE/Plugins/Image.php create mode 100644 Application/Core/TinyMCE/Plugins/Legacyoutput.php create mode 100644 Application/Core/TinyMCE/Plugins/Link.php create mode 100644 Application/Core/TinyMCE/Plugins/Lists.php create mode 100644 Application/Core/TinyMCE/Plugins/Media.php create mode 100644 Application/Core/TinyMCE/Plugins/Nonbreaking.php create mode 100644 Application/Core/TinyMCE/Plugins/Pagebreak.php create mode 100644 Application/Core/TinyMCE/Plugins/Paste.php create mode 100644 Application/Core/TinyMCE/Plugins/PluginInterface.php create mode 100644 Application/Core/TinyMCE/Plugins/Preview.php create mode 100644 Application/Core/TinyMCE/Plugins/Quickbars.php create mode 100644 Application/Core/TinyMCE/Plugins/Roxy.php create mode 100644 Application/Core/TinyMCE/Plugins/SearchReplace.php create mode 100644 Application/Core/TinyMCE/Plugins/Table.php create mode 100644 Application/Core/TinyMCE/Plugins/Visualblocks.php create mode 100644 Application/Core/TinyMCE/Plugins/WordCount.php create mode 100644 Application/Core/TinyMCE/Toolbar/AbstractToolbar.php create mode 100644 Application/Core/TinyMCE/Toolbar/Align.php create mode 100644 Application/Core/TinyMCE/Toolbar/Blockquote.php create mode 100644 Application/Core/TinyMCE/Toolbar/Color.php create mode 100644 Application/Core/TinyMCE/Toolbar/CopyPaste.php create mode 100644 Application/Core/TinyMCE/Toolbar/Font.php create mode 100644 Application/Core/TinyMCE/Toolbar/Formatselect.php create mode 100644 Application/Core/TinyMCE/Toolbar/Indent.php create mode 100644 Application/Core/TinyMCE/Toolbar/Lists.php create mode 100644 Application/Core/TinyMCE/Toolbar/RemoveFormat.php create mode 100644 Application/Core/TinyMCE/Toolbar/Subscript.php create mode 100644 Application/Core/TinyMCE/Toolbar/Superscript.php create mode 100644 Application/Core/TinyMCE/Toolbar/ToolbarInterface.php create mode 100644 Application/Core/TinyMCE/Toolbar/Undo.php create mode 100644 Application/Core/TinyMCE/ToolbarList.php create mode 100644 Application/Core/TinyMCE/Utils.php create mode 100644 Application/views/admin/editorswitch.tpl create mode 100644 out/scripts/copyLongDesc.js create mode 100644 out/scripts/init.js create mode 100644 out/scripts/urlConverter.js diff --git a/Application/Core/TinyMCE/Configuration.php b/Application/Core/TinyMCE/Configuration.php new file mode 100644 index 0000000..37e2e33 --- /dev/null +++ b/Application/Core/TinyMCE/Configuration.php @@ -0,0 +1,166 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE; + +use O3\TinyMCE\Application\Core\TinyMCE\Options\BaseUrl; +use O3\TinyMCE\Application\Core\TinyMCE\Options\CacheSuffix; +use O3\TinyMCE\Application\Core\TinyMCE\Options\ContentCss; +use O3\TinyMCE\Application\Core\TinyMCE\Options\ContextMenu; +use O3\TinyMCE\Application\Core\TinyMCE\Options\DocumentBaseUrl; +use O3\TinyMCE\Application\Core\TinyMCE\Options\EntityEncoding; +use O3\TinyMCE\Application\Core\TinyMCE\Options\ExternalPlugins; +use O3\TinyMCE\Application\Core\TinyMCE\Options\FilemanagerUrl; +use O3\TinyMCE\Application\Core\TinyMCE\Options\ImageAdvtab; +use O3\TinyMCE\Application\Core\TinyMCE\Options\Language; +use O3\TinyMCE\Application\Core\TinyMCE\Options\MaxHeight; +use O3\TinyMCE\Application\Core\TinyMCE\Options\MaxWidth; +use O3\TinyMCE\Application\Core\TinyMCE\Options\Menubar; +use O3\TinyMCE\Application\Core\TinyMCE\Options\MinHeight; +use O3\TinyMCE\Application\Core\TinyMCE\Options\OptionInterface; +use O3\TinyMCE\Application\Core\TinyMCE\Options\Plugins; +use O3\TinyMCE\Application\Core\TinyMCE\Options\Protect; +use O3\TinyMCE\Application\Core\TinyMCE\Options\QuickbarsInsertToolbar; +use O3\TinyMCE\Application\Core\TinyMCE\Options\RelativeUrls; +use O3\TinyMCE\Application\Core\TinyMCE\Options\Selector; +use O3\TinyMCE\Application\Core\TinyMCE\Options\Toolbar; +use O3\TinyMCE\Application\Core\TinyMCE\Options\ToolbarSticky; + +class Configuration +{ + protected Loader $loader; + protected array $options = []; + + public function __construct(Loader $loader) + { + $this->loader = $loader; + } + + public function build(): void + { + $this->addIntegrateOptions(); + $this->addGuiOptions(); + $this->addContentAppearance(); + $this->addContentFiltering(); + $this->addLocalizationOptions(); + $this->addUrlHandling(); + $this->addPlugins(); + $this->addToolbar(); + } + + protected function addOption($key, OptionInterface $optionInstance): void + { + if (!$optionInstance->requireRegistration()) return; + + $option = $optionInstance->get(); + + if ($optionInstance->mustQuote()) { + $option = (oxNew(Utils::class))->quote($option); + } + + $this->options[$key] = $option; + } + + public function getConfig() + { +/* + return implode(', ', array_map( + function ($v, $k) { + if (is_array($v)) { + return $k.'[]='.implode('&'.$k.'[]=', $v); + } else { + return $k.': '.$v; + } + }, + $this->options, + array_keys($this->options) + )); + + + http_build_query($this->options,'',', ') +*/ +// $config = json_encode($this->options); + + foreach ($this->options as $param => $value) { + $sConfig .= "$param: $value, "; + } + + return $sConfig; + } + + /** + * @return void + */ + protected function addIntegrateOptions(): void + { + $this->addOption( BaseUrl::KEY, oxNew( BaseUrl::class, $this->loader)); + $this->addOption( CacheSuffix::KEY, oxNew( CacheSuffix::class, $this->loader)); + $this->addOption( Selector::KEY, oxNew( Selector::class, $this->loader)); + } + + protected function addGuiOptions(): void + { + $this->addOption(ContextMenu::KEY, oxNew(ContextMenu::class, $this->loader)); + $this->addOption(MinHeight::KEY, oxNew(MinHeight::class, $this->loader)); + $this->addOption(MaxHeight::KEY, oxNew(MaxHeight::class, $this->loader)); + $this->addOption(MaxWidth::KEY, oxNew(MaxWidth::class, $this->loader)); + $this->addOption(Menubar::KEY, oxNew(Menubar::class, $this->loader)); + $this->addOption(ToolbarSticky::KEY, oxNew(ToolbarSticky::class, $this->loader)); + } + + protected function addContentAppearance(): void + { + $this->addOption(ContentCss::KEY, oxNew(ContentCss::class,$this->loader)); + } + + protected function addContentFiltering(): void + { + $this->addOption(EntityEncoding::KEY, oxNew(EntityEncoding::class,$this->loader)); + $this->addOption(Protect::KEY, oxNew(Protect::class,$this->loader)); + } + + protected function addLocalizationOptions(): void + { + $this->addOption( Language::KEY, oxNew( Language::class, $this->loader)); + } + + protected function addUrlHandling(): void + { + $this->addOption( DocumentBaseUrl::KEY, oxNew( DocumentBaseUrl::class, $this->loader)); + $this->addOption( RelativeUrls::KEY, oxNew( RelativeUrls::class, $this->loader)); + } + + protected function addPlugins(): void + { + $this->addOption( ImageAdvtab::KEY, oxNew( ImageAdvtab::class, $this->loader)); + $this->addOption( Plugins::KEY, oxNew( Plugins::class, $this->loader)); + $this->addOption( ExternalPlugins::KEY, oxNew( ExternalPlugins::class, $this->loader)); + $this->addOption( FilemanagerUrl::KEY, oxNew( FilemanagerUrl::class, $this->loader)); + $this->addOption(QuickbarsInsertToolbar::KEY, oxNew(QuickbarsInsertToolbar::class, $this->loader)); + } + + protected function addToolbar(): void + { + $this->addOption( Toolbar::KEY, oxNew( Toolbar::class, $this->loader)); + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Loader.php b/Application/Core/TinyMCE/Loader.php new file mode 100644 index 0000000..4109333 --- /dev/null +++ b/Application/Core/TinyMCE/Loader.php @@ -0,0 +1,147 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE; + +use OxidEsales\Eshop\Application\Model\Content; +use OxidEsales\Eshop\Core\Config; +use OxidEsales\Eshop\Core\Language; +use OxidEsales\Eshop\Core\Model\BaseModel; +use OxidEsales\Eshop\Core\Registry; + +class Loader +{ + protected Config $config; + protected Language $language; + + public function __construct(Config $config, Language $language) + { + $this->config = $config; + $this->language = $language; + } + + /** + * @return string + */ + public function getEditorSwitch(): string + { + if (!$this->isEnabledForCurrentController()) return ''; + + if ($this->contentIsPlain()) return $this->language->translateString('BLA_TINYMCE_PLAINCMS'); + + $configuration = oxNew(Configuration::class, $this); + $configuration->build(); + + $this->registerScripts($configuration); + $this->registerIncludes(); + + $smarty = Registry::getUtilsView()->getSmarty(); + return $smarty->fetch('EditorSwitch.tpl'); + } + + /** + * @return bool + */ + protected function isEnabledForCurrentController(): bool + { + $aEnabledClasses = $this->getShopConfig()->getConfigParam( "aTinyMCE_classes", []); + + return in_array( $this->getShopConfig()->getActiveView()->getClassKey(), $aEnabledClasses); + } + + /** + * @return bool + */ + protected function contentIsPlain(): bool + { + /** @var BaseModel $oEditObject */ + $oEditObject = $this->getShopConfig()->getActiveView()->getViewDataElement( "edit" ); + return $oEditObject instanceof Content && $oEditObject->isPlain(); + } + + /** + * @return Language + */ + public function getLanguage(): Language + { + return $this->language; + } + + /** + * @return Config + */ + public function getShopConfig(): Config + { + return $this->config; + } + + /** + * @param Configuration $configuration + * + * @return void + */ + protected function registerScripts(Configuration $configuration): void + { + $sCopyLongDescFromTinyMCE = file_get_contents(__DIR__.'/../../../out/scripts/copyLongDesc.js'); + $sUrlConverter = file_get_contents(__DIR__.'/../../../out/scripts/urlConverter.js'); + $sInit = str_replace( + "'CONFIG':'VALUES'", + $configuration->getConfig(), + file_get_contents(__DIR__.'/../../../out/scripts/init.js') + ); +dumpvar($sInit.PHP_EOL, 1); + $smarty = Registry::getUtilsView()->getSmarty(); + $sSufix = ($smarty->_tpl_vars["__oxid_include_dynamic"]) ? '_dynamic' : ''; + + $aScript = (array) Registry::getConfig()->getGlobalParameter('scripts' . $sSufix); + $aScript[] = $sCopyLongDescFromTinyMCE; + $aScript[] = $sUrlConverter; + $aScript[] = $sInit; + + Registry::getConfig()->setGlobalParameter('scripts' . $sSufix, $aScript); + } + + /** + * @return void + * @throws \oxFileException + */ + protected function registerIncludes(): void + { + $smarty = Registry::getUtilsView()->getSmarty(); + $sSuffix = ($smarty->_tpl_vars["__oxid_include_dynamic"]) ? '_dynamic' : ''; + + $aInclude = (array) Registry::getConfig()->getGlobalParameter('includes' . $sSuffix); + + $aExtjs = Registry::getConfig()->getConfigParam('aTinyMCE_extjs', []); + foreach ($aExtjs as $js) { + $aInclude[3][] = $js; + } + + $aInclude[3][] = Registry::getConfig()->getActiveView()->getViewConfig()->getModuleUrl( + 'tinymce-editor', + 'out/tinymce/tinymce.min.js' + ); + + Registry::getConfig()->setGlobalParameter('includes' . $sSuffix, $aInclude); + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/AbstractOption.php b/Application/Core/TinyMCE/Options/AbstractOption.php new file mode 100644 index 0000000..8d71849 --- /dev/null +++ b/Application/Core/TinyMCE/Options/AbstractOption.php @@ -0,0 +1,48 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\Loader; + +abstract class AbstractOption implements OptionInterface +{ + protected Loader $loader; + + public function __construct(Loader $loader) + { + $this->loader = $loader; + } + + abstract public function get(): string; + + public function mustQuote(): bool + { + return false; + } + + public function requireRegistration(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/BaseUrl.php b/Application/Core/TinyMCE/Options/BaseUrl.php new file mode 100644 index 0000000..18eff8c --- /dev/null +++ b/Application/Core/TinyMCE/Options/BaseUrl.php @@ -0,0 +1,46 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class BaseUrl extends AbstractOption +{ + public const KEY = 'base_url'; + + /** + * @return string + */ + public function get(): string + { + return $this->loader->getShopConfig()->getActiveView()->getViewConfig()->getBaseDir() . + 'modules/o3-shop/tinymce-editor/out/tinymce/'; + } + + /** + * @return bool + */ + public function mustQuote(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/CacheSuffix.php b/Application/Core/TinyMCE/Options/CacheSuffix.php new file mode 100644 index 0000000..21e5c32 --- /dev/null +++ b/Application/Core/TinyMCE/Options/CacheSuffix.php @@ -0,0 +1,43 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\Loader; + +class CacheSuffix extends AbstractOption +{ + public const KEY = 'cache_suffix'; + + protected Loader $loader; + + public function get(): string + { + return '?v='.date('Ymd'); + } + + public function mustQuote(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/ContentCss.php b/Application/Core/TinyMCE/Options/ContentCss.php new file mode 100644 index 0000000..2975372 --- /dev/null +++ b/Application/Core/TinyMCE/Options/ContentCss.php @@ -0,0 +1,44 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\Loader; + +class ContentCss extends AbstractOption +{ + public const KEY = 'content_css'; + + protected Loader $loader; + + public function get(): string + { + // ToDo: use current theme + return '/out/wave/src/css/styles.min.css'; + } + + public function mustQuote(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/ContextMenu.php b/Application/Core/TinyMCE/Options/ContextMenu.php new file mode 100644 index 0000000..c9db5e0 --- /dev/null +++ b/Application/Core/TinyMCE/Options/ContextMenu.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class ContextMenu extends AbstractOption +{ + public const KEY = 'contextmenu'; + + public function get(): string + { + return 'link linkchecker image imagetools table'; + } + + public function mustQuote(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/DocumentBaseUrl.php b/Application/Core/TinyMCE/Options/DocumentBaseUrl.php new file mode 100644 index 0000000..08ee1fa --- /dev/null +++ b/Application/Core/TinyMCE/Options/DocumentBaseUrl.php @@ -0,0 +1,41 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use OxidEsales\Eshop\Core\Registry; + +class DocumentBaseUrl extends AbstractOption +{ + public const KEY = 'document_base_url'; + + public function get(): string + { + return Registry::getConfig()->getActiveView()->getViewConfig()->getBaseDir(); + } + + public function mustQuote(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/EntityEncoding.php b/Application/Core/TinyMCE/Options/EntityEncoding.php new file mode 100644 index 0000000..73e1c96 --- /dev/null +++ b/Application/Core/TinyMCE/Options/EntityEncoding.php @@ -0,0 +1,43 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\Loader; + +class EntityEncoding extends AbstractOption +{ + public const KEY = 'entity_encoding'; + + protected Loader $loader; + + public function get(): string + { + return 'raw'; + } + + public function mustQuote(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/ExternalPlugins.php b/Application/Core/TinyMCE/Options/ExternalPlugins.php new file mode 100644 index 0000000..c9da48d --- /dev/null +++ b/Application/Core/TinyMCE/Options/ExternalPlugins.php @@ -0,0 +1,63 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\PluginList; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\PluginInterface; +use O3\TinyMCE\Application\Core\TinyMCE\Utils; + +class ExternalPlugins extends AbstractOption +{ + public const KEY = 'external_plugins'; + + public function get(): string + { + $pluginList = oxNew(PluginList::class); + + $list = implode(', ', array_filter( + array_map( + function (PluginInterface $plugin) { + return $plugin->getScriptPath() ? implode( + ':', + [ + (oxNew(Utils::class))->quote($plugin->getPluginName()), + (oxNew(Utils::class))->quote($plugin->getScriptPath()) + ] + ) : null; + }, + $pluginList->get() + )) + ); + + return '{ '.$list.' }'; + + // plugins for newsletter emails + if ( $this->getActiveClassName() === "newsletter_main" ) { + $aPlugins["legacyoutput"] = ""; + $aPlugins["fullpage"] = "fullpage"; + } + + return 350; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/FilemanagerUrl.php b/Application/Core/TinyMCE/Options/FilemanagerUrl.php new file mode 100644 index 0000000..482b87b --- /dev/null +++ b/Application/Core/TinyMCE/Options/FilemanagerUrl.php @@ -0,0 +1,60 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\Loader; +use OxidEsales\Eshop\Core\Registry; +use OxidEsales\Eshop\Core\UtilsServer; + +class FilemanagerUrl extends AbstractOption +{ + public const KEY = 'filemanager_url'; + + protected Loader $loader; + + public function get(): string + { + $sFilemanagerKey = md5_file(Registry::getConfig()->getConfigParam("sShopDir")."/config.inc.php"); + Registry::get(UtilsServer::class)->setOxCookie("filemanagerkey", $sFilemanagerKey); + + return str_replace( + '&', + '&', + Registry::getConfig()->getActiveView()->getViewConfig()->getSslSelfLink()."cl=tinyfilemanager" + ); + } + + public function mustQuote(): bool + { + return true; + } + + /** + * @return bool + */ + public function requireRegistration(): bool + { + return (bool) $this->loader->getShopConfig()->getConfigParam("blTinyMCE_filemanager"); + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/ImageAdvtab.php b/Application/Core/TinyMCE/Options/ImageAdvtab.php new file mode 100644 index 0000000..bdbbcf5 --- /dev/null +++ b/Application/Core/TinyMCE/Options/ImageAdvtab.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class ImageAdvtab extends AbstractOption +{ + public const KEY = 'image_advtab'; + + public function get(): string + { + return 'true'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/Language.php b/Application/Core/TinyMCE/Options/Language.php new file mode 100644 index 0000000..6f2d3e9 --- /dev/null +++ b/Application/Core/TinyMCE/Options/Language.php @@ -0,0 +1,58 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class Language extends AbstractOption +{ + public const KEY = 'language'; + + /** + * @return string + */ + public function get(): string + { + // https://www.tiny.cloud/docs/configure/localization/#language + + $oLang = $this->loader->getLanguage(); + + $aLang = array( + "cs" => "cs", + "da" => "da", + "de" => "de", + "es" => "es_419", + "fr" => "fr_FR", + "it" => "it_IT", + "nl" => "nl", + "ru" => "ru" + ); + $sLang = $aLang[ $oLang->getLanguageAbbr( $oLang->getTplLanguage() ) ] ?? "en"; + + return $sLang; + } + + public function mustQuote(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/MaxHeight.php b/Application/Core/TinyMCE/Options/MaxHeight.php new file mode 100644 index 0000000..bf9e172 --- /dev/null +++ b/Application/Core/TinyMCE/Options/MaxHeight.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class MaxHeight extends AbstractOption +{ + public const KEY = 'max_height'; + + public function get(): string + { + return '90%'; + } + + public function mustQuote(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/MaxWidth.php b/Application/Core/TinyMCE/Options/MaxWidth.php new file mode 100644 index 0000000..9c564e0 --- /dev/null +++ b/Application/Core/TinyMCE/Options/MaxWidth.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class MaxWidth extends AbstractOption +{ + public const KEY = 'max_width'; + + public function get(): string + { + return '90%'; + } + + public function mustQuote(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/Menubar.php b/Application/Core/TinyMCE/Options/Menubar.php new file mode 100644 index 0000000..1993bb0 --- /dev/null +++ b/Application/Core/TinyMCE/Options/Menubar.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class Menubar extends AbstractOption +{ + public const KEY = 'menubar'; + + public function get(): string + { + return 'false'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/MinHeight.php b/Application/Core/TinyMCE/Options/MinHeight.php new file mode 100644 index 0000000..f6ca46d --- /dev/null +++ b/Application/Core/TinyMCE/Options/MinHeight.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class MinHeight extends AbstractOption +{ + public const KEY = 'min_height'; + + public function get(): string + { + return '350'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/OptionInterface.php b/Application/Core/TinyMCE/Options/OptionInterface.php new file mode 100644 index 0000000..9a2e81a --- /dev/null +++ b/Application/Core/TinyMCE/Options/OptionInterface.php @@ -0,0 +1,37 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\Loader; + +interface OptionInterface +{ + public function __construct(Loader $loader); + + public function get(): string; + + public function mustQuote(): bool; + + public function requireRegistration(): bool; +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/Plugins.php b/Application/Core/TinyMCE/Options/Plugins.php new file mode 100644 index 0000000..dac2665 --- /dev/null +++ b/Application/Core/TinyMCE/Options/Plugins.php @@ -0,0 +1,89 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\PluginList; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\PluginInterface; + +class Plugins extends AbstractOption +{ + public const KEY = 'plugins'; + + public function get(): string + { + $pluginList = oxNew(PluginList::class); + + return implode(' ', array_filter( + array_map( + function (PluginInterface $plugin) { + return $plugin->requireRegistration() ? + $plugin->getPluginName() : + null + ; + }, + $pluginList->get() + ) + )); + + $aPlugins = array( + //'advlist' => '', // '' = plugin has no buttons + 'anchor' => 'anchor', + 'autolink' => '', + 'autoresize' => '', + 'charmap' => 'charmap', + 'code' => 'code', + 'hr' => 'hr', + 'image' => 'image', + // 'imagetools' => '', // das hier klingt sehr kompliziert + 'link' => 'link unlink', + 'lists' => '', + 'media' => 'media', + 'nonbreaking' => 'nonbreaking', + 'pagebreak' => 'pagebreak', + 'paste' => 'pastetext', + 'preview' => 'preview', + 'quickbars' => '',//'quicklink quickimage quicktable', + 'searchreplace' => 'searchreplace', + 'table' => 'table', + 'visualblocks' => 'visualblocks', + 'wordcount' => '', + 'oxfullscreen' => 'fullscreen', //custom fullscreen plugin + //'oxwidget' => 'widget' + //'oxgetseourl' => 'yolo' //custom seo url plugin // wip + ); + + // plugins for newsletter emails + if ( $this->getActiveClassName() === "newsletter_main" ) { + $aPlugins["legacyoutput"] = ""; + $aPlugins["fullpage"] = "fullpage"; + } + + return 350; + } + + public function mustQuote(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/Protect.php b/Application/Core/TinyMCE/Options/Protect.php new file mode 100644 index 0000000..29ca7d2 --- /dev/null +++ b/Application/Core/TinyMCE/Options/Protect.php @@ -0,0 +1,36 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class Protect extends AbstractOption +{ + public const KEY = 'protect'; + + public function get(): string + { + // ToDo: check this regexp + + return '[ /\[\{((?!\}\]).)+\}\]/gm ]'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/QuickbarsInsertToolbar.php b/Application/Core/TinyMCE/Options/QuickbarsInsertToolbar.php new file mode 100644 index 0000000..5048924 --- /dev/null +++ b/Application/Core/TinyMCE/Options/QuickbarsInsertToolbar.php @@ -0,0 +1,66 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\PluginList; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\PluginInterface; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Quickbars; +use O3\TinyMCE\Application\Core\TinyMCE\Utils; + +class QuickbarsInsertToolbar extends AbstractOption +{ + public const KEY = 'quickbars_insert_toolbar'; + + public function get(): string + { + return implode( + ' | ', + [ + 'quicktable', + 'hr', + 'pagebreak' + ] + ); + } + + public function mustQuote(): bool + { + return true; + } + + public function requireRegistration(): bool + { + $pluginList = oxNew(PluginList::class); + + return in_array( + true, + array_map( + function (PluginInterface $plugin) { + return $plugin instanceof Quickbars; + }, + $pluginList->get(), + ) + ); + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/RelativeUrls.php b/Application/Core/TinyMCE/Options/RelativeUrls.php new file mode 100644 index 0000000..8679a15 --- /dev/null +++ b/Application/Core/TinyMCE/Options/RelativeUrls.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class RelativeUrls extends AbstractOption +{ + public const KEY = 'relative_urls'; + + public function get(): string + { + return 'true'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/Selector.php b/Application/Core/TinyMCE/Options/Selector.php new file mode 100644 index 0000000..41b4483 --- /dev/null +++ b/Application/Core/TinyMCE/Options/Selector.php @@ -0,0 +1,36 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\Loader; + +class Selector extends AbstractOption +{ + public const KEY = 'selector'; + + public function get(): string + { + return '"textarea:not(.mceNoEditor)"'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/Toolbar.php b/Application/Core/TinyMCE/Options/Toolbar.php new file mode 100644 index 0000000..d3f5484 --- /dev/null +++ b/Application/Core/TinyMCE/Options/Toolbar.php @@ -0,0 +1,80 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +use O3\TinyMCE\Application\Core\TinyMCE\Loader; +use O3\TinyMCE\Application\Core\TinyMCE\PluginList; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\PluginInterface; +use O3\TinyMCE\Application\Core\TinyMCE\ToolbarList; + +class Toolbar extends AbstractOption +{ + public const KEY = 'toolbar'; + + public function __construct( Loader $loader ) + { + parent::__construct( $loader ); + } + + public function get(): string + { + $toolbarList = oxNew(ToolbarList::class); + $list = []; + + foreach ($toolbarList->get() as $toolbar) { + $list[] = implode( + ' | ', + array_filter( + array_map( + function ($toolbarElement) { + return implode( + ' ', + $toolbarElement->getButtons() + ); + }, + $toolbar + ) + ) + ); + } + + $pluginList = oxNew(PluginList::class); + $list[] = $pluginToolbarElements = implode( + ' | ', + array_filter( + array_map( + function (PluginInterface $plugin) { + return count($plugin->getToolbarElements()) ? implode( + ' ', + $plugin->getToolbarElements() + ) : null; + }, + $pluginList->get() + ) + ) + ); + + return '["'.implode('", "', $list).'"]'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Options/ToolbarSticky.php b/Application/Core/TinyMCE/Options/ToolbarSticky.php new file mode 100644 index 0000000..26c3506 --- /dev/null +++ b/Application/Core/TinyMCE/Options/ToolbarSticky.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Options; + +class ToolbarSticky extends AbstractOption +{ + public const KEY = 'toolbar_sticky'; + + public function get(): string + { + return 'true'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/PluginList.php b/Application/Core/TinyMCE/PluginList.php new file mode 100644 index 0000000..d41cee0 --- /dev/null +++ b/Application/Core/TinyMCE/PluginList.php @@ -0,0 +1,80 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE; + +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Anchor; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Autolink; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\AutoResize; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Charmap; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Code; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\FullPage; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\FullScreen; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Hr; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Image; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Legacyoutput; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Link; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Lists; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Media; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Nonbreaking; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Pagebreak; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Paste; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Preview; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Quickbars; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Roxy; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\SearchReplace; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Table; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\Visualblocks; +use O3\TinyMCE\Application\Core\TinyMCE\Plugins\WordCount; + +class PluginList +{ + public function get(): array + { + return [ + 'anchor' => oxNew(Anchor::class), + 'autolink' => oxNew(Autolink::class), + 'autoresize' => oxNew(AutoResize::class), + 'charmap' => oxNew(Charmap::class), + 'code' => oxNew(Code::class), + 'fullpage' => oxNew(FullPage::class), + 'hr' => oxNew(Hr::class), + 'image' => oxNew(Image::class), + 'legacyoutput' => oxNew(Legacyoutput::class), + 'link' => oxNew(Link::class), + 'lists' => oxNew(Lists::class), + 'media' => oxNew(Media::class), + 'nonbreaking' => oxNew(Nonbreaking::class), + 'pagebreak' => oxNew(Pagebreak::class), + 'paste' => oxNew(Paste::class), + 'preview' => oxNew(Preview::class), + 'quickbars' => oxNew(Quickbars::class), + 'searchreplace' => oxNew(SearchReplace::class), + 'table' => oxNew(Table::class), + 'visualblocks' => oxNew(Visualblocks::class), + 'wordcount' => oxNew(WordCount::class), + 'fullscreen' => oxNew(FullScreen::class), + 'roxy' => oxNew(Roxy::class), + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/AbstractPlugin.php b/Application/Core/TinyMCE/Plugins/AbstractPlugin.php new file mode 100644 index 0000000..ac79d0a --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/AbstractPlugin.php @@ -0,0 +1,49 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +abstract class AbstractPlugin implements PluginInterface +{ + abstract public function getPluginName(): string; + + public function getToolbarElements(): array + { + return []; + } + + public function getScriptPath(): ?string + { + return null; + } + + public function requireRegistration(): bool + { + return true; + } + + public function requireScript(): bool + { + return true; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Anchor.php b/Application/Core/TinyMCE/Plugins/Anchor.php new file mode 100644 index 0000000..34b6857 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Anchor.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Anchor extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'anchor'; + } + + public function getToolbarElements(): array + { + return [ + 'anchor' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/AutoResize.php b/Application/Core/TinyMCE/Plugins/AutoResize.php new file mode 100644 index 0000000..d636d47 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/AutoResize.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class AutoResize extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'autoresize'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Autolink.php b/Application/Core/TinyMCE/Plugins/Autolink.php new file mode 100644 index 0000000..878acbd --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Autolink.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Autolink extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'autolink'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Charmap.php b/Application/Core/TinyMCE/Plugins/Charmap.php new file mode 100644 index 0000000..24a6afa --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Charmap.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Charmap extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'charmap'; + } + + public function getToolbarElements(): array + { + return [ + 'charmap' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Code.php b/Application/Core/TinyMCE/Plugins/Code.php new file mode 100644 index 0000000..1148f49 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Code.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Code extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'code'; + } + + public function getToolbarElements(): array + { + return [ + 'code' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/FullPage.php b/Application/Core/TinyMCE/Plugins/FullPage.php new file mode 100644 index 0000000..600b30a --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/FullPage.php @@ -0,0 +1,46 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +use OxidEsales\Eshop\Core\Registry; + +class FullPage extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'fullpage'; + } + + public function getToolbarElements(): array + { + return [ + 'fullpage' + ]; + } + + public function requireRegistration(): bool + { + return strtolower(Registry::getConfig()->getActiveView()->getClassKey()) === 'newsletter_main'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/FullScreen.php b/Application/Core/TinyMCE/Plugins/FullScreen.php new file mode 100644 index 0000000..368de94 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/FullScreen.php @@ -0,0 +1,49 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +use OxidEsales\Eshop\Core\Registry; + +class FullScreen extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'oxfullscreen'; + } + + public function getToolbarElements(): array + { + return [ + 'fullscreen' + ]; + } + + public function getScriptPath(): ?string + { + return Registry::getConfig()->getActiveView()->getViewConfig()->getModuleUrl( + 'tinymce-editor', + 'out/plugins/oxfullscreen/plugin.js' + ); + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Hr.php b/Application/Core/TinyMCE/Plugins/Hr.php new file mode 100644 index 0000000..dbeb162 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Hr.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Hr extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'hr'; + } + + public function getToolbarElements(): array + { + return [ + 'hr' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Image.php b/Application/Core/TinyMCE/Plugins/Image.php new file mode 100644 index 0000000..5c0effb --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Image.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Image extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'image'; + } + + public function getToolbarElements(): array + { + return [ + 'image' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Legacyoutput.php b/Application/Core/TinyMCE/Plugins/Legacyoutput.php new file mode 100644 index 0000000..67e7177 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Legacyoutput.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +use OxidEsales\Eshop\Core\Registry; + +class Legacyoutput extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'legacyoutput'; + } + + public function requireRegistration(): bool + { + return strtolower(Registry::getConfig()->getActiveView()->getClassKey()) === 'newsletter_main'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Link.php b/Application/Core/TinyMCE/Plugins/Link.php new file mode 100644 index 0000000..8e454e4 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Link.php @@ -0,0 +1,40 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Link extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'link'; + } + + public function getToolbarElements(): array + { + return [ + 'link', + 'unlink' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Lists.php b/Application/Core/TinyMCE/Plugins/Lists.php new file mode 100644 index 0000000..4f17d86 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Lists.php @@ -0,0 +1,37 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Lists extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'lists'; + } + + public function getToolbarElements(): array + { + return []; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Media.php b/Application/Core/TinyMCE/Plugins/Media.php new file mode 100644 index 0000000..25bb98d --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Media.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Media extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'media'; + } + + public function getToolbarElements(): array + { + return [ + 'media' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Nonbreaking.php b/Application/Core/TinyMCE/Plugins/Nonbreaking.php new file mode 100644 index 0000000..3b5eb0e --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Nonbreaking.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Nonbreaking extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'nonbreaking'; + } + + public function getToolbarElements(): array + { + return [ + 'nonbreaking' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Pagebreak.php b/Application/Core/TinyMCE/Plugins/Pagebreak.php new file mode 100644 index 0000000..74d04ca --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Pagebreak.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Pagebreak extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'pagebreak'; + } + + public function getToolbarElements(): array + { + return [ + 'pagebreak' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Paste.php b/Application/Core/TinyMCE/Plugins/Paste.php new file mode 100644 index 0000000..70cd785 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Paste.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Paste extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'paste'; + } + + public function getToolbarElements(): array + { + return [ + 'pastetext' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/PluginInterface.php b/Application/Core/TinyMCE/Plugins/PluginInterface.php new file mode 100644 index 0000000..2e4807b --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/PluginInterface.php @@ -0,0 +1,37 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +interface PluginInterface +{ + public function getPluginName(): string; + + public function getToolbarElements(): array; + + public function getScriptPath(): ?string; + + public function requireRegistration(): bool; + + public function requireScript(): bool; +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Preview.php b/Application/Core/TinyMCE/Plugins/Preview.php new file mode 100644 index 0000000..9f63216 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Preview.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Preview extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'preview'; + } + + public function getToolbarElements(): array + { + return [ + 'preview' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Quickbars.php b/Application/Core/TinyMCE/Plugins/Quickbars.php new file mode 100644 index 0000000..5453542 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Quickbars.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Quickbars extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'quickbars'; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Roxy.php b/Application/Core/TinyMCE/Plugins/Roxy.php new file mode 100644 index 0000000..08f30a9 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Roxy.php @@ -0,0 +1,52 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +use OxidEsales\Eshop\Core\Registry; + +class Roxy extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'roxy'; + } + + public function getScriptPath(): ?string + { + return Registry::getConfig()->getActiveView()->getViewConfig()->getModuleUrl( + 'tinymce-editor', + 'out/plugins/roxy/plugin.js' + ); + } + + public function requireRegistration(): bool + { + return false; + } + + public function requireScript(): bool + { + return (bool) Registry::getConfig()->getConfigParam("blTinyMCE_filemanager"); + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/SearchReplace.php b/Application/Core/TinyMCE/Plugins/SearchReplace.php new file mode 100644 index 0000000..6e8deda --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/SearchReplace.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class SearchReplace extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'searchreplace'; + } + + public function getToolbarElements(): array + { + return [ + 'searchreplace' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Table.php b/Application/Core/TinyMCE/Plugins/Table.php new file mode 100644 index 0000000..07a6360 --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Table.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Table extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'table'; + } + + public function getToolbarElements(): array + { + return [ + 'table' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/Visualblocks.php b/Application/Core/TinyMCE/Plugins/Visualblocks.php new file mode 100644 index 0000000..dd7211d --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/Visualblocks.php @@ -0,0 +1,39 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class Visualblocks extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'visualblocks'; + } + + public function getToolbarElements(): array + { + return [ + 'visualblocks' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Plugins/WordCount.php b/Application/Core/TinyMCE/Plugins/WordCount.php new file mode 100644 index 0000000..22776ce --- /dev/null +++ b/Application/Core/TinyMCE/Plugins/WordCount.php @@ -0,0 +1,37 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Plugins; + +class WordCount extends AbstractPlugin +{ + public function getPluginName(): string + { + return 'wordcount'; + } + + public function getToolbarElements(): array + { + return []; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/AbstractToolbar.php b/Application/Core/TinyMCE/Toolbar/AbstractToolbar.php new file mode 100644 index 0000000..1335729 --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/AbstractToolbar.php @@ -0,0 +1,29 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +abstract class AbstractToolbar implements ToolbarInterface +{ + abstract public function getButtons(): array; +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/Align.php b/Application/Core/TinyMCE/Toolbar/Align.php new file mode 100644 index 0000000..75e7f9d --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/Align.php @@ -0,0 +1,37 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class Align extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'alignleft', + 'aligncenter', + 'alignright', + 'alignjustify', + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/Blockquote.php b/Application/Core/TinyMCE/Toolbar/Blockquote.php new file mode 100644 index 0000000..e608530 --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/Blockquote.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class Blockquote extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'blockquote', + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/Color.php b/Application/Core/TinyMCE/Toolbar/Color.php new file mode 100644 index 0000000..19bad23 --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/Color.php @@ -0,0 +1,35 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class Color extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'forecolor', + 'backcolor' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/CopyPaste.php b/Application/Core/TinyMCE/Toolbar/CopyPaste.php new file mode 100644 index 0000000..7d2e128 --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/CopyPaste.php @@ -0,0 +1,36 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class CopyPaste extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'cut', + 'copy', + 'paste' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/Font.php b/Application/Core/TinyMCE/Toolbar/Font.php new file mode 100644 index 0000000..64a6509 --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/Font.php @@ -0,0 +1,37 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class Font extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'bold', + 'italic', + 'underline', + 'strikethrough', + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/Formatselect.php b/Application/Core/TinyMCE/Toolbar/Formatselect.php new file mode 100644 index 0000000..2314057 --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/Formatselect.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class Formatselect extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'formatselect', + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/Indent.php b/Application/Core/TinyMCE/Toolbar/Indent.php new file mode 100644 index 0000000..e796a03 --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/Indent.php @@ -0,0 +1,35 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class Indent extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'outdent', + 'indent', + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/Lists.php b/Application/Core/TinyMCE/Toolbar/Lists.php new file mode 100644 index 0000000..e666af0 --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/Lists.php @@ -0,0 +1,35 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class Lists extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'bullist', + 'numlist', + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/RemoveFormat.php b/Application/Core/TinyMCE/Toolbar/RemoveFormat.php new file mode 100644 index 0000000..4e2c42f --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/RemoveFormat.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class RemoveFormat extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'removeformat', + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/Subscript.php b/Application/Core/TinyMCE/Toolbar/Subscript.php new file mode 100644 index 0000000..4f48745 --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/Subscript.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class Subscript extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'subscript', + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/Superscript.php b/Application/Core/TinyMCE/Toolbar/Superscript.php new file mode 100644 index 0000000..96fb41e --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/Superscript.php @@ -0,0 +1,34 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class Superscript extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'superscript', + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/ToolbarInterface.php b/Application/Core/TinyMCE/Toolbar/ToolbarInterface.php new file mode 100644 index 0000000..1c2b2ad --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/ToolbarInterface.php @@ -0,0 +1,29 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +interface ToolbarInterface +{ + public function getButtons(): array; +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Toolbar/Undo.php b/Application/Core/TinyMCE/Toolbar/Undo.php new file mode 100644 index 0000000..641f387 --- /dev/null +++ b/Application/Core/TinyMCE/Toolbar/Undo.php @@ -0,0 +1,35 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE\Toolbar; + +class Undo extends AbstractToolbar +{ + public function getButtons(): array + { + return [ + 'undo', + 'redo' + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/ToolbarList.php b/Application/Core/TinyMCE/ToolbarList.php new file mode 100644 index 0000000..1337b67 --- /dev/null +++ b/Application/Core/TinyMCE/ToolbarList.php @@ -0,0 +1,96 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE; + +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Align; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Blockquote; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Color; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\CopyPaste; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Font; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Formatselect; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Indent; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Lists; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\RemoveFormat; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Subscript; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Superscript; +use O3\TinyMCE\Application\Core\TinyMCE\Toolbar\Undo; + +class ToolbarList +{ + public function get(): array + { + return [ + [ + 'formatselect' => oxNew(Formatselect::class), + 'font' => oxNew(Font::class), + 'color' => oxNew(Color::class), + 'align' => oxNew(Align::class), + 'subscript' => oxNew(Subscript::class), + 'superscript' => oxNew(Superscript::class), + ], + [ + 'undo' => oxNew(Undo::class), + 'copypaste' => oxNew(CopyPaste::class), + 'lists' => oxNew(Lists::class), + 'indent' => oxNew(Indent::class), + 'blockquote' => oxNew(Blockquote::class), + 'removeformat' => oxNew(RemoveFormat::class), + ] + ]; + + $all = $this->getAll(); + + if ($count && isset($all[$count])) { + return $all[$count]; + } elseif (!$count) { + $allList = []; + foreach ($all as $toolbars) { + $allList = array_merge($allList, $toolbars); + } + return $allList; + } + } + + protected function getAll(): array + { + return [ + 1 => [ + 'formatselect' => oxNew(Formatselect::class), + 'font' => oxNew(Font::class), + 'color' => oxNew(Color::class), + 'align' => oxNew(Align::class), + 'subscript' => oxNew(Subscript::class), + 'superscript' => oxNew(Superscript::class), + ], + 2 => [ + 'undo' => oxNew(Undo::class), + 'copypaste' => oxNew(CopyPaste::class), + 'lists' => oxNew(Lists::class), + 'indent' => oxNew(Indent::class), + 'blockquote' => oxNew(Blockquote::class), + 'removeformat' => oxNew(RemoveFormat::class), + ] + ]; + } +} \ No newline at end of file diff --git a/Application/Core/TinyMCE/Utils.php b/Application/Core/TinyMCE/Utils.php new file mode 100644 index 0000000..ab1a1cd --- /dev/null +++ b/Application/Core/TinyMCE/Utils.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 OXID Marat Bedoev, bestlife AG + * @copyright Copyright (c) 2023 O3-Shop (https://www.o3-shop.com) + * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) + */ + +declare(strict_types=1); + +namespace O3\TinyMCE\Application\Core\TinyMCE; + +class Utils +{ + public function quote($string): string + { + return '"'.addslashes($string).'"'; + } +} \ No newline at end of file diff --git a/Application/Core/ViewConfig.php b/Application/Core/ViewConfig.php index b87b414..5300ca1 100755 --- a/Application/Core/ViewConfig.php +++ b/Application/Core/ViewConfig.php @@ -19,312 +19,33 @@ * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) */ +declare(strict_types=1); + namespace O3\TinyMCE\Application\Core; +use O3\TinyMCE\Application\Core\TinyMCE\Loader; use OxidEsales\Eshop\Core\Registry; -use OxidEsales\Eshop\Core\UtilsServer; -/** - * funtion for adding quotes to config variables - * @param $string - * @return string - */ -function q($string) { return '"'.addslashes($string).'"'; } - -/** - * ViewConfig class wrapper for TinyMCE module. - * - * @mixin \OxidEsales\Eshop\Core\ViewConfig - */ class ViewConfig extends ViewConfig_parent { - public function loadTinyMce() + /** + * @return string + */ + public function loadTinyMce(): string { - $cfg = Registry::getConfig(); + $config = Registry::getConfig(); + $language = Registry::getLang(); - // is tinymce enabled for current controller? - $aEnabledClasses = $cfg->getConfigParam("aTinyMCE_classes") ?? []; - if (!in_array($this->getActiveClassName(), $aEnabledClasses)) return ''; + $loader = oxNew(Loader::class, $config, $language); - $oLang = Registry::getLang(); - - // filter plain cms pages - $oEditObject = $cfg->getActiveView()->getViewDataElement("edit"); - $sCoreTableName = $oEditObject->getCoreTableName(); - $aPlainCmsPages = $cfg->getConfigParam("aTinyMCE_plaincms") ?? []; - if ($sCoreTableName === "oxcontents" && in_array($oEditObject->getLoadId(), $aPlainCmsPages)) { - return $oLang->translateString("BLA_TINYMCE_PLAINCMS"); - } - - // ******************** TinyMCE Config ******************** - - // array to assign shop lang abbreviations to lang files of tinymce: shopLang => langfile (without .js ) - $aLang = array( - "cs" => "cs", - "da" => "da", - "de" => "de", - "es" => "es_419", - "fr" => "fr_FR", - "it" => "it_IT", - "nl" => "nl", - "ru" => "ru" - ); - $sLang = $aLang[$oLang->getLanguageAbbr($oLang->getTplLanguage())] ?? "en"; - - // processing editor config & other stuff - - // default config, updated on 2021-10-10 according to - $aConfig = array( - // integration options https://www.tiny.cloud/docs/configure/integration-and-setup/ - // 'auto_focus' => '', // don't think we need me, maybe for cms pages? - 'base_url' => q($this->getBaseDir().'modules/o3-shop/tinymce-editor/out/tinymce/'), - 'cache_suffix' => q('?v=20211010'), - 'selector' => '"textarea:not(.mceNoEditor)"', - - // gui options https://www.tiny.cloud/docs/configure/editor-appearance/ - 'contextmenu' => 'false', q("link linkchecker image imagetools table"), - 'min_height' => 350, - 'max_height' => q('90%'), - 'max_width' => q('90%'), - 'menubar' => 'false', - 'toolbar_sticky' => 'true', - - // content appearance https://www.tiny.cloud/docs/configure/content-appearance/ - 'content_css' => q('/out/wave/src/css/styles.min.css'), // hardcoded, for testing purposes - - // content filtering https://www.tiny.cloud/docs/configure/content-filtering/ - 'entity_encoding' => q('raw'), - 'protect' => '[ /\[\{((?!\}\]).)+\}\]/gm ]', // holy shit, this is like Weihnachten and Geburtstag all at once - - // content formatting https://www.tiny.cloud/docs/configure/content-formatting/ - - // localization https://www.tiny.cloud/docs/configure/localization/ - 'language' => q($sLang), - - // URL handling https://www.tiny.cloud/docs/configure/url-handling/ - 'document_base_url' => q($this->getBaseDir()), - 'relative_urls' => 'true', - - // plugins - 'image_advtab' => 'true' - - -/* - // old - //'spellchecker_language' => '"' . (in_array($sLang, $aLang) ? $aLang[$sLang] : 'en') . '"', - 'nowrap' => 'false', - // http://www.tinymce.com/wiki.php/Configuration:entity_encoding - // http://www.tinymce.com/wiki.php/Configuration:document_base_url - // http://www.tinymce.com/wiki.php/Configuration:relative_urls - 'plugin_preview_width' => 'window.innerWidth', - 'plugin_preview_height' => 'window.innerHeight-90', - 'code_dialog_width' => 'window.innerWidth-50', - 'code_dialog_height' => 'window.innerHeight-130', - 'imagetools_toolbar' => '"rotateleft rotateright | flipv fliph | editimage imageoptions"', - 'moxiemanager_fullscreen' => 'true', - 'insertdatetime_formats' => '[ "%d.%m.%Y", "%H:%M" ]', - 'nonbreaking_force_tab' => 'true', - // http://www.tinymce.com/wiki.php/Plugin:nonbreaking - 'urlconverter_callback' => '"urlconverter"', - 'filemanager_access_key' => '"' . md5($_SERVER['DOCUMENT_ROOT']) . '"', - 'tinymcehelper' => '"' . $this->getSelfActionLink() . 'renderPartial=1"' - */ - ); - - //merging with onfig override - $aOverrideCfg = $this->_getTinyCustConfig(); - if (!empty($aOverrideCfg) && is_array($aOverrideCfg)) { - $aConfig = array_merge($aConfig, $aOverrideCfg); - } - - - // default plugins and their buttons - $aPlugins = array( - //'advlist' => '', // '' = plugin has no buttons - 'anchor' => 'anchor', - 'autolink' => '', - 'autoresize' => '', - 'charmap' => 'charmap', - 'code' => 'code', - 'hr' => 'hr', - 'image' => 'image', - // 'imagetools' => '', // das hier klingt sehr kompliziert - 'link' => 'link unlink', - 'lists' => '', - 'media' => 'media', - 'nonbreaking' => 'nonbreaking', - 'pagebreak' => 'pagebreak', - 'paste' => 'pastetext', - 'preview' => 'preview', - 'quickbars' => '',//'quicklink quickimage quicktable', - 'searchreplace' => 'searchreplace', - 'table' => 'table', - 'visualblocks' => 'visualblocks', - 'wordcount' => '', - 'oxfullscreen' => 'fullscreen', //custom fullscreen plugin - //'oxwidget' => 'widget' - //'oxgetseourl' => 'yolo' //custom seo url plugin // wip - ); - - // plugins for newsletter emails - if ($this->getActiveClassName() === "newsletter_main") { - $aPlugins["legacyoutput"] = ""; - $aPlugins["fullpage"] = "fullpage"; - } - - - // override for active plugins - $aOverridePlgns = $cfg->getConfigParam("aTinyMCE_plugins"); - if (!empty($aOverridePlgns) && is_array($aOverridePlgns)) { - $aPlugins = array_merge($aPlugins, $aOverridePlgns); - } - $aPlugins = array_filter($aPlugins, function ($value) { - return $value !== "false"; - }); - - // array keys von $aPlugins enthalten aktive plugins - $aConfig['plugins'] = '"' . implode(' ', array_keys($aPlugins)) . '"'; - - // external plugins - $aConfig['external_plugins'] = '{ "oxfullscreen":"' . $this->getModuleUrl( - 'tinymce-editor', - 'out/plugins/oxfullscreen/plugin.js' - ) . '" '; - //$aConfig['external_plugins'] .= ', "oxwidget":"' . $this->getModuleUrl('bla-tinymce', 'plugins/oxwidget/plugin.js') . '" '; - - - $blFilemanager = $cfg->getConfigParam("blTinyMCE_filemanager"); - // @todo: $blFilemanager wiederherstellen - if ($blFilemanager) - { - $aConfig['filemanager_url'] = q(str_replace('&','&',$this->getSslSelfLink())."cl=tinyfilemanager"); - $sFilemanagerKey = md5_file(Registry::getConfig()->getConfigParam("sShopDir")."/config.inc.php"); - //$aConfig['filemanager_access_key'] = q($sFilemanagerKey); - Registry::get(UtilsServer::class)->setOxCookie("filemanagerkey", $sFilemanagerKey); - - $aConfig['external_plugins'] .= ',"roxy":' . q($this->getModuleUrl( - 'tinymce-editor', - 'out/plugins/roxy/plugin.js' - )); - } - - //$aConfig['external_plugins'] .= ',"oxgetseourl":"' . $this->getModuleUrl('bla-tinymce', 'plugins/oxgetseourl/plugin.js') . '" '; - - $aExtPlugins = $this->_getTinyExtPlugins(); - if (!empty($aExtPlugins) && is_array($aExtPlugins)) { - foreach ($aExtPlugins as $plugin => $file) { - $aConfig['external_plugins'] .= ', "' . $plugin . '": "' . $file . '" '; - } - } - $aConfig['external_plugins'] .= ' }'; - - // default toolbar buttons - $aDefaultButtons = array( - "undo redo", - //"cut copy paste", - "forecolor backcolor", - "bold italic underline strikethrough", - "alignleft aligncenter alignright alignjustify", - "bullist numlist", - "outdent indent", - "blockquote", - "subscript", - "superscript", - "formatselect", - //"fontselect", - //"fontsizeselect", - "removeformat" - ); - $aOverrideButtons = $cfg->getConfigParam("aTinyMCE_buttons"); - $aButtons = (empty($aOverrideButtons) || !is_array($aOverrideButtons)) ? $aDefaultButtons : $aOverrideButtons; - - // plugin buttons - $aPluginButtons = array_filter($aPlugins); - - // zusätzliche buttons - $aCustomButtons = $this->_getTinyToolbarControls(); - - $aButtons = array_merge(array_filter($aButtons), [" | "], array_filter($aPluginButtons), array_filter($aCustomButtons)); - $aConfig['toolbar'] = '["' . implode(" | ", $aButtons) . '"]'; - - - // compile the whole config stuff - $sConfig = ''; - foreach ($aConfig as $param => $value) { - $sConfig .= "$param: $value, "; - } - - // add init script - $sInit = 'tinymce.init({ ' . $sConfig . ' });'; - - $sCopyLongDescFromTinyMCE = 'function copyLongDescFromTinyMCE(sIdent) { - var editor = tinymce.get("editor_"+sIdent); - var content = (editor && !editor.isHidden()) ? editor.getContent() : document.getElementById("editor_"+sIdent).value; - document.getElementsByName("editval[" + sIdent + "]").item(0).value = content.replace(/\[{([^\]]*?)}\]/g, function(m) { return m.replace(/>/g, ">").replace(/</g, "<").replace(/&/g, "&") }); - return true; -} - -var origCopyLongDesc = copyLongDesc; -copyLongDesc = function(sIdent) { - if ( copyLongDescFromTinyMCE( sIdent ) ) return; - console.log("tinymce disabled, copy content from regular textarea"); - origCopyLongDesc( sIdent ); -}'; - $sUrlConverter = 'function urlconverter(url, node, on_save) { - console.log(tinyMCE.activeEditor); - if(url.indexOf("[{") == 0) return url; - return (tinyMCE.activeEditor.settings.relative_urls) ? tinyMCE.activeEditor.documentBaseURI.toRelative(url) : tinyMCE.activeEditor.documentBaseURI.toAbsolute(url); -}'; - - // adding scripts to template - $smarty = Registry::getUtilsView()->getSmarty(); - $sSufix = ($smarty->_tpl_vars["__oxid_include_dynamic"]) ? '_dynamic' : ''; - - $aScript = (array)$cfg->getGlobalParameter('scripts' . $sSufix); - $aScript[] = $sCopyLongDescFromTinyMCE; - $aScript[] = $sUrlConverter; - $aScript[] = $sInit; - $cfg->setGlobalParameter('scripts' . $sSufix, $aScript); - - $aInclude = (array)$cfg->getGlobalParameter('includes' . $sSufix); - - $aExtjs = $cfg->getConfigParam('aTinyMCE_extjs'); - if (!empty($aExtjs) && is_array($aExtjs)) { - foreach ($aExtjs as $key => $js) { - $aInclude[3][] = $js; - } - } - - $aInclude[3][] = $this->getModuleUrl('tinymce-editor', 'out/tinymce/tinymce.min.js'); - $cfg->setGlobalParameter('includes' . $sSufix, $aInclude); - - return '
  • '; - // javascript:tinymce.execCommand(\'mceToggleEditor\',false,\'editor1\'); - } - - protected function _getTinyToolbarControls() - { - $aControls = []; - - return $aControls; - } - - protected function _getTinyExtPlugins() - { - $aPlugins = Registry::getConfig()->getConfigParam("aTinyMCE_external_plugins"); - - return $aPlugins; - } - - protected function _getTinyCustConfig() - { - //$oModCfg = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingBridgeInterface::class); - //$oModCfg->get('setting-name', 'module-id'); - - $aConfig = Registry::getConfig()->getConfigParam("aTinyMCE_config"); - - return $aConfig; + return $loader->getEditorSwitch(); } } + + +// ToDo: + +// https://www.tiny.cloud/docs/tinymce/6/toolbar-configuration-options/ +// flexible MinHeight je nach Logineinstellung +// flexibles CSS basierend auf Wave +// MediaSelect Bug diff --git a/Application/Core/config.php b/Application/Core/config.php index f18dde2..4e9c968 100755 --- a/Application/Core/config.php +++ b/Application/Core/config.php @@ -19,6 +19,8 @@ * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) */ +declare(strict_types=1); + function checkAccess($action) { //if(!session_id()) die("Access Denied!"); diff --git a/Application/views/admin/de/module_options.php b/Application/views/admin/de/module_options.php index d111df7..08345ef 100644 --- a/Application/views/admin/de/module_options.php +++ b/Application/views/admin/de/module_options.php @@ -25,14 +25,8 @@ $aLang = array( 'SHOP_MODULE_blTinyMCE_filemanager' => 'Dateimanager aktivieren', 'HELP_SHOP_MODULE_blTinyMCE_filemanager' => 'Ist diese Option aktiv, können Bilder hochgeladen werden. Der Speicherort ist: out/pictures/wysiwigpro/', 'SHOP_MODULE_aTinyMCE_classes' => '

    TinyMCE für folgende Backend-Seiten laden:

    ', - 'HELP_SHOP_MODULE_aTinyMCE_classes' => 'für die Benutzung von TinyMCE in eigenen Admin Views muss hier die entsprechende View Klasse eingetragen werden, dann werden für jedes textarea je ein Editor erzeugt', - 'SHOP_MODULE_aTinyMCE_plaincms' => '

    plaintext CMS Seiten

    Für diese CMS Seiten wird TinyMCE deaktiviert.', - 'HELP_SHOP_MODULE_aTinyMCE_plaincms' => 'Einige CMS Seiten dürfen keine HTML Tags enthalten, z.B: Plaintext Emails, Email Betreffzeilen, SEO Beschreibung, etc.', + 'HELP_SHOP_MODULE_aTinyMCE_classes' => 'für die Benutzung von TinyMCE in eigenen Admin Views muss hier die entsprechende Controllerklasse eingetragen werden, dann wird für jedes Textarea je ein Editor erzeugt', 'SHOP_MODULE_aTinyMCE_extjs' => '

    Externe JS Abhängigkeiten

    ', 'HELP_SHOP_MODULE_aTinyMCE_extjs' => 'Komplette URL mit http:// bzw https:// falls der Shop über HTTPS läuft.', 'SHOP_MODULE_GROUP_tinyMceSettings' => 'TinyMCE Einstellungen & Plugins', - 'SHOP_MODULE_aTinyMCE_config' => '

    eigene TinyMCE Konfiguration (?)

    hier können Parameter für externe Plugins hinterlegt oder auch standard Werte überschreiben werden
    parameter => "wert" (mit Anführungszeichen, falls erforderlich!)', - 'SHOP_MODULE_aTinyMCE_plugins' => '

    TinyMCE Plugins aktivieren/überschreiben (?)

    Plugin hinzufügen: plugin => plugin buttons
    Plugin ohne Buttons: plugin => |
    Plugin entfernen: plugin => false', - 'SHOP_MODULE_aTinyMCE_external_plugins' => '

    externe Plugins (?)

    Eingabeformat:
    Pluginname => Pfad/zur/Datei.js | plugin buttons', - 'SHOP_MODULE_aTinyMCE_buttons' => '

    Toolbar Buttons überschreiben (?)

    es betrifft nur Buttons (Toolbar controls) unter dem ersten Punkt: "core" + Buttons für externe Plugins
    Standard Buttons:' . "" ); diff --git a/Application/views/admin/editorswitch.tpl b/Application/views/admin/editorswitch.tpl new file mode 100644 index 0000000..f45e9ee --- /dev/null +++ b/Application/views/admin/editorswitch.tpl @@ -0,0 +1,8 @@ +
  • + +
  • \ No newline at end of file diff --git a/Application/views/admin/en/module_options.php b/Application/views/admin/en/module_options.php index 55bc1ae..502c9db 100644 --- a/Application/views/admin/en/module_options.php +++ b/Application/views/admin/en/module_options.php @@ -25,14 +25,8 @@ $aLang = array( 'SHOP_MODULE_blTinyMCE_filemanager' => 'enable filemanager', 'HELP_SHOP_MODULE_blTinyMCE_filemanager' => 'When enabled, you can upload pictures into this directory: out/pictures/wysiwigpro/', 'SHOP_MODULE_aTinyMCE_classes' => '

    Enable TinyMCE for following backend pages:

    ', - 'HELP_SHOP_MODULE_aTinyMCE_classes' => 'if you want to use TinyMCE for your custom views/controllers, you need to enter their class names here.', - 'SHOP_MODULE_aTinyMCE_plaincms' => '

    Plain Text CMS pages

    TinyMCE will not be loaded for these cms pages. e.g: Plain text Emails, Email subjects, etc.', - 'HELP_SHOP_MODULE_aTinyMCE_plaincms' => 'some cms pages may not contain HTML tags, because the are used as plain text emails. email subjects or SEO description', + 'HELP_SHOP_MODULE_aTinyMCE_classes' => 'if you want to use TinyMCE for your custom controllers, you need to enter their class names here.', 'SHOP_MODULE_aTinyMCE_extjs' => '

    external JS dependencies

    (e.g. for plugins)', 'HELP_SHOP_MODULE_aTinyMCE_extjs' => 'full URL with http:// or https:// if your shop runs with HTTPS.', 'SHOP_MODULE_GROUP_tinyMceSettings' => 'TinyMCE Settings & Plugins', - 'SHOP_MODULE_aTinyMCE_config' => '

    custom TinyMCE configuration (?)

    here you can add custom config params for external plugins or overwrite default params
    param => "value" (with quotes, if required!)', - 'SHOP_MODULE_aTinyMCE_plugins' => '

    enable/overwrite TinyMCE Plugins (?)

    add plugin: plugin => plugin buttons
    add plugin without buttons: plugin => |
    disable plugin: plugin => false', - 'SHOP_MODULE_aTinyMCE_external_plugins' => '

    external plugins (?)

    example:
    pluginname => path/to/file.js | plugin buttons', - 'SHOP_MODULE_aTinyMCE_buttons' => '

    Toolbar Buttons (?)

    only for core toolbar controls and buttons for custom and external plugins!
    default buttons:' . "" ); \ No newline at end of file diff --git a/metadata.php b/metadata.php index fb6ed89..ce49a72 100755 --- a/metadata.php +++ b/metadata.php @@ -38,7 +38,8 @@ $aModule = [ ], 'templates' => [ 'TinyFilemanager.tpl' => 'o3-shop/tinymce-editor/Application/views/admin/filemanager.tpl', - 'TinyHelper.tpl' => 'o3-shop/tinymce-editor/Application/views/admin/helper.tpl' + 'TinyHelper.tpl' => 'o3-shop/tinymce-editor/Application/views/admin/helper.tpl', + 'EditorSwitch.tpl' => 'o3-shop/tinymce-editor/Application/views/admin/editorswitch.tpl' ], 'blocks' => [ [ @@ -62,29 +63,6 @@ $aModule = [ ], 'position' => 0 ], - [ - 'group' => 'tinyMceMain', - 'name' => 'aTinyMCE_plaincms', - 'type' => 'arr', - 'value' => [ - "oxadminorderplainemail", - "oxadminordernpplainemail", // bestellbenachrichtigung admin + fremdländer - "oxuserorderplainemail", - "oxuserordernpplainemail", - "oxuserorderemailendplain", // bestellbenachrichtigung user + fremdländer + abschluss - "oxordersendplainemail", // versandbestätigung - "oxregisterplainemail", - "oxregisterplainaltemail", // registrierung - "oxupdatepassinfoplainemail", // passwort update - "oxnewsletterplainemail", // newsletter - "oxemailfooterplain", // email fußtext - "oxrighttocancellegend", - "oxrighttocancellegend2", // widerrufsrecht - "oxstartmetadescription", - "oxstartmetakeywords" // META Tags - ], - 'position' => 1 - ], [ 'group' => 'tinyMceMain', 'name' => 'blTinyMCE_filemanager', @@ -98,38 +76,6 @@ $aModule = [ 'type' => 'arr', 'value' => [], 'position' => 3 - ], - - - // ################################################################# tinymce settings - - [ - 'group' => 'tinyMceSettings', - 'name' => 'aTinyMCE_config', - 'type' => 'aarr', - 'value' => [], - 'position' => 0 - ], - [ - 'group' => 'tinyMceSettings', - 'name' => 'aTinyMCE_plugins', - 'type' => 'aarr', - 'value' => [], - 'position' => 1 - ], - [ - 'group' => 'tinyMceSettings', - 'name' => 'aTinyMCE_external_plugins', - 'type' => 'aarr', - 'value' => [], - 'position' => 2 - ], - [ - 'group' => 'tinyMceSettings', - 'name' => 'aTinyMCE_buttons', - 'type' => 'arr', - 'value' => [], - 'position' => 3 ] ] ]; diff --git a/out/scripts/copyLongDesc.js b/out/scripts/copyLongDesc.js new file mode 100644 index 0000000..913d3e6 --- /dev/null +++ b/out/scripts/copyLongDesc.js @@ -0,0 +1,13 @@ +function copyLongDescFromTinyMCE(sIdent) { + var editor = tinymce.get("editor_"+sIdent); + var content = (editor && !editor.isHidden()) ? editor.getContent() : document.getElementById("editor_"+sIdent).value; + document.getElementsByName("editval[" + sIdent + "]").item(0).value = content.replace(/\[{([^\]]*?)}\]/g, function(m) { return m.replace(/>/g, ">").replace(/</g, "<").replace(/&/g, "&") }); + return true; +} + +var origCopyLongDesc = copyLongDesc; +copyLongDesc = function(sIdent) { + if ( copyLongDescFromTinyMCE( sIdent ) ) return; + console.log("tinymce disabled, copy content from regular textarea"); + origCopyLongDesc( sIdent ); +} \ No newline at end of file diff --git a/out/scripts/init.js b/out/scripts/init.js new file mode 100644 index 0000000..84d9358 --- /dev/null +++ b/out/scripts/init.js @@ -0,0 +1 @@ +tinymce.init({ 'CONFIG':'VALUES' }); \ No newline at end of file diff --git a/out/scripts/urlConverter.js b/out/scripts/urlConverter.js new file mode 100644 index 0000000..8833a1f --- /dev/null +++ b/out/scripts/urlConverter.js @@ -0,0 +1,7 @@ +function urlconverter(url, node, on_save) { + console.log(tinyMCE.activeEditor); + if(url.indexOf("[{") === 0) return url; + return (tinyMCE.activeEditor.settings.relative_urls) ? + tinyMCE.activeEditor.documentBaseURI.toRelative(url) : + tinyMCE.activeEditor.documentBaseURI.toAbsolute(url); +} \ No newline at end of file