Index: typo3/sysext/cms/tslib/class.tslib_menu.php =================================================================== --- typo3/sysext/cms/tslib/class.tslib_menu.php (revision 3459) +++ typo3/sysext/cms/tslib/class.tslib_menu.php (working copy) @@ -1210,9 +1210,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->linkData2typoLink($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->linkData2typoLink($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: @@ -1268,7 +1268,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->linkData2typoLink($thePage,$mainTarget,'','','', $addParams, $typeOverride); } } @@ -1552,6 +1552,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 linkData2typoLink($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; + } + } @@ -2526,7 +2560,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->linkData2typoLink($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']); @@ -2825,7 +2859,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->linkData2typoLink($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 3459) +++ typo3/sysext/cms/tslib/class.tslib_content.php (working copy) @@ -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 @@ -5113,6 +5114,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); @@ -5298,11 +5300,28 @@ $addQueryParams.= '&MP='.rawurlencode(implode(',',$MPvarAcc)); } 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; foreach ($tCR_rootline as $tCR_data) { - if ($tCR_data['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) { + if ($tCR_data['uid'] == $GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) { $tCR_flag = 1; // OK, it was in rootline! break; } @@ -5322,17 +5341,25 @@ // If other domain, overwrite if (strlen($tCR_domain) && !$GLOBALS['TSFE']->config['config']['typolinkEnableLinksAcrossDomains']) { $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; + $target = $forceTarget; } $LD = $GLOBALS['TSFE']->tmpl->linkData($page,$target,$conf['no_cache'],'','',$addQueryParams,$theTypeP); if (strlen($tCR_domain)) { - $LD['totalURL'] = 'http://' . $tCR_domain . ($LD['totalURL']{0} == '/' ? '' : '/') . $LD['totalURL']; + // 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; } @@ -5378,10 +5405,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"';