Index: class.t3lib_befunc.php =================================================================== --- class.t3lib_befunc.php (revision 51) +++ class.t3lib_befunc.php (working copy) @@ -2615,15 +2615,6 @@ $viewScriptPreviewEnabled = '/' . TYPO3_mainDir . 'mod/user/ws/wsol_preview.php?id='; $viewScriptPreviewDisabled = '/index.php?id='; - // check alternate Domains - if ($rootLine) { - $parts = parse_url(t3lib_div::getIndpEnv('TYPO3_SITE_URL')); - if (t3lib_BEfunc::getDomainStartPage($parts['host'],$parts['path'])) { - $preUrl_temp = t3lib_BEfunc::firstDomainRecord($rootLine); - } - } - $preUrl = $preUrl_temp ? (t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://').$preUrl_temp : $backPath.'..'; - // Look if a fixed preview language should be added: $viewLanguageOrder = $GLOBALS['BE_USER']->getTSConfigVal('options.view.languageOrder'); if (strlen($viewLanguageOrder)) { @@ -2653,8 +2644,9 @@ $addGetVars.= $suffix; } - $urlPreviewEnabled = $preUrl . $viewScriptPreviewEnabled . $id . $addGetVars . $anchor; - $urlPreviewDisabled = $preUrl . $viewScriptPreviewDisabled . $id . $addGetVars . $anchor; + $viewDomain = t3lib_BEfunc::getViewDomain($id, $rootLine); + $urlPreviewEnabled = $viewDomain . $viewScriptPreviewEnabled . $id . $addGetVars . $anchor; + $urlPreviewDisabled = $viewDomain . $viewScriptPreviewDisabled . $id . $addGetVars . $anchor; } return "previewWin=window.open(top.WorkspaceFrontendPreviewEnabled?'" . @@ -2662,6 +2654,36 @@ "','newTYPO3frontendWindow');" . ( $switchFocus ? 'previewWin.focus();' : ''); } + /** + * Builds the frontend view domain for a given page ID with a given root + * line. + * + * @param integer $pageId the page ID to use, must be > 0 + * @param array $rootLine the root line structure to use + * + * @return string the full domain including the protocol http:// or https:// + * + * @author Michael Klapper + */ + public static function getViewDomain($pageId, $rootLine = null) { + $domain = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); + + if (!is_array($rootLine)) { + $rootLine = t3lib_BEfunc::BEgetRootLine($pageId); + } + + // checks alternate Domains + if (count($rootLine) > 0) { + $urlParts = parse_url($domain); + if (t3lib_BEfunc::getDomainStartPage($urlParts['host'], $urlParts['path'])) { + $protocol = t3lib_div::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://'; + $domain = $protocol . t3lib_BEfunc::firstDomainRecord($rootLine); + } + } + + return $domain; + } + /** * Returns the merged User/Page TSconfig for page id, $id. * Please read details about module programming elsewhere!