From b63fcedbab6f768169cc3bf65855b866df7ae282 Mon Sep 17 00:00:00 2001 From: Benjamin Kott <benjamin.kott@outlook.com> Date: Thu, 6 Jul 2023 22:17:37 +0200 Subject: [PATCH] [BUGFIX] Disable preview links if no preview uri can be generated Resolves: #101276 Releases: main, 12.4 Change-Id: Ie9941076dc54fc3c123241cf51a50a19a9145ec6 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79866 Tested-by: Benjamin Franzke <ben@bnf.dev> Reviewed-by: Benjamin Franzke <ben@bnf.dev> Tested-by: core-ci <typo3@b13.com> --- .../ContextMenu/ItemProviders/PageProvider.php | 3 ++- .../ItemProviders/RecordProvider.php | 12 +++++++++++- .../Classes/Controller/NewRecordController.php | 10 ++++------ .../Page/NewMultiplePagesController.php | 5 +++-- .../Controller/Page/SortSubPagesController.php | 5 +++-- .../Controller/PageLayoutController.php | 5 +++-- .../Controller/RecordListController.php | 7 ++++--- .../Classes/RecordList/DatabaseRecordList.php | 18 ++++++++++-------- .../Partials/PageLayout/LanguageColumns.html | 4 ++-- .../ContentElement/ElementInformation.html | 4 ++-- .../Classes/Controller/ImportController.php | 7 ++++--- typo3/sysext/impexp/Classes/ImportExport.php | 4 +++- .../RenderPreviewExportPageAndRecords.php | 6 +++--- ...PreviewExportPageAndRecordsWithSoftRefs.php | 6 +++--- ...nderPreviewImportPageAndRecordsByUpdate.php | 4 ++-- ...iewImportPageAndRecordsByUpdateWithDiff.php | 2 +- ...nderPreviewImportPageAndRecordsWithDiff.php | 2 +- .../Controller/InfoModuleController.php | 7 ++++--- .../Controller/PageInformationController.php | 4 ++-- .../Controller/TranslationStatusController.php | 10 +++++----- .../AbstractTemplateModuleController.php | 7 ++++--- 21 files changed, 76 insertions(+), 56 deletions(-) diff --git a/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/PageProvider.php b/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/PageProvider.php index fad1fde5b50d..914f185de20b 100644 --- a/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/PageProvider.php +++ b/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/PageProvider.php @@ -423,7 +423,8 @@ class PageProvider extends RecordProvider { return !$this->isRoot() && !$this->isDeleted() - && !$this->isExcludedDoktype(); + && !$this->isExcludedDoktype() + && $this->previewLinkCanBeBuild(); } /** diff --git a/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/RecordProvider.php b/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/RecordProvider.php index 2f209d24d071..4431a7bd8629 100644 --- a/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/RecordProvider.php +++ b/typo3/sysext/backend/Classes/ContextMenu/ItemProviders/RecordProvider.php @@ -442,7 +442,9 @@ class RecordProvider extends AbstractProvider */ protected function canBeViewed(): bool { - return $this->table === 'tt_content' && $this->parentPageCanBeViewed(); + return $this->table === 'tt_content' + && $this->parentPageCanBeViewed() + && $this->previewLinkCanBeBuild(); } /** @@ -643,4 +645,12 @@ class RecordProvider extends AbstractProvider { return $this->record['uid']; } + + /** + * Returns true if a view link can be build for the record + */ + protected function previewLinkCanBeBuild(): bool + { + return $this->getViewLink() !== ''; + } } diff --git a/typo3/sysext/backend/Classes/Controller/NewRecordController.php b/typo3/sysext/backend/Classes/Controller/NewRecordController.php index cd835ad1596f..2025c5a7d42a 100644 --- a/typo3/sysext/backend/Classes/Controller/NewRecordController.php +++ b/typo3/sysext/backend/Classes/Controller/NewRecordController.php @@ -319,12 +319,10 @@ class NewRecordController $viewButton = $buttonBar->makeLinkButton() ->setHref('#') ->setDataAttributes($previewDataAttributes ?? []) - ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) - ->setShowLabelText(true) - ->setIcon($this->iconFactory->getIcon( - 'actions-view-page', - Icon::SIZE_SMALL - )); + ->setDisabled(!$previewDataAttributes) + ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) + ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)) + ->setShowLabelText(true); $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 30); } } diff --git a/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php b/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php index 80801c94a210..8c2cb16c6dc3 100644 --- a/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php +++ b/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php @@ -74,11 +74,12 @@ class NewMultiplePagesController ->withRootLine(BackendUtility::BEgetRootLine($pageUid)) ->buildDispatcherDataAttributes(); $viewButton = $buttonBar->makeLinkButton() + ->setHref('#') ->setDataAttributes($previewDataAttributes ?? []) + ->setDisabled(!$previewDataAttributes) ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) - ->setShowLabelText(true) ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)) - ->setHref('#'); + ->setShowLabelText(true); $buttonBar->addButton($viewButton); $calculatedPermissions = new Permission($backendUser->calcPerms($pageRecord)); diff --git a/typo3/sysext/backend/Classes/Controller/Page/SortSubPagesController.php b/typo3/sysext/backend/Classes/Controller/Page/SortSubPagesController.php index 20718aa3910c..a7a9e20903a9 100644 --- a/typo3/sysext/backend/Classes/Controller/Page/SortSubPagesController.php +++ b/typo3/sysext/backend/Classes/Controller/Page/SortSubPagesController.php @@ -70,11 +70,12 @@ class SortSubPagesController ->withRootLine(BackendUtility::BEgetRootLine($parentPageUid)) ->buildDispatcherDataAttributes(); $viewButton = $buttonBar->makeLinkButton() + ->setHref('#') ->setDataAttributes($previewDataAttributes ?? []) + ->setDisabled(!$previewDataAttributes) ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) - ->setShowLabelText(true) ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)) - ->setHref('#'); + ->setShowLabelText(true); $buttonBar->addButton($viewButton); $isInWorkspace = $backendUser->workspace !== 0; diff --git a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php index 9b2ee323ef3c..85fecaf87207 100644 --- a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php +++ b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php @@ -632,11 +632,12 @@ class PageLayoutController ->buildDispatcherDataAttributes(); return $buttonBar->makeLinkButton() + ->setHref('#') ->setDataAttributes($previewDataAttributes ?? []) + ->setDisabled(!$previewDataAttributes) ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)) - ->setShowLabelText(true) - ->setHref('#'); + ->setShowLabelText(true); } /** diff --git a/typo3/sysext/backend/Classes/Controller/RecordListController.php b/typo3/sysext/backend/Classes/Controller/RecordListController.php index 5b66e5f47235..6e05c95255f2 100644 --- a/typo3/sysext/backend/Classes/Controller/RecordListController.php +++ b/typo3/sysext/backend/Classes/Controller/RecordListController.php @@ -310,9 +310,10 @@ class RecordListController $viewButton = $buttonBar->makeLinkButton() ->setHref('#') ->setDataAttributes($previewDataAttributes ?? []) - ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) - ->setShowLabelText(true) - ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)); + ->setDisabled(!$previewDataAttributes) + ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) + ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)) + ->setShowLabelText(true); $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 15); } // If edit permissions are set, see BackendUserAuthentication diff --git a/typo3/sysext/backend/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/backend/Classes/RecordList/DatabaseRecordList.php index 171d2b218250..893dc86424c9 100644 --- a/typo3/sysext/backend/Classes/RecordList/DatabaseRecordList.php +++ b/typo3/sysext/backend/Classes/RecordList/DatabaseRecordList.php @@ -1371,9 +1371,10 @@ class DatabaseRecordList && !in_array((int)$this->pageRow['doktype'], $this->getNoViewWithDokTypes($tsConfig), true) ) ) { - if (!$isDeletePlaceHolder) { - $attributes = $this->getPreviewUriBuilder($table, $row)->serializeDispatcherAttributes(); - $viewAction = '<a href="#"' + if (!$isDeletePlaceHolder + && ($attributes = $this->getPreviewUriBuilder($table, $row)->serializeDispatcherAttributes()) !== null + ) { + $viewAction = '<button' . ' class="btn btn-default" ' . $attributes . ' title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">'; if ($table === 'pages') { @@ -1381,7 +1382,7 @@ class DatabaseRecordList } else { $viewAction .= $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render(); } - $viewAction .= '</a>'; + $viewAction .= '</button>'; $this->addActionToCellGroup($cells, $viewAction, 'view'); } else { $this->addActionToCellGroup($cells, $this->spaceIcon, 'view'); @@ -2576,13 +2577,14 @@ class DatabaseRecordList break; case 'show': // "Show" link (only pages and tt_content elements) - if ($table === 'pages' || $table === 'tt_content') { - $attributes = $this->getPreviewUriBuilder($table, $row)->serializeDispatcherAttributes(); + if (($table === 'pages' || $table === 'tt_content') + && ($attributes = $this->getPreviewUriBuilder($table, $row)->serializeDispatcherAttributes()) !== null + ) { $title = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')); - $code = '<a href="#" ' . $attributes + $code = '<button ' . $attributes . ' title="' . $title . '"' . ' aria-label="' . $title . '">' - . $code . '</a>'; + . $code . '</button>'; } break; case 'info': diff --git a/typo3/sysext/backend/Resources/Private/Partials/PageLayout/LanguageColumns.html b/typo3/sysext/backend/Resources/Private/Partials/PageLayout/LanguageColumns.html index e1ebf51f6f52..5aa2aa11d4d7 100644 --- a/typo3/sysext/backend/Resources/Private/Partials/PageLayout/LanguageColumns.html +++ b/typo3/sysext/backend/Resources/Private/Partials/PageLayout/LanguageColumns.html @@ -32,9 +32,9 @@ <td class="t3-page-column t3-page-lang-label nowrap"> <div class="btn-group"> <f:if condition="{languageColumn.allowViewPage}"> - <a href="#" class="btn btn-default btn-sm" {languageColumn.previewUrlAttributes -> f:format.raw()} title="{languageColumn.viewPageLinkTitle}"> + <button class="btn btn-default btn-sm" {f:if(condition: languageColumn.previewUrlAttributes, then: '{languageColumn.previewUrlAttributes -> f:format.raw()}', else: 'disabled="true"')} title="{languageColumn.viewPageLinkTitle}"> <core:icon identifier="actions-view" /> - </a> + </button> </f:if> <f:if condition="{languageColumn.allowEditPage}"> <a href="{languageColumn.pageEditUrl}" class="btn btn-default btn-sm" title="{languageColumn.pageEditTitle}"> diff --git a/typo3/sysext/backend/Resources/Private/Templates/ContentElement/ElementInformation.html b/typo3/sysext/backend/Resources/Private/Templates/ContentElement/ElementInformation.html index 982c55c4f237..399ece5daf16 100644 --- a/typo3/sysext/backend/Resources/Private/Templates/ContentElement/ElementInformation.html +++ b/typo3/sysext/backend/Resources/Private/Templates/ContentElement/ElementInformation.html @@ -234,9 +234,9 @@ <f:section name="action"> <div class="btn-group" role="group"> <f:if condition="{line.webListUrl}"> - <a class="btn btn-default btn-sm" href="#" {line.previewUrlAttributes -> f:format.raw()} title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')}"> + <button class="btn btn-default btn-sm" {f:if(condition: languageColumn.previewUrlAttributes, then: '{languageColumn.previewUrlAttributes -> f:format.raw()}', else: 'disabled="true"')} title="{f:translate(key: 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')}"> <core:icon identifier="actions-document-view" size="small" /> - </a> + </button> </f:if> <a class="btn btn-default btn-sm" href="{line.recordEditUrl}" title="{f:translate(key:'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.edit')}"> <core:icon identifier="actions-open" size="small" /> diff --git a/typo3/sysext/impexp/Classes/Controller/ImportController.php b/typo3/sysext/impexp/Classes/Controller/ImportController.php index 5b09b139e6eb..17b56939bacf 100644 --- a/typo3/sysext/impexp/Classes/Controller/ImportController.php +++ b/typo3/sysext/impexp/Classes/Controller/ImportController.php @@ -137,11 +137,12 @@ class ImportController ->withRootLine(BackendUtility::BEgetRootLine($pageUid)) ->buildDispatcherDataAttributes(); $viewButton = $buttonBar->makeLinkButton() - ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) - ->setShowLabelText(true) ->setHref('#') + ->setDataAttributes($previewDataAttributes ?? []) + ->setDisabled(!$previewDataAttributes) + ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)) - ->setDataAttributes($previewDataAttributes ?? []); + ->setShowLabelText(true); $buttonBar->addButton($viewButton); } diff --git a/typo3/sysext/impexp/Classes/ImportExport.php b/typo3/sysext/impexp/Classes/ImportExport.php index cbbbbc3ccf42..bdf78caddad0 100644 --- a/typo3/sysext/impexp/Classes/ImportExport.php +++ b/typo3/sysext/impexp/Classes/ImportExport.php @@ -542,7 +542,9 @@ abstract class ImportExport $viewID = $this->mode === 'export' ? $uid : ($this->doesImport ? ($this->importMapId['pages'][$uid] ?? 0) : 0); if ($viewID) { $attributes = PreviewUriBuilder::create($viewID)->serializeDispatcherAttributes(); - $line['title'] = sprintf('<a href="#" %s>%s</a>', $attributes, $line['title']); + if ($attributes) { + $line['title'] = sprintf('<a href="#" %s>%s</a>', $attributes, $line['title']); + } } } $line['active'] = !$this->isRecordDisabled($table, $uid) ? 'active' : 'hidden'; diff --git a/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewExportPageAndRecords.php b/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewExportPageAndRecords.php index 790e24a829ae..96536fe53f61 100644 --- a/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewExportPageAndRecords.php +++ b/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewExportPageAndRecords.php @@ -186,7 +186,7 @@ return [ </span> </span>', - 'title' => '<a href="#" >Root</a>', + 'title' => 'Root', 'active' => 'active', 'controls' => '<div class="form-check mb-0"><input class="form-check-input t3js-exclude-checkbox" type="checkbox" name="tx_impexp[exclude][pages:1]" id="checkExcludepages:1" value="1" /><label class="form-check-label" for="checkExcludepages:1">Exclude</label></div>', 'message' => '', @@ -393,7 +393,7 @@ return [ </span> </span>', - 'title' => '<a href="#" >Dummy 1-2</a>', + 'title' => 'Dummy 1-2', 'active' => 'active', 'controls' => '<div class="form-check mb-0"><input class="form-check-input t3js-exclude-checkbox" type="checkbox" name="tx_impexp[exclude][pages:2]" id="checkExcludepages:2" value="1" /><label class="form-check-label" for="checkExcludepages:2">Exclude</label></div>', 'message' => '', @@ -409,7 +409,7 @@ return [ </span> <span class="icon-overlay icon-overlay-hidden"><svg class="icon-color"><use xlink:href="typo3/sysext/core/Resources/Public/Icons/T3Icons/sprites/overlay.svg#overlay-hidden" /></svg></span> </span>', - 'title' => '<a href="#" >Dummy 1-3</a>', + 'title' => 'Dummy 1-3', 'active' => 'hidden', 'controls' => '<div class="form-check mb-0"><input class="form-check-input t3js-exclude-checkbox" type="checkbox" name="tx_impexp[exclude][pages:3]" id="checkExcludepages:3" value="1" /><label class="form-check-label" for="checkExcludepages:3">Exclude</label></div>', 'message' => '', diff --git a/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewExportPageAndRecordsWithSoftRefs.php b/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewExportPageAndRecordsWithSoftRefs.php index 2a96fb125ec8..b0b8fd9666e3 100644 --- a/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewExportPageAndRecordsWithSoftRefs.php +++ b/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewExportPageAndRecordsWithSoftRefs.php @@ -170,7 +170,7 @@ return [ </span> </span>', - 'title' => '<a href="#" >Root</a>', + 'title' => 'Root', 'active' => 'active', 'controls' => '<div class="form-check mb-0"><input class="form-check-input t3js-exclude-checkbox" type="checkbox" name="tx_impexp[exclude][pages:1]" id="checkExcludepages:1" value="1" /><label class="form-check-label" for="checkExcludepages:1">Exclude</label></div>', 'message' => '', @@ -260,7 +260,7 @@ return [ </span> </span>', - 'title' => '<a href="#" >Dummy 1-2</a>', + 'title' => 'Dummy 1-2', 'active' => 'active', 'controls' => '<div class="form-check mb-0"><input class="form-check-input t3js-exclude-checkbox" type="checkbox" name="tx_impexp[exclude][pages:2]" id="checkExcludepages:2" value="1" /><label class="form-check-label" for="checkExcludepages:2">Exclude</label></div>', 'message' => '', @@ -276,7 +276,7 @@ return [ </span> <span class="icon-overlay icon-overlay-hidden"><svg class="icon-color"><use xlink:href="typo3/sysext/core/Resources/Public/Icons/T3Icons/sprites/overlay.svg#overlay-hidden" /></svg></span> </span>', - 'title' => '<a href="#" >Dummy 1-3</a>', + 'title' => 'Dummy 1-3', 'active' => 'hidden', 'controls' => '<div class="form-check mb-0"><input class="form-check-input t3js-exclude-checkbox" type="checkbox" name="tx_impexp[exclude][pages:3]" id="checkExcludepages:3" value="1" /><label class="form-check-label" for="checkExcludepages:3">Exclude</label></div>', 'message' => '', diff --git a/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsByUpdate.php b/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsByUpdate.php index 89123ff991b7..e5bad259dd16 100644 --- a/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsByUpdate.php +++ b/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsByUpdate.php @@ -29,7 +29,7 @@ return [ </span> </span>', - 'title' => '<a href="#" >Root</a>', + 'title' => 'Root', 'active' => 'active', 'updatePath' => '/', 'updateMode' => sprintf('<select class="form-select form-select-sm" name="tx_impexp[import_mode][pages:1]" style="width: 100px"><option value="0">Update</option><option value="%s">Import as new</option><option value="%s">Ignore PID</option><option value="%s">Exclude</option></select>', \TYPO3\CMS\Impexp\Import::IMPORT_MODE_AS_NEW, \TYPO3\CMS\Impexp\Import::IMPORT_MODE_IGNORE_PID, \TYPO3\CMS\Impexp\Import::IMPORT_MODE_EXCLUDE), @@ -169,7 +169,7 @@ return [ </span> </span>', - 'title' => '<a href="#" >Dummy 1-2</a>', + 'title' => 'Dummy 1-2', 'active' => 'active', 'updatePath' => '/Root/', 'updateMode' => sprintf('<select class="form-select form-select-sm" name="tx_impexp[import_mode][pages:2]" style="width: 100px"><option value="0">Update</option><option value="%s">Import as new</option><option value="%s">Ignore PID</option><option value="%s">Exclude</option></select>', \TYPO3\CMS\Impexp\Import::IMPORT_MODE_AS_NEW, \TYPO3\CMS\Impexp\Import::IMPORT_MODE_IGNORE_PID, \TYPO3\CMS\Impexp\Import::IMPORT_MODE_EXCLUDE), diff --git a/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsByUpdateWithDiff.php b/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsByUpdateWithDiff.php index 95ae71a84ba0..a18861f9ad53 100644 --- a/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsByUpdateWithDiff.php +++ b/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsByUpdateWithDiff.php @@ -517,7 +517,7 @@ return [ . "\t" . '</span>' . "\n" . "\t\n" . '</span>', - 'title' => '<a href="#" >Root</a>', + 'title' => 'Root', 'active' => 'active', 'updatePath' => '/', 'updateMode' => sprintf('<select class="form-select form-select-sm" name="tx_impexp[import_mode][pages:1]" style="width: 100px"><option value="0">Update</option><option value="%s">Import as new</option><option value="%s">Ignore PID</option><option value="%s">Exclude</option></select>', \TYPO3\CMS\Impexp\Import::IMPORT_MODE_AS_NEW, \TYPO3\CMS\Impexp\Import::IMPORT_MODE_IGNORE_PID, \TYPO3\CMS\Impexp\Import::IMPORT_MODE_EXCLUDE), diff --git a/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsWithDiff.php b/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsWithDiff.php index d3ce6c98bad6..ef5944901a16 100644 --- a/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsWithDiff.php +++ b/typo3/sysext/impexp/Tests/Functional/Fixtures/ArrayAssertions/RenderPreviewImportPageAndRecordsWithDiff.php @@ -470,7 +470,7 @@ return [ </span> </span>', - 'title' => '<a href="#" >Root</a>', + 'title' => 'Root', 'active' => 'active', 'showDiffContent' => '<strong class="text-nowrap">[pages:1 => 1]:</strong> Match', diff --git a/typo3/sysext/info/Classes/Controller/InfoModuleController.php b/typo3/sysext/info/Classes/Controller/InfoModuleController.php index b1c31aeada88..b7d7578068b7 100644 --- a/typo3/sysext/info/Classes/Controller/InfoModuleController.php +++ b/typo3/sysext/info/Classes/Controller/InfoModuleController.php @@ -147,9 +147,10 @@ class InfoModuleController $viewButton = $buttonBar->makeLinkButton() ->setHref('#') ->setDataAttributes($previewDataAttributes ?? []) - ->setShowLabelText(true) - ->setTitle($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) - ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)); + ->setDisabled(!$previewDataAttributes) + ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) + ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)) + ->setShowLabelText(true); $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT); } } diff --git a/typo3/sysext/info/Classes/Controller/PageInformationController.php b/typo3/sysext/info/Classes/Controller/PageInformationController.php index 222b17c27e3b..e62a43725741 100644 --- a/typo3/sysext/info/Classes/Controller/PageInformationController.php +++ b/typo3/sysext/info/Classes/Controller/PageInformationController.php @@ -375,10 +375,10 @@ class PageInformationController extends InfoModuleController ->withRootLine(BackendUtility::BEgetRootLine($row['uid'])) ->serializeDispatcherAttributes(); $editButton = - '<a href="#" ' . $attributes . ' class="btn btn-default" title="' . + '<button ' . ($attributes ?? 'disabled="true"') . ' class="btn btn-default" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">' . $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render() . - '</a>'; + '</button>'; if ($this->getBackendUser()->check('tables_modify', 'pages')) { $editButton .= diff --git a/typo3/sysext/info/Classes/Controller/TranslationStatusController.php b/typo3/sysext/info/Classes/Controller/TranslationStatusController.php index e01c2114d758..67db47dae0c7 100644 --- a/typo3/sysext/info/Classes/Controller/TranslationStatusController.php +++ b/typo3/sysext/info/Classes/Controller/TranslationStatusController.php @@ -175,9 +175,9 @@ class TranslationStatusController extends InfoModuleController ], 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri(), ]); - $info = '<a href="#" ' . $previewUriBuilder->serializeDispatcherAttributes() + $info = '<button ' . ($previewUriBuilder->serializeDispatcherAttributes() ?? 'disabled="true"') . ' class="btn btn-default" title="' . $lang->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_viewPage') . '">' . - $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render() . '</a>'; + $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render() . '</button>'; if ($backendUser->check('tables_modify', 'pages')) { $info .= '<a href="' . htmlspecialchars($editUrl) . '" class="btn btn-default" title="' . $lang->sL( @@ -241,11 +241,11 @@ class TranslationStatusController extends InfoModuleController 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri(), ]); // ViewPageLink - $info = '<a href="#" ' . $previewUriBuilder + $info = '<button ' . ($previewUriBuilder ->withLanguage($languageId) - ->serializeDispatcherAttributes() + ->serializeDispatcherAttributes() ?? 'disabled="true"') . ' class="btn btn-default" title="' . $lang->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_viewPage') . '">' . - $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render() . '</a>'; + $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render() . '</button>'; $info .= '<a href="' . htmlspecialchars($editUrl) . '" class="btn btn-default" title="' . $lang->sL( 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editLanguageOverlayRecord' diff --git a/typo3/sysext/tstemplate/Classes/Controller/AbstractTemplateModuleController.php b/typo3/sysext/tstemplate/Classes/Controller/AbstractTemplateModuleController.php index b74fc6cec277..309aa6bdd4cc 100644 --- a/typo3/sysext/tstemplate/Classes/Controller/AbstractTemplateModuleController.php +++ b/typo3/sysext/tstemplate/Classes/Controller/AbstractTemplateModuleController.php @@ -141,9 +141,10 @@ abstract class AbstractTemplateModuleController $viewButton = $buttonBar->makeLinkButton() ->setHref('#') ->setDataAttributes($previewDataAttributes ?? []) - ->setTitle($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) - ->setShowLabelText(true) - ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)); + ->setDisabled(!$previewDataAttributes) + ->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) + ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)) + ->setShowLabelText(true); $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 99); } } -- GitLab