Commit 3eaade3a authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Anja Leichsenring
Browse files

[TASK] Show hints about shortcuts and external pages in Page module

To improve the usability, pages of the type shortcut and external link
show additional information in the page module

Resolves: #77742
Releases: master
Change-Id: Ica5e2ecc017842bc6cca9bd347a59def2c7b6ad4
Reviewed-on: https://review.typo3.org/49715

Reviewed-by: default avatarDaniel Goerz <ervaude@gmail.com>
Tested-by: default avatarDaniel Goerz <ervaude@gmail.com>
Reviewed-by: default avatarJoerg Boesche <typo3@joergboesche.de>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarMichael Oehlhof <typo3@oehlhof.de>
Tested-by: default avatarMichael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Łukasz Uznański
Tested-by: Łukasz Uznański
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent d9c604f2
......@@ -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,
......
......@@ -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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment