2023-04-05 08:27:08 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of O3-Shop TinyMCE editor module.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with O3-Shop. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
2023-04-07 21:48:54 +02:00
|
|
|
* @copyright Copyright (c) 2022 Marat Bedoev, bestlife AG
|
2023-04-05 08:27:08 +02:00
|
|
|
* @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;
|
2023-04-11 01:05:06 +02:00
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\InitInstanceCallback;
|
2023-04-05 08:27:08 +02:00
|
|
|
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;
|
2023-04-06 23:54:46 +02:00
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\Promotion;
|
2023-04-05 08:27:08 +02:00
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\Protect;
|
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\QuickbarsInsertToolbar;
|
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\RelativeUrls;
|
2023-04-11 10:27:00 +02:00
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\Resize;
|
2023-04-05 08:27:08 +02:00
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\Selector;
|
2023-04-06 23:54:46 +02:00
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\Setup;
|
2023-04-07 23:11:54 +02:00
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\Skin;
|
2023-04-05 08:27:08 +02:00
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\Toolbar;
|
2023-04-05 08:53:11 +02:00
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\ToolbarMode;
|
2023-04-05 08:27:08 +02:00
|
|
|
use O3\TinyMCE\Application\Core\TinyMCE\Options\ToolbarSticky;
|
|
|
|
|
|
|
|
class Configuration
|
|
|
|
{
|
|
|
|
protected Loader $loader;
|
2023-04-08 22:47:11 +02:00
|
|
|
/** @var array<String, String> */
|
2023-04-05 08:27:08 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2023-04-05 08:53:11 +02:00
|
|
|
protected function addOption(OptionInterface $optionInstance): void
|
2023-04-05 08:27:08 +02:00
|
|
|
{
|
2023-04-10 22:47:06 +02:00
|
|
|
if (!$optionInstance->requireRegistration()) {
|
|
|
|
return;
|
|
|
|
}
|
2023-04-05 08:27:08 +02:00
|
|
|
|
|
|
|
$option = $optionInstance->get();
|
|
|
|
|
|
|
|
if ($optionInstance->mustQuote()) {
|
|
|
|
$option = (oxNew(Utils::class))->quote($option);
|
|
|
|
}
|
|
|
|
|
2023-04-05 08:53:11 +02:00
|
|
|
$this->options[$optionInstance->getKey()] = $option;
|
2023-04-05 08:27:08 +02:00
|
|
|
}
|
|
|
|
|
2023-04-07 23:34:59 +02:00
|
|
|
public function getConfig(): string
|
2023-04-05 08:27:08 +02:00
|
|
|
{
|
2023-04-07 23:34:59 +02:00
|
|
|
$sConfig = '';
|
|
|
|
|
2023-04-08 22:47:11 +02:00
|
|
|
/**
|
|
|
|
* @var string $param
|
|
|
|
* @var string $value
|
|
|
|
*/
|
2023-04-05 08:27:08 +02:00
|
|
|
foreach ($this->options as $param => $value) {
|
|
|
|
$sConfig .= "$param: $value, ";
|
|
|
|
}
|
|
|
|
|
|
|
|
return $sConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function addIntegrateOptions(): void
|
|
|
|
{
|
2023-04-10 22:47:06 +02:00
|
|
|
$this->addOption(oxNew(Setup::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(BaseUrl::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(CacheSuffix::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(Selector::class, $this->loader));
|
2023-04-11 01:05:06 +02:00
|
|
|
$this->addOption(oxNew(InitInstanceCallback::class, $this->loader));
|
2023-04-05 08:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function addGuiOptions(): void
|
|
|
|
{
|
2023-04-07 23:11:54 +02:00
|
|
|
$this->addOption(oxNew(Skin::class, $this->loader));
|
2023-04-06 23:54:46 +02:00
|
|
|
$this->addOption(oxNew(Promotion::class, $this->loader));
|
2023-04-05 08:53:11 +02:00
|
|
|
$this->addOption(oxNew(ContextMenu::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(MinHeight::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(MaxHeight::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(MaxWidth::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(Menubar::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(ToolbarSticky::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(ToolbarMode::class, $this->loader));
|
2023-04-11 10:27:00 +02:00
|
|
|
$this->addOption(oxNew(Resize::class, $this->loader));
|
2023-04-05 08:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function addContentAppearance(): void
|
|
|
|
{
|
2023-04-10 22:47:06 +02:00
|
|
|
$this->addOption(oxNew(ContentCss::class, $this->loader));
|
2023-04-05 08:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function addContentFiltering(): void
|
|
|
|
{
|
2023-04-10 22:47:06 +02:00
|
|
|
$this->addOption(oxNew(EntityEncoding::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(Protect::class, $this->loader));
|
2023-04-05 08:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function addLocalizationOptions(): void
|
|
|
|
{
|
2023-04-10 22:47:06 +02:00
|
|
|
$this->addOption(oxNew(Language::class, $this->loader));
|
2023-04-05 08:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function addUrlHandling(): void
|
|
|
|
{
|
2023-04-10 22:47:06 +02:00
|
|
|
$this->addOption(oxNew(DocumentBaseUrl::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(RelativeUrls::class, $this->loader));
|
2023-04-05 08:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function addPlugins(): void
|
|
|
|
{
|
2023-04-10 22:47:06 +02:00
|
|
|
$this->addOption(oxNew(ImageAdvtab::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(Plugins::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(ExternalPlugins::class, $this->loader));
|
|
|
|
$this->addOption(oxNew(FilemanagerUrl::class, $this->loader));
|
2023-04-05 08:53:11 +02:00
|
|
|
$this->addOption(oxNew(QuickbarsInsertToolbar::class, $this->loader));
|
2023-04-05 08:27:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function addToolbar(): void
|
|
|
|
{
|
2023-04-10 22:47:06 +02:00
|
|
|
$this->addOption(oxNew(Toolbar::class, $this->loader));
|
2023-04-05 08:27:08 +02:00
|
|
|
}
|
2023-04-05 08:53:11 +02:00
|
|
|
}
|