Task #54887

Post-processing of the previewUrl

Added by Xavier Perseguers over 5 years ago. Updated 10 months ago.

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

100%

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.

Associated revisions

Revision ef506270 (diff)
Added by Georg Ringer over 3 years ago

[FEATURE] Add hook to post process preview url

Add a hook to post process the preview url in
`BackendUtility->viewOnClick()'.

Change-Id: Ib5ae283276f65de79466333c685df107ce10dbe7
Resolves: #54887
Releases: master
Reviewed-on: https://review.typo3.org/45918
Reviewed-by: Markus Klein <>
Reviewed-by: Georg Ringer <>
Tested-by: Georg Ringer <>
Reviewed-by: Anja Leichsenring <>
Tested-by: Anja Leichsenring <>

Revision 7a2f10fb (diff)
Added by Benni Mack over 3 years ago

[FOLLOWUP][FEATURE] Update signature for newly introduced hook

The new hook introduced for BackendUtility::viewOnClick()
added a parameter "backPath" which was never evaluated
and was there for legacy reasons. The option has no effect
and should not be part of the hook signature.

The followup patch removes the property again.

Resolves: #54887
Releases: master
Change-Id: I6d0fec5d7639c1de00d73a4dc1196fb65268f1ce
Reviewed-on: https://review.typo3.org/47326
Reviewed-by: Frank Naegler <>
Tested-by: Frank Naegler <>
Reviewed-by: Wouter Wolters <>
Tested-by: Wouter Wolters <>

History

#1 Updated by Alexander Opitz about 5 years ago

Hi Xavier,

what's the state of this issue?

#2 Updated by Xavier Perseguers about 5 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.

#3 Updated by Alexander Opitz about 5 years ago

  • Category set to Backend API
  • Status changed from Needs Feedback to New

#4 Updated by Gerrit Code Review over 3 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

#5 Updated by Gerrit Code Review over 3 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

#6 Updated by Georg Ringer over 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#7 Updated by Gerrit Code Review over 3 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

#8 Updated by Gerrit Code Review over 3 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

#9 Updated by Benni Mack over 3 years ago

  • Status changed from Under Review to Resolved

#10 Updated by Benni Mack 10 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF