mirror of
https://github.com/FriendsOfTYPO3/feedit.git
synced 2024-11-09 17:26:09 +01:00
[TASK] Support v11 + v12
This commit is contained in:
parent
652ea1b1ce
commit
5b7ddfc366
12 changed files with 179 additions and 61 deletions
43
Classes/ContentObject/EditPanelContentObject.php
Executable file
43
Classes/ContentObject/EditPanelContentObject.php
Executable 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;
|
||||
}
|
||||
}
|
|
@ -64,11 +64,12 @@ class FrontendEditDataHandler
|
|||
public function editAction()
|
||||
{
|
||||
// Commands
|
||||
list($table, $uid) = explode(':', $this->configuration['record']);
|
||||
$uid = (int)$uid;
|
||||
$cmd = $this->configuration['cmd'];
|
||||
$split= explode(':', (string)($this->configuration['record'] ?? ''));
|
||||
$table = $split[0] ?? '';
|
||||
$uid = (int)($split[1] ?? 0);
|
||||
$cmd = $this->configuration['cmd'] ?? '';
|
||||
// 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';
|
||||
}
|
||||
if ($cmd === 'save' || $cmd && $table && $uid && isset($GLOBALS['TCA'][$table])) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
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\PathUtility;
|
||||
use TYPO3\CMS\Feedit\Service\EditToolbarService;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
|
||||
|
||||
/**
|
||||
|
@ -61,16 +63,16 @@ class FrontendEditPanel
|
|||
/**
|
||||
* Constructor for the edit panel
|
||||
*
|
||||
* @param mixed $_ Previous the database connection
|
||||
* @param TypoScriptFrontendController $frontendController
|
||||
* @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->backendUser = $backendUser ?: $GLOBALS['BE_USER'];
|
||||
$this->cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
|
||||
$this->cObj->start([]);
|
||||
# $this->cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
|
||||
# $this->cObj->start([]);
|
||||
$this->cObj = $contentObjectRenderer;
|
||||
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
|
||||
$this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_tsfe.xlf');
|
||||
}
|
||||
|
@ -111,7 +113,7 @@ class FrontendEditPanel
|
|||
}
|
||||
if (isset($allow['edit'])) {
|
||||
$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
|
||||
if (isset($allow['move']) && $sortField && $this->backendUser->workspace === 0) {
|
||||
|
@ -122,7 +124,7 @@ class FrontendEditPanel
|
|||
}
|
||||
// Hiding in workspaces because implementation is incomplete
|
||||
// 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]) {
|
||||
$icon = $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render('inline');
|
||||
$panel .= $this->editPanelLinkWrap($icon, $formName, 'unhide');
|
||||
|
@ -146,14 +148,16 @@ class FrontendEditPanel
|
|||
}
|
||||
// Hiding in workspaces because implementation is incomplete
|
||||
// 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') . '">'
|
||||
. $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render('inline')
|
||||
. '</span>';
|
||||
$panel .= $this->editPanelLinkWrap($icon, $formName, 'delete', '', $this->getLabel('p_deleteConfirm'));
|
||||
}
|
||||
|
||||
// Final
|
||||
$labelTxt = $this->cObj->stdWrap($conf['label'], $conf['label.']);
|
||||
// $labelTxt = $this->cObj->stdWrap($conf['label'] ?? '', $conf['label.'] ?? []);
|
||||
$labelTxt = '';
|
||||
foreach ((array)$hiddenFields as $name => $value) {
|
||||
$hiddenFieldString .= '<input type="hidden" name="TSFE_EDIT[' . htmlspecialchars($name) . ']" value="' . htmlspecialchars($value) . '"/>' . LF;
|
||||
}
|
||||
|
@ -170,30 +174,30 @@ class FrontendEditPanel
|
|||
</div>
|
||||
</form>';
|
||||
|
||||
// Wrap the panel
|
||||
if ($conf['innerWrap']) {
|
||||
$panel = $this->cObj->wrap($panel, $conf['innerWrap']);
|
||||
}
|
||||
if ($conf['innerWrap.']) {
|
||||
$panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']);
|
||||
}
|
||||
|
||||
// Wrap the complete panel
|
||||
if ($conf['outerWrap']) {
|
||||
$panel = $this->cObj->wrap($panel, $conf['outerWrap']);
|
||||
}
|
||||
if ($conf['outerWrap.']) {
|
||||
$panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']);
|
||||
}
|
||||
if ($conf['printBeforeContent']) {
|
||||
// // Wrap the panel
|
||||
// if ($conf['innerWrap']) {
|
||||
// $panel = $this->cObj->wrap($panel, $conf['innerWrap']);
|
||||
// }
|
||||
// if ($conf['innerWrap.']) {
|
||||
// $panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']);
|
||||
// }
|
||||
//
|
||||
// // Wrap the complete panel
|
||||
// if ($conf['outerWrap']) {
|
||||
// $panel = $this->cObj->wrap($panel, $conf['outerWrap']);
|
||||
// }
|
||||
// if ($conf['outerWrap.']) {
|
||||
// $panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']);
|
||||
// }
|
||||
if ($conf['printBeforeContent'] ?? false) {
|
||||
$finalOut = $panel . $content;
|
||||
} else {
|
||||
$finalOut = $content . $panel;
|
||||
}
|
||||
|
||||
$hidden = $this->isDisabled($table, $dataArr) ? ' typo3-feedit-element-hidden' : '';
|
||||
$outerWrapConfig = $conf['stdWrap.'] ?? ['wrap' => '<div class="typo3-feedit-element' . $hidden . '">|</div>'];
|
||||
$finalOut = $this->cObj->stdWrap($finalOut, $outerWrapConfig);
|
||||
// $outerWrapConfig = $conf['stdWrap.'] ?? ['wrap' => '<div class="typo3-feedit-element' . $hidden . '">|</div>'];
|
||||
// $finalOut = $this->cObj->stdWrap($finalOut, $outerWrapConfig);
|
||||
|
||||
return $finalOut;
|
||||
}
|
||||
|
@ -213,7 +217,7 @@ class FrontendEditPanel
|
|||
* @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.
|
||||
*/
|
||||
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.
|
||||
$this->frontendController->set_no_cache('Display frontend edit icons', true);
|
||||
|
|
62
Classes/Hooks/StdWrapEditPanelHook.php
Normal file
62
Classes/Hooks/StdWrapEditPanelHook.php
Normal 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'];
|
||||
}
|
||||
}
|
|
@ -57,7 +57,7 @@ class FrontendEditInitiator implements MiddlewareInterface
|
|||
if ($active && isset($config['enable.'])) {
|
||||
foreach ($config['enable.'] as $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)) {
|
||||
GeneralUtility::makeInstance(FrontendEditDataHandler::class, $parameters)->editAction();
|
||||
}
|
||||
|
@ -80,10 +80,10 @@ class FrontendEditInitiator implements MiddlewareInterface
|
|||
if (!is_array($parameters)) {
|
||||
return false;
|
||||
}
|
||||
if ($parameters['cancel']) {
|
||||
if ($parameters['cancel'] ?? false) {
|
||||
unset($parameters['cmd']);
|
||||
} 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') {
|
||||
// $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;
|
||||
|
|
|
@ -44,7 +44,6 @@ class EditModule extends AbstractModule implements PageSettingsProviderInterface
|
|||
*/
|
||||
public function __construct(UriBuilder $uriBuilder)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->uriBuilder = $uriBuilder;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class EditToolbarService
|
|||
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
|
||||
$tsfe = $this->getTypoScriptFrontendController();
|
||||
// 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);
|
||||
$perms = $this->getBackendUser()->calcPerms($tsfe->page);
|
||||
$langAllowed = $this->getBackendUser()->checkLanguageAccess($languageAspect->getId());
|
||||
|
|
|
@ -9,3 +9,11 @@ services:
|
|||
|
||||
TYPO3\CMS\Feedit\Modules\EditModule:
|
||||
public: true
|
||||
|
||||
TYPO3\CMS\Feedit\Hooks\StdWrapEditPanelHook:
|
||||
public: false
|
||||
|
||||
TYPO3\CMS\Feedit\ContentObject\EditPanelContentObject:
|
||||
tags:
|
||||
- name: frontend.contentobject
|
||||
identifier: 'EDITPANEL'
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
defined('TYPO3_MODE') or die();
|
||||
|
||||
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
|
||||
'feedit',
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"typo3/cms-adminpanel": "^10.0",
|
||||
"typo3/cms-backend": "^10.0",
|
||||
"typo3/cms-core": "^10.0",
|
||||
"typo3/cms-frontend": "^10.0",
|
||||
"typo3/cms-adminpanel": "^11 || ^12",
|
||||
"typo3/cms-backend": "^11 || ^12",
|
||||
"typo3/cms-core": "^11 || ^12",
|
||||
"typo3/cms-frontend": "^11 || ^12",
|
||||
"psr/http-message": "~1.0",
|
||||
"psr/http-server-handler": "^1.0",
|
||||
"psr/http-server-middleware": "^1.0"
|
||||
|
|
|
@ -7,12 +7,11 @@ $EM_CONF[$_EXTKEY] = [
|
|||
'author_email' => 'friendsof@typo3.org',
|
||||
'author_company' => '',
|
||||
'state' => 'stable',
|
||||
'createDirs' => '',
|
||||
'clearCacheOnLoad' => 0,
|
||||
'version' => '10.0.2',
|
||||
'clearCacheOnLoad' => true,
|
||||
'version' => '11.0.0',
|
||||
'constraints' => [
|
||||
'depends' => [
|
||||
'typo3' => '10.0.0-10.9.99',
|
||||
'typo3' => '11.5.0-12.2.99',
|
||||
],
|
||||
'conflicts' => [],
|
||||
'suggests' => [],
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
defined('TYPO3_MODE') or die();
|
||||
|
||||
// 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'] = [
|
||||
'module' => \TYPO3\CMS\Feedit\Modules\EditModule::class,
|
||||
'after' => ['cache'],
|
||||
];
|
||||
|
||||
$GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects']['EDITPANEL']
|
||||
= \TYPO3\CMS\Feedit\ContentObject\EditPanelContentObject::class;
|
Loading…
Reference in a new issue