[TASK] Decouple adminPanel from frontend

The admin panel has been extracted into an own extension. To enable
users to de-activate the admin panel completely, the hard coupling
between the extension and other parts of the core had to be resolved.

With this change, the initialization of both adminPanel and feedit
were moved into PSR-15 middlewares. Additionally all parameters
related to the adminPanel were removed from the FrontendBackend-
UserAuthentication.

As feedit is tigthly coupled with the adminPanel some changes had
to be made to its initialization, too.

The flow of the adminPanel initialization and rendering were
streamlined to allow modules to make use of the request object.

Due to these changes in the control flow of the application the
two existing tests were removed and new tests will be rewritten
once the API is declared as stable.

Releases: master
Resolves: #84641
Change-Id: I72beefde0d792d3f4295c45aa27204c817d2de7a
Reviewed-on: https://review.typo3.org/56558
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
This commit is contained in:
Susanne Moog 2018-04-05 13:09:41 +02:00 committed by Benni Mack
parent eab6640e88
commit 1857c6ddc7
4 changed files with 99 additions and 4 deletions

View file

@ -13,7 +13,7 @@ namespace TYPO3\CMS\Feedit;
* *
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
use TYPO3\CMS\Adminpanel\View\AdminPanelView; use TYPO3\CMS\Adminpanel\Service\EditToolbarService;
use TYPO3\CMS\Backend\FrontendBackendUserAuthentication; use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Imaging\IconFactory;
@ -97,8 +97,9 @@ class FrontendEditPanel
$hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']; $hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
$panel = ''; $panel = '';
if (isset($allow['toolbar']) && $this->backendUser->adminPanel instanceof AdminPanelView) { if (isset($allow['toolbar'])) {
$panel .= $this->backendUser->adminPanel->ext_makeToolBar(); $editToolbarService = GeneralUtility::makeInstance(EditToolbarService::class);
$panel .= $editToolbarService->createToolbar();
} }
if (isset($allow['edit'])) { if (isset($allow['edit'])) {
$icon = '<span title="' . $this->backendUser->extGetLL('p_editRecord') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render('inline') . '</span>'; $icon = '<span title="' . $this->backendUser->extGetLL('p_editRecord') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render('inline') . '</span>';

View file

@ -0,0 +1,67 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Feedit\Middleware;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
/**
* PSR-15 middleware initializing frontend editing
*/
class FrontendEditInitiator implements MiddlewareInterface
{
/**
* Process an incoming server request and return a response, optionally delegating
* response creation to a handler.
*
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
if ($GLOBALS['BE_USER'] instanceof FrontendBackendUserAuthentication) {
$config = $GLOBALS['BE_USER']->getTSConfigProp('admPanel');
$active = (int)$GLOBALS['TSFE']->displayEditIcons === 1 || (int)$GLOBALS['TSFE']->displayFieldEditIcons === 1;
if ($active && isset($config['enable.'])) {
foreach ($config['enable.'] as $value) {
if ($value) {
if ($GLOBALS['TSFE'] instanceof TypoScriptFrontendController) {
// Grab the Page TSConfig property that determines which controller to use.
$pageTSConfig = $GLOBALS['TSFE']->getPagesTSconfig();
$controllerKey = $pageTSConfig['TSFE.']['frontendEditingController'] ?? 'default';
} else {
$controllerKey = 'default';
}
$controllerClass = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController'][$controllerKey];
if ($controllerClass) {
$GLOBALS['BE_USER']->frontendEdit = GeneralUtility::makeInstance($controllerClass);
}
break;
}
}
}
}
return $handler->handle($request);
}
}

View file

@ -0,0 +1,21 @@
<?php
/**
* An array consisting of implementations of middlewares for a middleware stack to be registered
* 'stackname' => [
* 'middleware-identifier' => [
* 'target' => classname or callable
* 'before/after' => array of dependencies
* ]
* ]
*/
return [
'frontend' => [
'typo3/cms-frontendedit/initiator' => [
'target' => \TYPO3\CMS\Feedit\Middleware\FrontendEditInitiator::class,
'after' => [
'typo3/cms-adminpanel/initiator',
'typo3/cms-frontend/page-resolver',
]
],
]
];

View file

@ -13,7 +13,13 @@
"sort-packages": true "sort-packages": true
}, },
"require": { "require": {
"typo3/cms-core": "9.2.*@dev" "typo3/cms-adminpanel": "9.2.*@dev",
"typo3/cms-backend": "9.2.*@dev",
"typo3/cms-core": "9.2.*@dev",
"typo3/cms-frontend": "9.2.*@dev",
"psr/http-message": "~1.0",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0"
}, },
"conflict": { "conflict": {
"typo3/cms": "*" "typo3/cms": "*"