[TASK] Support v11 + v12

This commit is contained in:
Georg Ringer 2022-12-29 09:22:43 +01:00
parent 652ea1b1ce
commit 5b7ddfc366
12 changed files with 179 additions and 61 deletions

View file

@ -0,0 +1,43 @@
<?php
/*
* 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!
*/
namespace TYPO3\CMS\Feedit\ContentObject;
use TYPO3\CMS\Frontend\ContentObject\AbstractContentObject;
/**
* Contains EDITPANEL class object.
*/
class EditPanelContentObject extends AbstractContentObject
{
/**
* Rendering the cObject, EDITPANEL
*
* @param array $conf Array of TypoScript properties
* @return string Output
*/
public function render($conf = [])
{
$theValue = '';
die('xxxx');
if ($GLOBALS['TSFE']->isBackendUserLoggedIn()) {
$theValue = $this->cObj->editPanel($theValue, $conf);
}
if (isset($conf['stdWrap.'])) {
$theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
}
return $theValue;
}
}

View file

@ -64,11 +64,12 @@ class FrontendEditDataHandler
public function editAction() public function editAction()
{ {
// Commands // Commands
list($table, $uid) = explode(':', $this->configuration['record']); $split= explode(':', (string)($this->configuration['record'] ?? ''));
$uid = (int)$uid; $table = $split[0] ?? '';
$cmd = $this->configuration['cmd']; $uid = (int)($split[1] ?? 0);
$cmd = $this->configuration['cmd'] ?? '';
// Look for some configuration data that indicates we should save. // Look for some configuration data that indicates we should save.
if (($this->configuration['doSave'] || $this->configuration['update'] || $this->configuration['update_close']) && is_array($this->configuration['data'])) { if ((($this->configuration['doSave'] ?? '') || ($this->configuration['update'] ?? '') || ($this->configuration['update_close'] ?? '')) && is_array($this->configuration['data'] ?? null)) {
$cmd = 'save'; $cmd = 'save';
} }
if ($cmd === 'save' || $cmd && $table && $uid && isset($GLOBALS['TCA'][$table])) { if ($cmd === 'save' || $cmd && $table && $uid && isset($GLOBALS['TCA'][$table])) {

View file

@ -1,4 +1,5 @@
<?php <?php
namespace TYPO3\CMS\Feedit; namespace TYPO3\CMS\Feedit;
/* /*
@ -25,6 +26,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Feedit\Service\EditToolbarService; use TYPO3\CMS\Feedit\Service\EditToolbarService;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
/** /**
@ -61,16 +63,16 @@ class FrontendEditPanel
/** /**
* Constructor for the edit panel * Constructor for the edit panel
* *
* @param mixed $_ Previous the database connection
* @param TypoScriptFrontendController $frontendController * @param TypoScriptFrontendController $frontendController
* @param FrontendBackendUserAuthentication $backendUser * @param FrontendBackendUserAuthentication $backendUser
*/ */
public function __construct($_ = null, TypoScriptFrontendController $frontendController = null, FrontendBackendUserAuthentication $backendUser = null) public function __construct(ContentObjectRenderer $contentObjectRenderer, TypoScriptFrontendController $frontendController = null, FrontendBackendUserAuthentication $backendUser = null)
{ {
$this->frontendController = $frontendController ?: $GLOBALS['TSFE']; $this->frontendController = $frontendController ?: $GLOBALS['TSFE'];
$this->backendUser = $backendUser ?: $GLOBALS['BE_USER']; $this->backendUser = $backendUser ?: $GLOBALS['BE_USER'];
$this->cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class); # $this->cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
$this->cObj->start([]); # $this->cObj->start([]);
$this->cObj = $contentObjectRenderer;
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_tsfe.xlf'); $this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_tsfe.xlf');
} }
@ -111,7 +113,7 @@ class FrontendEditPanel
} }
if (isset($allow['edit'])) { if (isset($allow['edit'])) {
$icon = '<span title="' . $this->getLabel('p_editRecord') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render('inline') . '</span>'; $icon = '<span title="' . $this->getLabel('p_editRecord') . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render('inline') . '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'edit', $dataArr['_LOCALIZED_UID'] ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord); $panel .= $this->editPanelLinkWrap($icon, $formName, 'edit', isset($dataArr['_LOCALIZED_UID']) ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord);
} }
// Hiding in workspaces because implementation is incomplete // Hiding in workspaces because implementation is incomplete
if (isset($allow['move']) && $sortField && $this->backendUser->workspace === 0) { if (isset($allow['move']) && $sortField && $this->backendUser->workspace === 0) {
@ -122,7 +124,7 @@ class FrontendEditPanel
} }
// Hiding in workspaces because implementation is incomplete // Hiding in workspaces because implementation is incomplete
// Hiding for localizations because it is unknown what should be the function in that case // Hiding for localizations because it is unknown what should be the function in that case
if (isset($allow['hide']) && $hideField && $this->backendUser->workspace === 0 && !$dataArr['_LOCALIZED_UID']) { if (isset($allow['hide']) && $hideField && $this->backendUser->workspace === 0 && !($dataArr['_LOCALIZED_UID'] ?? 0)) {
if ($dataArr[$hideField]) { if ($dataArr[$hideField]) {
$icon = $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render('inline'); $icon = $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render('inline');
$panel .= $this->editPanelLinkWrap($icon, $formName, 'unhide'); $panel .= $this->editPanelLinkWrap($icon, $formName, 'unhide');
@ -146,14 +148,16 @@ class FrontendEditPanel
} }
// Hiding in workspaces because implementation is incomplete // Hiding in workspaces because implementation is incomplete
// Hiding for localizations because it is unknown what should be the function in that case // Hiding for localizations because it is unknown what should be the function in that case
if (isset($allow['delete']) && $this->backendUser->workspace === 0 && !$dataArr['_LOCALIZED_UID']) { if (isset($allow['delete']) && $this->backendUser->workspace === 0 && !($dataArr['_LOCALIZED_UID'] ?? 0)) {
$icon = '<span title="' . $this->getLabel('p_delete') . '">' $icon = '<span title="' . $this->getLabel('p_delete') . '">'
. $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render('inline') . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render('inline')
. '</span>'; . '</span>';
$panel .= $this->editPanelLinkWrap($icon, $formName, 'delete', '', $this->getLabel('p_deleteConfirm')); $panel .= $this->editPanelLinkWrap($icon, $formName, 'delete', '', $this->getLabel('p_deleteConfirm'));
} }
// Final // Final
$labelTxt = $this->cObj->stdWrap($conf['label'], $conf['label.']); // $labelTxt = $this->cObj->stdWrap($conf['label'] ?? '', $conf['label.'] ?? []);
$labelTxt = '';
foreach ((array)$hiddenFields as $name => $value) { foreach ((array)$hiddenFields as $name => $value) {
$hiddenFieldString .= '<input type="hidden" name="TSFE_EDIT[' . htmlspecialchars($name) . ']" value="' . htmlspecialchars($value) . '"/>' . LF; $hiddenFieldString .= '<input type="hidden" name="TSFE_EDIT[' . htmlspecialchars($name) . ']" value="' . htmlspecialchars($value) . '"/>' . LF;
} }
@ -170,30 +174,30 @@ class FrontendEditPanel
</div> </div>
</form>'; </form>';
// Wrap the panel // // Wrap the panel
if ($conf['innerWrap']) { // if ($conf['innerWrap']) {
$panel = $this->cObj->wrap($panel, $conf['innerWrap']); // $panel = $this->cObj->wrap($panel, $conf['innerWrap']);
} // }
if ($conf['innerWrap.']) { // if ($conf['innerWrap.']) {
$panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']); // $panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']);
} // }
//
// Wrap the complete panel // // Wrap the complete panel
if ($conf['outerWrap']) { // if ($conf['outerWrap']) {
$panel = $this->cObj->wrap($panel, $conf['outerWrap']); // $panel = $this->cObj->wrap($panel, $conf['outerWrap']);
} // }
if ($conf['outerWrap.']) { // if ($conf['outerWrap.']) {
$panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']); // $panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']);
} // }
if ($conf['printBeforeContent']) { if ($conf['printBeforeContent'] ?? false) {
$finalOut = $panel . $content; $finalOut = $panel . $content;
} else { } else {
$finalOut = $content . $panel; $finalOut = $content . $panel;
} }
$hidden = $this->isDisabled($table, $dataArr) ? ' typo3-feedit-element-hidden' : ''; $hidden = $this->isDisabled($table, $dataArr) ? ' typo3-feedit-element-hidden' : '';
$outerWrapConfig = $conf['stdWrap.'] ?? ['wrap' => '<div class="typo3-feedit-element' . $hidden . '">|</div>']; // $outerWrapConfig = $conf['stdWrap.'] ?? ['wrap' => '<div class="typo3-feedit-element' . $hidden . '">|</div>'];
$finalOut = $this->cObj->stdWrap($finalOut, $outerWrapConfig); // $finalOut = $this->cObj->stdWrap($finalOut, $outerWrapConfig);
return $finalOut; return $finalOut;
} }
@ -213,7 +217,7 @@ class FrontendEditPanel
* @param string $fieldList * @param string $fieldList
* @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content. * @return string The input content string, possibly with edit icons added (not necessarily in the end but just after the last string of normal content.
*/ */
public function editIcons($content, $params, array $conf = [], $currentRecord = '', array $dataArr = [], $addUrlParamStr = '', $table, $editUid, $fieldList) public function editIcons($content, $params, array $conf = [], $currentRecord = '', array $dataArr = [], $addUrlParamStr = '', $table = '', $editUid = 0, $fieldList = '')
{ {
// Special content is about to be shown, so the cache must be disabled. // Special content is about to be shown, so the cache must be disabled.
$this->frontendController->set_no_cache('Display frontend edit icons', true); $this->frontendController->set_no_cache('Display frontend edit icons', true);

View file

@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace TYPO3\CMS\Feedit\Hooks;
use TYPO3\CMS\Adminpanel\Service\ConfigurationService;
use TYPO3\CMS\Adminpanel\Utility\StateUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
use TYPO3\CMS\Feedit\FrontendEditPanel;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectStdWrapHookInterface;
class StdWrapEditPanelHook implements ContentObjectStdWrapHookInterface
{
public function __construct()
{
}
public function stdWrapPreProcess($content, array $configuration, ContentObjectRenderer &$parentObject)
{
return $content;
}
public function stdWrapOverride($content, array $configuration, ContentObjectRenderer &$parentObject)
{
return $content;
}
public function stdWrapProcess($content, array $configuration, ContentObjectRenderer &$parentObject)
{
return $content;
}
public function stdWrapPostProcess($content, array $configuration, ContentObjectRenderer &$parentObject)
{
$configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
$user = $this->getFrontendBackendUser();
if ($user && ($configuration['editPanel'] ?? false) && StateUtility::isOpen() && $configurationService->getConfigurationOption('edit', 'displayIcons')) {
[$table, $uid] = explode(':', $parentObject->currentRecord);
$allowedActions = $user->getAllowedEditActions($table, $configuration['editPanel.'] ?? [], $parentObject->data['pid']);
$frontendEditPanel = GeneralUtility::makeInstance(FrontendEditPanel::class, $parentObject);
return $frontendEditPanel->editPanel(
$content,
$configuration['editPanel.'] ?? [],
$parentObject->currentRecord,
$parentObject->data,
'tt_content',
$allowedActions
);
}
return $content;
}
protected function getFrontendBackendUser()
{
return $GLOBALS['BE_USER'];
}
}

View file

@ -57,7 +57,7 @@ class FrontendEditInitiator implements MiddlewareInterface
if ($active && isset($config['enable.'])) { if ($active && isset($config['enable.'])) {
foreach ($config['enable.'] as $value) { foreach ($config['enable.'] as $value) {
if ($value) { if ($value) {
$parameters = $request->getParsedBody()['TSFE_EDIT'] ?? $request->getQueryParams()['TSFE_EDIT'] ?? null; $parameters = $request->getParsedBody()['TSFE_EDIT'] ?? $request->getQueryParams()['TSFE_EDIT'] ?? [];
if ($this->isValidEditAction($parameters)) { if ($this->isValidEditAction($parameters)) {
GeneralUtility::makeInstance(FrontendEditDataHandler::class, $parameters)->editAction(); GeneralUtility::makeInstance(FrontendEditDataHandler::class, $parameters)->editAction();
} }
@ -80,10 +80,10 @@ class FrontendEditInitiator implements MiddlewareInterface
if (!is_array($parameters)) { if (!is_array($parameters)) {
return false; return false;
} }
if ($parameters['cancel']) { if ($parameters['cancel'] ?? false) {
unset($parameters['cmd']); unset($parameters['cmd']);
} else { } else {
$cmd = (string)$parameters['cmd']; $cmd = (string)($parameters['cmd'] ?? '');
if (($cmd !== 'edit' || is_array($parameters['data']) && ($parameters['doSave'] || $parameters['update'] || $parameters['update_close'])) && $cmd !== 'new') { if (($cmd !== 'edit' || is_array($parameters['data']) && ($parameters['doSave'] || $parameters['update'] || $parameters['update_close'])) && $cmd !== 'new') {
// $cmd can be a command like "hide" or "move". If $cmd is "edit" or "new" it's an indication to show the formfields. But if data is sent with update-flag then $cmd = edit is accepted because edit may be sent because of .keepGoing flag. // $cmd can be a command like "hide" or "move". If $cmd is "edit" or "new" it's an indication to show the formfields. But if data is sent with update-flag then $cmd = edit is accepted because edit may be sent because of .keepGoing flag.
return true; return true;

View file

@ -44,7 +44,6 @@ class EditModule extends AbstractModule implements PageSettingsProviderInterface
*/ */
public function __construct(UriBuilder $uriBuilder) public function __construct(UriBuilder $uriBuilder)
{ {
parent::__construct();
$this->uriBuilder = $uriBuilder; $this->uriBuilder = $uriBuilder;
} }

View file

@ -50,7 +50,7 @@ class EditToolbarService
$iconFactory = GeneralUtility::makeInstance(IconFactory::class); $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$tsfe = $this->getTypoScriptFrontendController(); $tsfe = $this->getTypoScriptFrontendController();
// If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead: // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
$moduleName = BackendUtility::getPagesTSconfig($tsfe->page['uid'])['mod.']['newContentElementWizard.']['override'] ?? 'new_content_element'; $moduleName = BackendUtility::getPagesTSconfig($tsfe->page['uid'])['mod.']['newContentElementWizard.']['override'] ?? 'new_content_element_wizard';
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$perms = $this->getBackendUser()->calcPerms($tsfe->page); $perms = $this->getBackendUser()->calcPerms($tsfe->page);
$langAllowed = $this->getBackendUser()->checkLanguageAccess($languageAspect->getId()); $langAllowed = $this->getBackendUser()->checkLanguageAccess($languageAspect->getId());

View file

@ -9,3 +9,11 @@ services:
TYPO3\CMS\Feedit\Modules\EditModule: TYPO3\CMS\Feedit\Modules\EditModule:
public: true public: true
TYPO3\CMS\Feedit\Hooks\StdWrapEditPanelHook:
public: false
TYPO3\CMS\Feedit\ContentObject\EditPanelContentObject:
tags:
- name: frontend.contentobject
identifier: 'EDITPANEL'

View file

@ -1,5 +1,4 @@
<?php <?php
defined('TYPO3_MODE') or die();
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'feedit', 'feedit',

View file

@ -18,10 +18,10 @@
"sort-packages": true "sort-packages": true
}, },
"require": { "require": {
"typo3/cms-adminpanel": "^10.0", "typo3/cms-adminpanel": "^11 || ^12",
"typo3/cms-backend": "^10.0", "typo3/cms-backend": "^11 || ^12",
"typo3/cms-core": "^10.0", "typo3/cms-core": "^11 || ^12",
"typo3/cms-frontend": "^10.0", "typo3/cms-frontend": "^11 || ^12",
"psr/http-message": "~1.0", "psr/http-message": "~1.0",
"psr/http-server-handler": "^1.0", "psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0" "psr/http-server-middleware": "^1.0"

View file

@ -7,12 +7,11 @@ $EM_CONF[$_EXTKEY] = [
'author_email' => 'friendsof@typo3.org', 'author_email' => 'friendsof@typo3.org',
'author_company' => '', 'author_company' => '',
'state' => 'stable', 'state' => 'stable',
'createDirs' => '', 'clearCacheOnLoad' => true,
'clearCacheOnLoad' => 0, 'version' => '11.0.0',
'version' => '10.0.2',
'constraints' => [ 'constraints' => [
'depends' => [ 'depends' => [
'typo3' => '10.0.0-10.9.99', 'typo3' => '11.5.0-12.2.99',
], ],
'conflicts' => [], 'conflicts' => [],
'suggests' => [], 'suggests' => [],

View file

@ -1,10 +1,13 @@
<?php <?php
defined('TYPO3_MODE') or die();
// Register the edit panel view. // Register the edit panel view.
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'] = \TYPO3\CMS\Feedit\FrontendEditPanel::class; //$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'] = \TYPO3\CMS\Feedit\FrontendEditPanel::class;
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap']['feedit'] = \TYPO3\CMS\Feedit\Hooks\StdWrapEditPanelHook::class;
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']['edit'] = [ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']['edit'] = [
'module' => \TYPO3\CMS\Feedit\Modules\EditModule::class, 'module' => \TYPO3\CMS\Feedit\Modules\EditModule::class,
'after' => ['cache'], 'after' => ['cache'],
]; ];
$GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects']['EDITPANEL']
= \TYPO3\CMS\Feedit\ContentObject\EditPanelContentObject::class;