Index: typo3/sysext/cms/tslib/class.tslib_fe.php =================================================================== --- typo3/sysext/cms/tslib/class.tslib_fe.php (revision 3539) +++ typo3/sysext/cms/tslib/class.tslib_fe.php (revision 3542) @@ -1804,6 +1804,10 @@ $this->setSimulReplacementChar(); } + if ($this->config['config']['typolinkEnableLinksAccrosDomains']) { + $this->config['config']['typolinkCheckRootline'] = true; + } + // Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0 if (!isset($this->config['config']['removeDefaultJS']) && t3lib_div::compat_version('4.0')) { $this->config['config']['removeDefaultJS'] = 'external'; Index: typo3/sysext/cms/tslib/class.tslib_menu.php =================================================================== --- typo3/sysext/cms/tslib/class.tslib_menu.php (revision 3539) +++ typo3/sysext/cms/tslib/class.tslib_menu.php (revision 3542) @@ -1167,9 +1167,9 @@ // Creating link: if ($this->mconf['collapse'] && $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key))) { $thePage = $this->sys_page->getPage($this->menuArr[$key]['pid']); - $LD = $this->tmpl->linkData($thePage,$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride); + $LD = $this->menuTypoLink($thePage,$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride); } else { - $LD = $this->tmpl->linkData($this->menuArr[$key],$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->I['val']['additionalParams'].$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride); + $LD = $this->menuTypoLink($this->menuArr[$key],$mainTarget,'','',$overrideArray, $this->mconf['addParams'].$MP_params.$this->I['val']['additionalParams'].$this->menuArr[$key]['_ADD_GETVARS'], $typeOverride); } // Override URL if using "External URL" as doktype with a valid e-mail address: @@ -1225,7 +1225,7 @@ $addParams = $this->mconf['showAccessRestrictedPages.']['addParams']; $addParams = str_replace('###RETURN_URL###',rawurlencode($LD['totalURL']),$addParams); $addParams = str_replace('###PAGE_ID###',$page['uid'],$addParams); - $LD = $this->tmpl->linkData($thePage,$mainTarget,'','','', $addParams, $typeOverride); + $LD = $this->menuTypoLink($thePage,$mainTarget,'','','', $addParams, $typeOverride); } } @@ -1508,6 +1508,40 @@ return $banUidArray; } + /** + * Converts a call to linkData to a call to typolink. + * + * @param array $page Page record (uid points where to link to) + * @param string $oTarget Target frame/window + * @param boolean $no_cache true if caching should be disabled + * @param string $script Alternative script name + * @param array $overrideArray Array to override values in $page + * @param string $addParams Parameters to add to URL + * @param array $typeOverride "type" value + * @return array See linkData + */ + function menuTypoLink($page, $oTarget, $no_cache, $script, $overrideArray = '', $addParams = '', $typeOverride = '') { + $conf = array( + 'parameter' => is_array($overrideArray) && $overrideArray['uid'] ? $overrideArray['uid'] : $page['uid'], + ); + if ($typeOverride && t3lib_div::testInt($typeOverride)) { + $conf['parameter'] .= ',' . $typeOverride; + } + if ($addParams) { + $conf['additionalParams'] = $addParams; + } + if ($no_cache) { + $conf['no_cache'] = true; + } + if ($oTarget) { + $conf['target'] = $oTarget; + } + $this->parent_cObj->typoLink('|', $conf); + $LD = $this->parent_cObj->lastTypoLinkLD; + $LD['totalURL'] = $this->parent_cObj->lastTypoLinkUrl; + return $LD; + } + } @@ -2481,7 +2515,7 @@ unset($theValArr['text.']); // if this is not done it seems that imageMaps will be rendered wrong!! // check links - $LD = $this->tmpl->linkData($this->menuArr[$key],$this->mconf['target'],'','',array(),'',$this->mconf['forceTypeValue']); + $LD = $this->menuTypoLink($this->menuArr[$key],$this->mconf['target'],'','',array(),'',$this->mconf['forceTypeValue']); // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page: $this->changeLinksForAccessRestrictedPages($LD, $this->menuArr[$key], $this->mconf['target'], $this->mconf['forceTypeValue']); @@ -2780,7 +2814,7 @@ $url=''; $target=''; if ((!$addLines && !$levelConf['noLink']) || $levelConf['alwaysLink']) { - $LD = $this->tmpl->linkData($data,$this->mconf['target'],'','',array(),$MP_params,$this->mconf['forceTypeValue']); + $LD = $this->menuTypoLink($data,$this->mconf['target'],'','',array(),$MP_params,$this->mconf['forceTypeValue']); // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page: $this->changeLinksForAccessRestrictedPages($LD, $data, $this->mconf['target'], $this->mconf['forceTypeValue']); Index: typo3/sysext/cms/tslib/class.tslib_content.php =================================================================== --- typo3/sysext/cms/tslib/class.tslib_content.php (revision 3539) +++ typo3/sysext/cms/tslib/class.tslib_content.php (revision 3542) @@ -335,6 +335,7 @@ var $checkPid_badDoktypeList = '255'; var $lastTypoLinkUrl=''; // This will be set by typoLink() to the url of the most recent link created. var $lastTypoLinkTarget=''; // DO. link target. + var $lastTypoLinkLD = array(); var $substMarkerCache=array(); // Caching substituteMarkerArrayCached function var $recordRegister=array(); // Array that registers rendered content elements (or any table) to make sure they are not rendered recursively! var $cObjHookObjectsArr = array(); // Containig hooks for userdefined cObjects @@ -5035,6 +5036,7 @@ * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=321&cHash=59bd727a5e */ function typoLink($linktxt, $conf) { + $LD = array(); $finalTagParts = array(); $finalTagParts['aTagParams'] = $this->getATagParams($conf); @@ -5212,7 +5214,24 @@ // Add "&MP" var: $addQueryParams.= '&MP='.rawurlencode(implode(',',$MPvarAcc)); } - elseif ($GLOBALS['TSFE']->config['config']['typolinkCheckRootline']) { + elseif ($GLOBALS['TSFE']->config['config']['typolinkCheckRootline']) { + + // If we link across domains and page is free type shortcut, we must resolve the shortcut first! + // If we do not do it, TYPO3 will fail to (1) link proper page in RealURL/CoolURI because + // they return relative links and (2) show proper page if no RealURL/CoolURI exists when link is clicked + if ($GLOBALS['TSFE']->config['config']['typolinkEnableLinksAcrossDomains'] && $page['doktype'] == 4 && $page['shortcut_mode'] == 0) { + $page2 = $page; // Save in case of broken destination or endless loop + $maxLoopCount = 20; // Same as in RealURL, seems enough + while ($maxLoopCount && is_array($page) && $page['doktype'] == 4 && $page['shortcut_mode'] == 0) { + $page = $GLOBALS['TSFE']->sys_page->getPage($page['shortcut'], $disableGroupAccessCheck); + $maxLoopCount--; + } + if (count($page) == 0 || $maxLoopCount == 0) { + // We revert if shortcut is broken or maximum number of loops is exceeded (indicates endless loop) + $page = $page2; + } + } + // This checks if the linked id is in the rootline of this site and if not it will find the domain for that ID and prefix it: $tCR_rootline = $GLOBALS['TSFE']->sys_page->getRootLine($page['uid']); // Gets rootline of linked-to page $tCR_flag = 0; @@ -5221,6 +5240,10 @@ $tCR_flag = 1; // OK, it was in rootline! break; } + if ($tCR_data['is_siteroot']) { + // Possibly subdomain inside main domain. In any case we must stop now because site root is reached. + break; + } } if (!$tCR_flag) { foreach ($tCR_rootline as $tCR_data) { @@ -5233,15 +5256,28 @@ } } // If other domain, overwrite - if (strlen($tCR_domain)) { + if (strlen($tCR_domain) && !$GLOBALS['TSFE']->config['config']['typolinkEnableLinksAccrosDomains']) { $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget; - if ($conf['extTarget.']) {$target = $this->stdWrap($target, $conf['extTarget.']);} - if ($forceTarget) {$target=$forceTarget;} + if ($conf['extTarget.']) { + $target = $this->stdWrap($target, $conf['extTarget.']); + } + if ($forceTarget) { + $target = $forceTarget; + } $LD['target'] = $target; $this->lastTypoLinkUrl = $this->URLqMark('http://'.$tCR_domain.'/index.php?id='.$page['uid'],$addQueryParams).$sectionMark; } else { // Internal link: - if ($forceTarget) {$target=$forceTarget;} + if ($forceTarget) { + $target = $forceTarget; + } $LD = $GLOBALS['TSFE']->tmpl->linkData($page,$target,$conf['no_cache'],'','',$addQueryParams,$theTypeP); + if (strlen($tCR_domain)) { + // We will add domain only if URL does not have it already. + $urlParts = parse_url($LD['totalURL']); + if ($urlParts['host'] == '') { + $LD['totalURL'] = 'http://' . $tCR_domain . ($LD['totalURL']{0} == '/' ? '' : '/') . $LD['totalURL']; + } + } $this->lastTypoLinkUrl = $this->URLqMark($LD['totalURL'],'').$sectionMark; } @@ -5286,10 +5322,14 @@ } } - if ($forceTitle) {$title=$forceTitle;} + $this->lastTypoLinkLD = $LD; - if ($JSwindowParams) { + if ($forceTitle) { + $title=$forceTitle; + } + if ($JSwindowParams) { + // Create TARGET-attribute only if the right doctype is used if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype)) { $target = ' target="FEopenLink"';