diff --git a/composer.json b/composer.json index 05354f9..64d742f 100644 --- a/composer.json +++ b/composer.json @@ -18,10 +18,10 @@ } ], "require":{ - "php":">=7.4", + "php":"^7.4 || ^8.0", "ext-json": "*", "ext-dom": "*", - "contao/core-bundle":"^4.13" + "contao/core-bundle":"^4.13 || ^5.1" }, "require-dev": { "contao/manager-plugin": "^2.0" diff --git a/docs/TEMPLATE_VARIABLES.md b/docs/TEMPLATE_VARIABLES.md index 56cddc4..f9bbd1e 100644 --- a/docs/TEMPLATE_VARIABLES.md +++ b/docs/TEMPLATE_VARIABLES.md @@ -8,6 +8,29 @@ --- +### As Twig is not yet fully supported (Contao ^5.1), this feature will only work with Legacy-Templates) +https://docs.contao.org/dev/framework/templates/legacy/ + +> To use legacy-templates (html5) in contao ^5.1, you can force this by overwriting config.php in "/contao/config/config.php". +```php +twig = $twig; $this->requestStack = $requestStack; $this->translator = $translator; + $this->tokenManager = $tokenManager; } public function __invoke(): Response @@ -85,7 +85,7 @@ public function __invoke(): Response $configs = $this->createImportTree(...$configs); } - return new Response($this->twig->render('@ContaoComponentStyleManager/import.html.twig', [ + return $this->render('@ContaoComponentStyleManager/import.html.twig', [ 'headline' => $partial ? $this->translator->trans('tl_style_manager_import.importPartial', [], 'contao_default') : 'Import', 'messages' => Message::generate(), 'useBundleConfig' => System::getContainer()->getParameter('contao_component_style_manager.use_bundle_config'), @@ -94,12 +94,12 @@ public function __invoke(): Response 'configs' => $configs, 'form' => [ 'id' => 'style_manager_import', - 'rt' => System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue(), + 'rt' => $this->tokenManager->getDefaultTokenValue(), 'maxFileSize' => Config::get('maxFileSize'), 'uploadWidget' => $objUploader->generateMarkup() ], 'action' => [ - 'back' => str_replace('/' . self::ROUTE, '', TL_SCRIPT) . '?do=style_manager', + 'back' => str_replace('/' . self::ROUTE, '', $this->generateUrl('contao_backend')) . '?do=style_manager', ], 'label' => [ 'back' => $this->translator->trans('MSC.backBT', [], 'contao_default'), @@ -114,7 +114,7 @@ public function __invoke(): Response 'bundleConfigEmpty' => $this->translator->trans('tl_style_manager_import.bundleConfigEmpty', [], 'contao_default'), 'bundleConfigInactive' => $this->translator->trans('tl_style_manager_import.bundleConfigInactive', [], 'contao_default'), ] - ])); + ]); } /** diff --git a/src/EventListener/DataContainer/StyleManagerArchiveListener.php b/src/EventListener/DataContainer/StyleManagerArchiveListener.php index b800eb8..ed6ed74 100644 --- a/src/EventListener/DataContainer/StyleManagerArchiveListener.php +++ b/src/EventListener/DataContainer/StyleManagerArchiveListener.php @@ -10,9 +10,19 @@ use Oveleon\ContaoComponentStyleManager\Controller\BackendModule\ImportController; use Oveleon\ContaoComponentStyleManager\Model\StyleManagerArchiveModel; use Oveleon\ContaoComponentStyleManager\StyleManager\Config; +use Symfony\Component\Routing\RouterInterface; class StyleManagerArchiveListener { + + private RouterInterface $router; + + + public function __construct(RouterInterface $router) + { + $this->router = $router; + } + /** * @Callback(table="tl_style_manager_archive", target="config.onload") */ @@ -54,7 +64,7 @@ public function importConfigButton(?string $href, string $label, string $title, } return vsprintf('%s ', [ - TL_SCRIPT. '/' . ImportController::ROUTE, + $this->router->generate(ImportController::class), $class, StringUtil::specialchars($title), $attributes, @@ -77,7 +87,7 @@ public function bundleConfigButton(?string $href, string $label, string $title, } return vsprintf('%s: %s', [ - TL_SCRIPT. '/' . ImportController::ROUTE, + $this->router->generate(ImportController::class), $class, $attributes, $label, diff --git a/src/Resources/contao/dca/tl_style_manager.php b/src/Resources/contao/dca/tl_style_manager.php index 8c9219a..7315e18 100644 --- a/src/Resources/contao/dca/tl_style_manager.php +++ b/src/Resources/contao/dca/tl_style_manager.php @@ -5,11 +5,13 @@ * (c) https://www.oveleon.de/ */ +use Contao\DC_Table; + $GLOBALS['TL_DCA']['tl_style_manager'] = [ // Config 'config' => [ - 'dataContainer' => 'Table', + 'dataContainer' => DC_Table::class, 'ptable' => 'tl_style_manager_archive', 'switchToEdit' => true, 'enableVersioning' => true, diff --git a/src/Resources/contao/dca/tl_style_manager_archive.php b/src/Resources/contao/dca/tl_style_manager_archive.php index 92d2e40..904a0c1 100644 --- a/src/Resources/contao/dca/tl_style_manager_archive.php +++ b/src/Resources/contao/dca/tl_style_manager_archive.php @@ -5,10 +5,12 @@ * (c) https://www.oveleon.de/ */ +use Contao\DC_Table; + $GLOBALS['TL_DCA']['tl_style_manager_archive'] = [ // Config 'config' => [ - 'dataContainer' => 'Table', + 'dataContainer' => DC_Table::class, 'ctable' => ['tl_style_manager'], 'switchToEdit' => true, 'enableVersioning' => true, diff --git a/src/Resources/public/icons/about.svg b/src/Resources/public/icons/about.svg new file mode 100644 index 0000000..4aa6a8a --- /dev/null +++ b/src/Resources/public/icons/about.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Resources/views/import.html.twig b/src/Resources/views/import.html.twig index eb4e146..6a6229c 100644 --- a/src/Resources/views/import.html.twig +++ b/src/Resources/views/import.html.twig @@ -1,12 +1,6 @@ -{% extends "@ContaoCore/Backend/be_page.html.twig" %} +{% extends "@Contao/be_main" %} -{% block headline %} - {{ headline }} -{% endblock %} - -{% block error %}{% endblock %} - -{% block main %} +{% block main_content %} {% if messages %} {{ messages|raw }} {% endif %} @@ -88,7 +82,7 @@
' . $GLOBALS['TL_LANG']['tl_style_manager']['noStylesDefined'] . '
' . $GLOBALS['TL_LANG']['tl_style_manager']['noStylesDefined'] . '