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 #1

Updated by Alexander Opitz about 10 years ago

Hi Xavier,

what's the state of this issue?

Actions #2

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

Actions #3

Updated by Alexander Opitz about 10 years ago

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

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

Actions #5

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/45918

Actions #6

Updated by Georg Ringer over 8 years ago

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

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

Actions #8

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

Actions #9

Updated by Benni Mack over 8 years ago

  • Status changed from Under Review to Resolved
Actions #10

Updated by Benni Mack almost 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF