Skip to content

Commit 0c74343

Browse files
bmackachimfritz
authored andcommitted
[BUGFIX] Fix backend previews in v14
This is a problem for previous versions with the partial
1 parent c7adabd commit 0c74343

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

Classes/Backend/Preview/ContentPreview.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* of the License, or any later version.
1313
*/
1414

15+
use B13\Backendpreviews\Service\DatabaseRowService;
1516
use TYPO3\CMS\Backend\Utility\BackendUtility;
1617
use TYPO3\CMS\Backend\View\PageLayoutContext;
1718
use TYPO3\CMS\Core\Domain\RecordInterface;
@@ -54,6 +55,9 @@ public function render(RecordInterface $record, PageLayoutContext $context): ?st
5455
$context->getCurrentRequest()
5556
)
5657
);
58+
59+
$data = GeneralUtility::makeInstance(DatabaseRowService::class)->getAdditionalDataForView($record);
60+
$view->assignMultiple($data);
5761
$view->assign('record', $record);
5862
try {
5963
return $view->render($fluidTemplateName);

Classes/Service/DatabaseRowService.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use TYPO3\CMS\Backend\Routing\UriBuilder;
1616
use TYPO3\CMS\Backend\Utility\BackendUtility;
1717
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
18+
use TYPO3\CMS\Core\Domain\RecordInterface;
1819
use TYPO3\CMS\Core\Localization\LanguageService;
1920
use TYPO3\CMS\Core\Resource\FileReference;
2021
use TYPO3\CMS\Core\Resource\FileRepository;
@@ -31,6 +32,33 @@ public function __construct(FileRepository $fileRepository)
3132
$this->fileRepository = $fileRepository;
3233
}
3334

35+
public function getAdditionalDataForView(RecordInterface $record): array
36+
{
37+
$data = [];
38+
if ($this->getBackendUser()->recordEditAccessInternals($record->getMainType(), $record)) {
39+
$urlParameters = [
40+
'edit' => [
41+
'tt_content' => [
42+
$record->getUid() => 'edit',
43+
],
44+
],
45+
'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $record->getUid(),
46+
];
47+
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
48+
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
49+
$return = [
50+
'url' => $url,
51+
'title' => htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:edit')),
52+
];
53+
$data['editLink'] = $return;
54+
}
55+
56+
$data['CType-label'] = $this->getLanguageService()->sL(
57+
BackendUtility::getLabelFromItemListMerged($record->getPid(), 'tt_content', 'CType', $record->get('CType'))
58+
);
59+
return $data;
60+
}
61+
3462
public function extendRow(array $row): array
3563
{
3664
if ($this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {

Resources/Private/Partials/Link.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
data-namespace-typo3-fluid="true"
44
>
55

6-
<f:if condition="{link}">
6+
<f:if condition="{link.url}">
77
<div class="b_link">
88
<span class="b_label">{f:translate(key: 'LLL:EXT:backendpreviews/Resources/Private/Language/locallang_db.xlf:link.label')}: </span>{linklabel}
9-
({f:if(condition: '{f:uri.typolink(parameter: link, language: language)}', then: '{f:uri.typolink(parameter: link, language: language)}', else: link)})
9+
({f:if(condition: '{f:uri.typolink(parameter: link.url, language: language)}', then: '{f:uri.typolink(parameter: link.url, language: language)}', else: link.url)})
1010
<f:if condition="{config}">
1111
[{f:translate(key: 'LLL:EXT:backendpreviews/Resources/Private/Language/locallang_db.xlf:link.config')}: {config}]
1212
</f:if>

0 commit comments

Comments
 (0)