diff --git a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php index 8dff1e8de39760ef793d633a6b779294d1ba9416..47a9931730d169a208aeee2577690792a87ccfa1 100644 --- a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php +++ b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php @@ -543,6 +543,9 @@ class PageLayoutController $content = ''; $lang = $this->getLanguageService(); + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/InfoBox.html')); + // If page is a folder if ($this->pageinfo['doktype'] == PageRepository::DOKTYPE_SYSFOLDER) { $moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class); @@ -552,8 +555,6 @@ class PageLayoutController $title = $lang->getLL('goToListModule'); $message = '<p>' . $lang->getLL('goToListModuleMessage') . '</p>'; $message .= '<a class="btn btn-info" href="javascript:top.goToModule(\'web_list\',1);">' . $lang->getLL('goToListModule') . '</a>'; - $view = GeneralUtility::makeInstance(StandaloneView::class); - $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/InfoBox.html')); $view->assignMultiple([ 'title' => $title, 'message' => $message, @@ -561,6 +562,72 @@ class PageLayoutController ]); $content .= $view->render(); } + } elseif ($this->pageinfo['doktype'] === PageRepository::DOKTYPE_SHORTCUT) { + $shortcutMode = (int)$this->pageinfo['shortcut_mode']; + $pageRepository = GeneralUtility::makeInstance(PageRepository::class); + $targetPage = []; + + if ($this->pageinfo['shortcut'] || $shortcutMode) { + switch ($shortcutMode) { + case PageRepository::SHORTCUT_MODE_NONE: + $targetPage = $pageRepository->getPage($this->pageinfo['shortcut']); + break; + case PageRepository::SHORTCUT_MODE_FIRST_SUBPAGE: + $targetPage = reset($pageRepository->getMenu($this->pageinfo['shortcut'] ?: $this->pageinfo['uid'])); + break; + case PageRepository::SHORTCUT_MODE_PARENT_PAGE: + $targetPage = $pageRepository->getPage($this->pageinfo['pid']); + break; + } + + $message = ''; + if ($shortcutMode === PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE) { + $message .= sprintf($lang->getLL('pageIsRandomInternalLinkMessage')); + } else { + $linkToPid = $this->local_linkThisScript(['id' => $targetPage['uid']]); + $path = BackendUtility::getRecordPath($targetPage['uid'], $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW), 1000); + $linkedPath = '<a href="' . $linkToPid . '">' . htmlspecialchars($path) . '</a>'; + $message .= sprintf($lang->getLL('pageIsInternalLinkMessage'), $linkedPath); + } + + $message .= ' (' . htmlspecialchars($lang->sL(BackendUtility::getLabelFromItemlist('pages', 'shortcut_mode', $shortcutMode))) . ')'; + + $view->assignMultiple([ + 'title' => $this->pageinfo['title'], + 'message' => $message, + 'state' => InfoboxViewHelper::STATE_INFO + ]); + $content .= $view->render(); + } else { + if (empty($targetPage) && $shortcutMode !== PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE) { + $view->assignMultiple([ + 'title' => $this->pageinfo['title'], + 'message' => $lang->getLL('pageIsMisconfiguredInternalLinkMessage'), + 'state' => InfoboxViewHelper::STATE_ERROR + ]); + $content .= $view->render(); + } + } + } elseif ($this->pageinfo['doktype'] === PageRepository::DOKTYPE_LINK) { + if (empty($this->pageinfo['url'])) { + $view->assignMultiple([ + 'title' => $this->pageinfo['title'], + 'message' => $lang->getLL('pageIsMisconfiguredExternalLinkMessage'), + 'state' => InfoboxViewHelper::STATE_ERROR + ]); + $content .= $view->render(); + } else { + $externalUrl = htmlspecialchars(GeneralUtility::makeInstance(PageRepository::class)->getExtURL($this->pageinfo)); + if ($externalUrl !== false) { + $externalUrlHtml = '<a href="' . $externalUrl . '" target="_blank" rel="noopener">' . $externalUrl . '</a>'; + $view->assignMultiple([ + 'title' => $this->pageinfo['title'], + 'message' => sprintf($lang->getLL('pageIsExternalLinkMessage'), $externalUrlHtml), + 'state' => InfoboxViewHelper::STATE_INFO + ]); + $content .= $view->render(); + } + } } // If content from different pid is displayed if ($this->pageinfo['content_from_pid']) { @@ -569,8 +636,6 @@ class PageLayoutController $title = BackendUtility::getRecordTitle('pages', $contentPage); $link = '<a href="' . $linkToPid . '">' . htmlspecialchars($title) . ' (PID ' . (int)$this->pageinfo['content_from_pid'] . ')</a>'; $message = sprintf($lang->getLL('content_from_pid_title'), $link); - $view = GeneralUtility::makeInstance(StandaloneView::class); - $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates/InfoBox.html')); $view->assignMultiple([ 'title' => $title, 'message' => $message, diff --git a/typo3/sysext/backend/Resources/Private/Language/locallang_layout.xlf b/typo3/sysext/backend/Resources/Private/Language/locallang_layout.xlf index ab85533445c99e9c2864a9f5bfb324f2b1b55a5f..c61d9e4f5a17e0f9a7e0f34734b146b476bd7cb3 100644 --- a/typo3/sysext/backend/Resources/Private/Language/locallang_layout.xlf +++ b/typo3/sysext/backend/Resources/Private/Language/locallang_layout.xlf @@ -261,6 +261,21 @@ <trans-unit id="content_from_pid_title"> <source>Page uses content from this page: %s</source> </trans-unit> + <trans-unit id="pageIsExternalLinkMessage"> + <source>Page is a link to the following external URL: %s</source> + </trans-unit> + <trans-unit id="pageIsInternalLinkMessage"> + <source>Page is a link to the following page: %s</source> + </trans-unit> + <trans-unit id="pageIsRandomInternalLinkMessage"> + <source>Page is a link to a random page.</source> + </trans-unit> + <trans-unit id="pageIsMisconfiguredInternalLinkMessage"> + <source>Page is configured to be a link but there is actually no target defined.</source> + </trans-unit> + <trans-unit id="pageIsMisconfiguredExternalLinkMessage"> + <source>Page is configured to be an external link but there is actually no URL defined.</source> + </trans-unit> <trans-unit id="goToListModule"> <source>Go to list module</source> </trans-unit>