From 882a776aa8c56f25c58f17023d0784c9e77c95a5 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 3 Dec 2024 14:43:55 +0100 Subject: [PATCH] refactor Smarty template integration --- .../Controller/Admin/TinyFileManager.php | 3 +- Application/Core/TinyMCE/Loader.php | 3 +- Application/Model/Constants.php | 29 +++++++++++++++++ Application/views/admin/cs/module_options.php | 3 -- Application/views/admin/da/module_options.php | 3 -- Application/views/admin/fr/module_options.php | 3 -- Application/views/admin/it/module_options.php | 3 -- Application/views/admin/nl/module_options.php | 3 -- Application/views/admin/ru/module_options.php | 3 -- .../views/admin_smarty/cs/tinymce_lang.php | 32 +++++++++++++++++++ .../views/admin_smarty/da/tinymce_lang.php | 32 +++++++++++++++++++ .../views/admin_smarty/de/tinymce_lang.php | 32 +++++++++++++++++++ .../views/admin_smarty/en/tinymce_lang.php | 32 +++++++++++++++++++ .../views/admin_smarty/fr/tinymce_lang.php | 32 +++++++++++++++++++ .../views/admin_smarty/it/tinymce_lang.php | 32 +++++++++++++++++++ .../views/admin_smarty/nl/tinymce_lang.php | 32 +++++++++++++++++++ .../views/admin_smarty/ru/tinymce_lang.php | 32 +++++++++++++++++++ .../tinymce_translations.php} | 7 ++-- .../tinymce_translations.php} | 7 ++-- metadata.php | 15 +++++---- .../smarty/admin/tpl}/editorswitch.tpl | 0 .../smarty/admin/tpl}/filemanager.tpl | 0 .../bottomnaviitem_admin_bottomnaviitem.tpl | 0 23 files changed, 307 insertions(+), 31 deletions(-) create mode 100644 Application/Model/Constants.php delete mode 100644 Application/views/admin/cs/module_options.php delete mode 100644 Application/views/admin/da/module_options.php delete mode 100644 Application/views/admin/fr/module_options.php delete mode 100644 Application/views/admin/it/module_options.php delete mode 100644 Application/views/admin/nl/module_options.php delete mode 100644 Application/views/admin/ru/module_options.php create mode 100644 Application/views/admin_smarty/cs/tinymce_lang.php create mode 100644 Application/views/admin_smarty/da/tinymce_lang.php create mode 100644 Application/views/admin_smarty/de/tinymce_lang.php create mode 100644 Application/views/admin_smarty/en/tinymce_lang.php create mode 100644 Application/views/admin_smarty/fr/tinymce_lang.php create mode 100644 Application/views/admin_smarty/it/tinymce_lang.php create mode 100644 Application/views/admin_smarty/nl/tinymce_lang.php create mode 100644 Application/views/admin_smarty/ru/tinymce_lang.php rename Application/views/{admin/de/module_options.php => de/tinymce_translations.php} (96%) rename Application/views/{admin/en/module_options.php => en/tinymce_translations.php} (95%) rename {Application/views/admin => views/smarty/admin/tpl}/editorswitch.tpl (100%) rename {Application/views/admin => views/smarty/admin/tpl}/filemanager.tpl (100%) rename {Application/views => views/smarty}/blocks/admin/bottomnaviitem_admin_bottomnaviitem.tpl (100%) diff --git a/Application/Controller/Admin/TinyFileManager.php b/Application/Controller/Admin/TinyFileManager.php index a8a61b8..8eb5b9f 100755 --- a/Application/Controller/Admin/TinyFileManager.php +++ b/Application/Controller/Admin/TinyFileManager.php @@ -23,9 +23,10 @@ declare(strict_types=1); namespace O3\TinyMCE\Application\Controller\Admin; +use O3\TinyMCE\Application\Model\Constants; use OxidEsales\Eshop\Application\Controller\Admin\AdminController; class TinyFileManager extends AdminController { - protected $_sThisTemplate = "TinyFilemanager.tpl"; + protected $_sThisTemplate = '@' . Constants::OXID_MODULE_ID.'/admin/TinyFilemanager.tpl'; } diff --git a/Application/Core/TinyMCE/Loader.php b/Application/Core/TinyMCE/Loader.php index 2024514..2b1cb23 100644 --- a/Application/Core/TinyMCE/Loader.php +++ b/Application/Core/TinyMCE/Loader.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace O3\TinyMCE\Application\Core\TinyMCE; +use O3\TinyMCE\Application\Model\Constants; use OxidEsales\Eshop\Core\Config; use OxidEsales\Eshop\Core\Exception\FileException; use OxidEsales\Eshop\Core\Language; @@ -62,7 +63,7 @@ class Loader $this->registerIncludes(); $smarty = Registry::getUtilsView()->getSmarty(); - return $smarty->fetch('EditorSwitch.tpl'); + return $smarty->fetch('@' . Constants::OXID_MODULE_ID.'/admin/EditorSwitch.tpl'); } /** diff --git a/Application/Model/Constants.php b/Application/Model/Constants.php new file mode 100644 index 0000000..6db77dc --- /dev/null +++ b/Application/Model/Constants.php @@ -0,0 +1,29 @@ + + * + * @copyright Copyright (c) 2022 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\Model; + +class Constants +{ + public const OXID_MODULE_ID = 'o3-tinymce-editor'; +} diff --git a/Application/views/admin/cs/module_options.php b/Application/views/admin/cs/module_options.php deleted file mode 100644 index b929ccc..0000000 --- a/Application/views/admin/cs/module_options.php +++ /dev/null @@ -1,3 +0,0 @@ - + * + * @copyright Copyright (c) 2022 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); + +$sLangName = 'English'; + +// ------------------------------- +// RESOURCE IDENTITFIER = STRING +// ------------------------------- + +$aLang = include __DIR__."/../../en/tinymce_translations.php"; + +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin_smarty/da/tinymce_lang.php b/Application/views/admin_smarty/da/tinymce_lang.php new file mode 100644 index 0000000..03d3b4f --- /dev/null +++ b/Application/views/admin_smarty/da/tinymce_lang.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 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); + +$sLangName = 'English'; + +// ------------------------------- +// RESOURCE IDENTITFIER = STRING +// ------------------------------- + +$aLang = include __DIR__."/../../en/tinymce_translations.php"; + +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin_smarty/de/tinymce_lang.php b/Application/views/admin_smarty/de/tinymce_lang.php new file mode 100644 index 0000000..9010676 --- /dev/null +++ b/Application/views/admin_smarty/de/tinymce_lang.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 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); + +$sLangName = 'Deutsch'; + +// ------------------------------- +// RESOURCE IDENTITFIER = STRING +// ------------------------------- + +$aLang = include __DIR__."/../../de/tinymce_translations.php"; + +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin_smarty/en/tinymce_lang.php b/Application/views/admin_smarty/en/tinymce_lang.php new file mode 100644 index 0000000..9010676 --- /dev/null +++ b/Application/views/admin_smarty/en/tinymce_lang.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 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); + +$sLangName = 'Deutsch'; + +// ------------------------------- +// RESOURCE IDENTITFIER = STRING +// ------------------------------- + +$aLang = include __DIR__."/../../de/tinymce_translations.php"; + +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin_smarty/fr/tinymce_lang.php b/Application/views/admin_smarty/fr/tinymce_lang.php new file mode 100644 index 0000000..03d3b4f --- /dev/null +++ b/Application/views/admin_smarty/fr/tinymce_lang.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 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); + +$sLangName = 'English'; + +// ------------------------------- +// RESOURCE IDENTITFIER = STRING +// ------------------------------- + +$aLang = include __DIR__."/../../en/tinymce_translations.php"; + +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin_smarty/it/tinymce_lang.php b/Application/views/admin_smarty/it/tinymce_lang.php new file mode 100644 index 0000000..03d3b4f --- /dev/null +++ b/Application/views/admin_smarty/it/tinymce_lang.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 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); + +$sLangName = 'English'; + +// ------------------------------- +// RESOURCE IDENTITFIER = STRING +// ------------------------------- + +$aLang = include __DIR__."/../../en/tinymce_translations.php"; + +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin_smarty/nl/tinymce_lang.php b/Application/views/admin_smarty/nl/tinymce_lang.php new file mode 100644 index 0000000..03d3b4f --- /dev/null +++ b/Application/views/admin_smarty/nl/tinymce_lang.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 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); + +$sLangName = 'English'; + +// ------------------------------- +// RESOURCE IDENTITFIER = STRING +// ------------------------------- + +$aLang = include __DIR__."/../../en/tinymce_translations.php"; + +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin_smarty/ru/tinymce_lang.php b/Application/views/admin_smarty/ru/tinymce_lang.php new file mode 100644 index 0000000..03d3b4f --- /dev/null +++ b/Application/views/admin_smarty/ru/tinymce_lang.php @@ -0,0 +1,32 @@ + + * + * @copyright Copyright (c) 2022 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); + +$sLangName = 'English'; + +// ------------------------------- +// RESOURCE IDENTITFIER = STRING +// ------------------------------- + +$aLang = include __DIR__."/../../en/tinymce_translations.php"; + +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/Application/views/admin/de/module_options.php b/Application/views/de/tinymce_translations.php similarity index 96% rename from Application/views/admin/de/module_options.php rename to Application/views/de/tinymce_translations.php index 99034bc..f101354 100644 --- a/Application/views/admin/de/module_options.php +++ b/Application/views/de/tinymce_translations.php @@ -19,8 +19,10 @@ * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) */ -$sLangName = 'Deutsch'; -$aLang = [ +// @codeCoverageIgnoreStart +declare(strict_types=1); + +return [ 'charset' => 'UTF-8', 'TINYMCE_TOGGLE' => 'Editor zeigen/verstecken', 'TINYMCE_PLAINCMS' => 'Der Editor wurde für diese Seite deaktiviert, weil sie keine HTML Formatierung enthalten darf ', @@ -31,3 +33,4 @@ $aLang = [ '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_GROUP_tinyMceSettings' => 'TinyMCE Einstellungen & Plugins', ]; +// @codeCoverageIgnoreStart \ No newline at end of file diff --git a/Application/views/admin/en/module_options.php b/Application/views/en/tinymce_translations.php similarity index 95% rename from Application/views/admin/en/module_options.php rename to Application/views/en/tinymce_translations.php index 5e0da4e..8e7306f 100644 --- a/Application/views/admin/en/module_options.php +++ b/Application/views/en/tinymce_translations.php @@ -19,8 +19,10 @@ * @license https://www.gnu.org/licenses/gpl-3.0 GNU General Public License 3 (GPLv3) */ -$sLangName = 'English'; -$aLang = [ +// @codeCoverageIgnoreStart +declare(strict_types=1); + +return [ 'charset' => 'UTF-8', 'TINYMCE_TOGGLE' => 'toggle editor', 'TINYMCE_PLAINCMS' => 'The editor was disabled for this page because it may not contain HTML code', @@ -31,3 +33,4 @@ $aLang = [ '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_GROUP_tinyMceSettings' => 'TinyMCE Settings & Plugins', ]; +// @codeCoverageIgnoreEnd \ No newline at end of file diff --git a/metadata.php b/metadata.php index 622cc41..f5d67a2 100755 --- a/metadata.php +++ b/metadata.php @@ -22,14 +22,15 @@ declare(strict_types=1); use O3\TinyMCE\Application\Core\Setup\Events; +use O3\TinyMCE\Application\Model\Constants; $sMetadataVersion = '2.1'; $aModule = [ - 'id' => 'o3-tinymce-editor', + 'id' => Constants::OXID_MODULE_ID, 'title' => 'TinyMCE Editor', 'description' => 'TinyMCE 6 integration for O3-Shop, ported to OXID eShop', 'thumbnail' => 'logo.png', - 'version' => '1.1.0', + 'version' => '2.0.0', 'author' => 'D3 Data Development, O3-Shop, Marat Bedoev', 'url' => 'https://www.o3-shop.com/', 'extend' => [ @@ -39,14 +40,14 @@ $aModule = [ 'tinyfilemanager' => O3\TinyMCE\Application\Controller\Admin\TinyFileManager::class, ], 'templates' => [ - 'TinyFilemanager.tpl' => 'o3-shop/tinymce-editor/Application/views/admin/filemanager.tpl', - 'EditorSwitch.tpl' => 'o3-shop/tinymce-editor/Application/views/admin/editorswitch.tpl', + '@' . Constants::OXID_MODULE_ID.'/admin/TinyFilemanager.tpl' => 'views/smarty/admin/tpl/filemanager.tpl', + '@' . Constants::OXID_MODULE_ID.'/admin/EditorSwitch.tpl' => 'views/smarty/admin/tpl/editorswitch.tpl', ], 'blocks' => [ [ - 'template' => 'bottomnaviitem.tpl', - 'block' => 'admin_bottomnaviitem', - 'file' => 'Application/views/blocks/admin/bottomnaviitem_admin_bottomnaviitem.tpl', + 'template' => 'bottomnaviitem.tpl', + 'block' => 'admin_bottomnaviitem', + 'file' => 'views/smarty/blocks/admin/bottomnaviitem_admin_bottomnaviitem.tpl', ], ], 'settings' => [ diff --git a/Application/views/admin/editorswitch.tpl b/views/smarty/admin/tpl/editorswitch.tpl similarity index 100% rename from Application/views/admin/editorswitch.tpl rename to views/smarty/admin/tpl/editorswitch.tpl diff --git a/Application/views/admin/filemanager.tpl b/views/smarty/admin/tpl/filemanager.tpl similarity index 100% rename from Application/views/admin/filemanager.tpl rename to views/smarty/admin/tpl/filemanager.tpl diff --git a/Application/views/blocks/admin/bottomnaviitem_admin_bottomnaviitem.tpl b/views/smarty/blocks/admin/bottomnaviitem_admin_bottomnaviitem.tpl similarity index 100% rename from Application/views/blocks/admin/bottomnaviitem_admin_bottomnaviitem.tpl rename to views/smarty/blocks/admin/bottomnaviitem_admin_bottomnaviitem.tpl