diff --git a/Build/phpstan-baseline12.neon b/Build/phpstan-baseline12.neon index aa87cd2..fd6cd1e 100644 --- a/Build/phpstan-baseline12.neon +++ b/Build/phpstan-baseline12.neon @@ -66,7 +66,7 @@ parameters: - message: "#^Call to method getUid\\(\\) on an unknown class TYPO3\\\\CMS\\\\Core\\\\Domain\\\\RecordInterface\\.$#" - count: 2 + count: 4 path: ../Classes/Service/DatabaseRowService.php - @@ -82,3 +82,7 @@ parameters: message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\IconProvider\\\\FontawesomeIconProvider not found\\.$#" count: 2 path: ../Classes/Listener/BootCompleted.php + - + message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Backend\\\\View\\\\PageLayoutContext\\:\\:getReturnUrl\\(\\)\\.$#" + count: 1 + path: ../Classes/Service/DatabaseRowService.php \ No newline at end of file diff --git a/Classes/Backend/Preview/ContentPreview.php b/Classes/Backend/Preview/ContentPreview.php index 8bbddf7..2468ab1 100644 --- a/Classes/Backend/Preview/ContentPreview.php +++ b/Classes/Backend/Preview/ContentPreview.php @@ -56,7 +56,7 @@ public function render(RecordInterface $record, PageLayoutContext $context): ?st ) ); - $data = GeneralUtility::makeInstance(DatabaseRowService::class)->getAdditionalDataForView($record); + $data = GeneralUtility::makeInstance(DatabaseRowService::class)->getAdditionalDataForView($record, $context); $view->assignMultiple($data); $view->assign('record', $record); try { diff --git a/Classes/Service/DatabaseRowService.php b/Classes/Service/DatabaseRowService.php index 3be3385..b2a61ff 100644 --- a/Classes/Service/DatabaseRowService.php +++ b/Classes/Service/DatabaseRowService.php @@ -14,6 +14,7 @@ use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Backend\View\PageLayoutContext; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Domain\RecordInterface; use TYPO3\CMS\Core\Information\Typo3Version; @@ -32,7 +33,7 @@ public function __construct(FileRepository $fileRepository) $this->fileRepository = $fileRepository; } - public function getAdditionalDataForView(RecordInterface $record): array + public function getAdditionalDataForView(RecordInterface $record, ?PageLayoutContext $context = null): array { $data = []; if ((new Typo3Version())->getMajorVersion() < 14) { @@ -41,13 +42,22 @@ public function getAdditionalDataForView(RecordInterface $record): array $editAccess = $this->getBackendUser()->recordEditAccessInternals($record->getMainType(), $record); } if ($editAccess) { + if ($context === null) { + trigger_error('not passing context is deprecated', E_USER_DEPRECATED); + } + if ($context === null || (new Typo3Version())->getMajorVersion() < 13) { + $returnUrl = GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $record->getUid(); + } else { + $returnUrl = $context->getReturnUrl() . '#element-tt_content-' . $record->getUid(); + } + $urlParameters = [ 'edit' => [ 'tt_content' => [ $record->getUid() => 'edit', ], ], - 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $record->getUid(), + 'returnUrl' => $returnUrl, ]; $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); @@ -55,6 +65,18 @@ public function getAdditionalDataForView(RecordInterface $record): array 'url' => $url, 'title' => htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:edit')), ]; + if ((new Typo3Version())->getMajorVersion() > 13) { + $urlParameters = [ + 'edit' => [ + 'tt_content' => [ + $record->getUid() => 'edit', + ], + ], + 'module' => 'web_layout', + 'returnUrl' => $returnUrl, + ]; + $return['contextual'] = (string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit_contextual', $urlParameters); + } $data['editLink'] = $return; } diff --git a/Resources/Private/Layouts/Default.html b/Resources/Private/Layouts/Default.html index 55f5dca..abae79f 100644 --- a/Resources/Private/Layouts/Default.html +++ b/Resources/Private/Layouts/Default.html @@ -12,27 +12,58 @@ --> - - - - - - -
-
- - - - - - - -
- -
-
- -
+ + + + + + + + +
+
+ + + + + + + +
+ +
+
+ +
+
+ + TYPO3 < v14 + + + + + + +
+
+ + + + + + + +
+ +
+
+ +
+
+
- diff --git a/Resources/Private/Layouts/DefaultWithLink.html b/Resources/Private/Layouts/DefaultWithLink.html index 347ae41..ed81bad 100644 --- a/Resources/Private/Layouts/DefaultWithLink.html +++ b/Resources/Private/Layouts/DefaultWithLink.html @@ -12,30 +12,64 @@ --> - - - - - - -
-
- - - - - - - -
- - - - -
-
- -
+ + + + + + + + +
+
+ + + + + + + +
+ + + + +
+
+ +
+
+ + + + + + + +
+
+ + + + + + + +
+ + + + +
+
+ +
+
+