Project

General

Profile

Actions

Task #54887

closed

Post-processing of the previewUrl

Added by Xavier Perseguers over 10 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend API
Target version:
-
Start date:
2014-01-09
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.4
Tags:
Complexity:
Sprint Focus:

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">&nbsp;</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.

Actions

Also available in: Atom PDF