Task #54887
closedPost-processing of the previewUrl
100%
Description
In BackendUtility, there is a hook to pre-process the previewUrl (although I don't really see any benefit) but there is no way to post-process it, before preparing the JS code
<a href="#" onclick="var previewWin = window.open('http://domain.tld/index.php?id=5737','newTYPO3frontendWindow');previewWin.focus();" title="View webpage"><span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-view"> </span></a>
The existing (pre) hook is found in \TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick
.
Use Case¶
TYPO3 Backend is accessible through SSL (https://somedomain.tld), multi-domain setup, part of the tree is on domain someotherdomain.tld. SSL is not configured for this domain, making all preview links break since they are generated as https://someotherdomain.tld.
To prevent this behaviour, every page's property in this website should be marked as using protocol "http:" instead of "default". This is hardly a solution since at some point, SSL might be activated and as such enforced.
Proposal¶
diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index b4e620d..7ef025b 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -2514,6 +2514,15 @@ class BackendUtility { $previewUrl = self::createPreviewUrl($pageUid, $rootLine, $anchorSection, $additionalGetVars, $viewScript); } + if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['viewOnClickClass']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['viewOnClickClass'])) { + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['viewOnClickClass'] as $funcRef) { + $hookObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($funcRef); + if (method_exists($hookObj, 'postProcess')) { + $hookObj->postProcess($previewUrl); + } + } + } + $onclickCode = 'var previewWin = window.open(\'' . $previewUrl . '\',\'newTYPO3frontendWindow\');' . ($switchFocus ? 'previewWin.focus();' : ''); return $onclickCode; }
Caveat¶
This has been PoCed and works, but I must still ensure save+view works as well (it does not seem to work at all, regardless of this patch, I must investigate).
@Ernesto, may this hook finds its way into 6.2? Currently tried it in my 6.1 website but goal is of course to upgrade to 6.2.
Updated by Alexander Opitz over 10 years ago
Hi Xavier,
what's the state of this issue?
Updated by Xavier Perseguers over 10 years ago
I don't have the need anymore since my websites are fully running on SSL but the problem must not have changed so a hook would still be useful. I'd go for a hook and not a signal since the "pre" is already hook but maybe that may be changed.
Could go to master and not 6.2 as this is a special need and we should not add anything more to 6.2.
Updated by Alexander Opitz over 10 years ago
- Category set to Backend API
- Status changed from Needs Feedback to New
Updated by Gerrit Code Review almost 9 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45918
Updated by Gerrit Code Review almost 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45918
Updated by Georg Ringer almost 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset ef5062706bee0beb497b0ac447d784fb8a50b213.
Updated by Gerrit Code Review over 8 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47326
Updated by Gerrit Code Review over 8 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47326
Updated by Benni Mack over 8 years ago
- Status changed from Under Review to Resolved
Applied in changeset 7a2f10fb35032436dadaff2d203b336c66e86cb1.