Bug #19149 » patch_9046_v5.patch
typo3/sysext/cms/locallang_tca.xml (Arbeitskopie) | ||
---|---|---|
<label index="sys_domain.redirectHttpStatusCode.303">See other (303)</label>
|
||
<label index="sys_domain.redirectHttpStatusCode.307">Moved temporarily (307)</label>
|
||
<label index="sys_domain.prepend_params">Transfer parameters to Redirect URL:</label>
|
||
<label index="sys_domain.forced">Always prepend this domain in links:</label>
|
||
<label index="sys_template">Template</label>
|
||
<label index="sys_template.title">Template title:</label>
|
||
<label index="sys_template.root">Rootlevel:</label>
|
typo3/sysext/cms/ext_tables.sql (Arbeitskopie) | ||
---|---|---|
redirectHttpStatusCode int(4) unsigned DEFAULT '301' NOT NULL,
|
||
sorting int(10) unsigned DEFAULT '0' NOT NULL,
|
||
prepend_params int(10) DEFAULT '0' NOT NULL,
|
||
forced int(10) DEFAULT '0' NOT NULL,
|
||
PRIMARY KEY (uid),
|
||
KEY parent (pid)
|
typo3/sysext/cms/tbl_cms.php (Arbeitskopie) | ||
---|---|---|
'type' => 'check',
|
||
'default' => '0'
|
||
)
|
||
),
|
||
'forced' => array(
|
||
'label' => 'LLL:EXT:cms/locallang_tca.php:sys_domain.forced',
|
||
'exclude' => 1,
|
||
'config' => array(
|
||
'type' => 'check',
|
||
'default' => '0'
|
||
)
|
||
)
|
||
),
|
||
'types' => array(
|
||
'1' => array('showitem' => 'hidden;;;;1-1-1,domainName;;1;;3-3-3,prepend_params')
|
||
'1' => array('showitem' => 'hidden;;;;1-1-1,domainName;;1;;3-3-3,prepend_params,forced;;;;4-4-4')
|
||
),
|
||
'palettes' => array(
|
||
'1' => array('showitem' => 'redirectTo, redirectHttpStatusCode')
|
||
... | ... | |
?>
|
||
?>
|
typo3/sysext/cms/tslib/class.tslib_content.php (Arbeitskopie) | ||
---|---|---|
$addQueryParams.= '&cHash='.t3lib_div::shortMD5(serialize($pA));
|
||
}
|
||
$tCR_domain = '';
|
||
$targetDomain = '';
|
||
$currentDomain = t3lib_div::getIndpEnv('HTTP_HOST');
|
||
// Mount pages are always local and never link to another domain
|
||
if (count($MPvarAcc)) {
|
||
// Add "&MP" var:
|
||
... | ... | |
}
|
||
}
|
||
// 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']) {
|
||
$tCR_flag = 1; // OK, it was in rootline!
|
||
// find all domain records in the rootline of the target page
|
||
$targetPageRootline = $GLOBALS['TSFE']->sys_page->getRootLine($page['uid']); // Gets rootline of linked-to page
|
||
$foundDomains = array();
|
||
$foundForcedDomains = array();
|
||
$targetPageRootlinePids = array();
|
||
$isCurrentPagePartOfTargetRootline = false;
|
||
foreach ($targetPageRootline as $data) {
|
||
if ($data['uid'] == $GLOBALS['TSFE']->id) {
|
||
$isCurrentPagePartOfTargetRootline = true;
|
||
break;
|
||
}
|
||
if ($tCR_data['is_siteroot']) {
|
||
// Possibly subdomain inside main domain. In any case we must stop now because site root is reached.
|
||
break;
|
||
}
|
||
$targetPageRootlinePids[] = intval($data['uid']);
|
||
}
|
||
if (!$tCR_flag) {
|
||
foreach ($tCR_rootline as $tCR_data) {
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('domainName', 'sys_domain', 'pid='.intval($tCR_data['uid']).' AND redirectTo=\'\''.$this->enableFields('sys_domain'), '', 'sorting');
|
||
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
|
||
$GLOBALS['TYPO3_DB']->sql_free_result($res);
|
||
if ($row) {
|
||
$tCR_domain = preg_replace('/\/$/','',$row['domainName']);
|
||
break;
|
||
// if the target page is not a subpage of the current page and not the current page itself
|
||
if (!$isCurrentPagePartOfTargetRootline) {
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'pid, domainName, forced',
|
||
'sys_domain',
|
||
'pid IN ('.implode(',', $targetPageRootlinePids).') ' .
|
||
' AND redirectTo=\'\''.$this->enableFields('sys_domain'),
|
||
'',
|
||
'sorting DESC'
|
||
);
|
||
// TODO maybe it makes sense to hold all sys_domain records in a cache to save additional DB querys on each typolink
|
||
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
|
||
if (!isset($foundDomains[$row['pid']])) {
|
||
$foundDomains[$row['pid']] = preg_replace('/\/$/', '', $row['domainName']);
|
||
if ($row['forced']) {
|
||
$foundForcedDomains[$row['pid']] = $foundDomains[$row['pid']];
|
||
}
|
||
}
|
||
}
|
||
$GLOBALS['TYPO3_DB']->sql_free_result($res);
|
||
|
||
// set targetDomain to first found domain record if the target page cannot be reached within the current domain
|
||
if (count($foundDomains) > 0
|
||
&& ( !in_array($currentDomain, $foundDomains) || count($foundForcedDomains) > 0)) {
|
||
foreach ($targetPageRootlinePids as $pid) {
|
||
// always use the 'forced' domain if we found one
|
||
if (isset($foundForcedDomains[$pid])) {
|
||
$targetDomain = $foundForcedDomains[$pid];
|
||
break;
|
||
}
|
||
// use the first found domain record
|
||
if ($targetDomain == '' && isset($foundDomains[$pid])) {
|
||
$targetDomain = $foundDomains[$pid];
|
||
}
|
||
}
|
||
// do not prepend the domain if its the current hostname
|
||
if ($targetDomain == $currentDomain) {
|
||
$targetDomain = '';
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// If other domain, overwrite
|
||
if (strlen($tCR_domain) && !$enableLinksAcrossDomains) {
|
||
|
||
// if target page has a diffenrent domain and the current domain's linking scheme (e.g. simulateStaticDocuments/RealURL/...) should not be used
|
||
if (strlen($targetDomain) && !$enableLinksAcrossDomains) {
|
||
$target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget;
|
||
if ($conf['extTarget.']) {
|
||
$target = $this->stdWrap($target, $conf['extTarget.']);
|
||
... | ... | |
$target = $forceTarget;
|
||
}
|
||
$LD['target'] = $target;
|
||
$this->lastTypoLinkUrl = $this->URLqMark('http://'.$tCR_domain.'/index.php?id='.$page['uid'],$addQueryParams).$sectionMark;
|
||
} else { // Internal link:
|
||
$this->lastTypoLinkUrl = $this->URLqMark('http://'.$targetDomain.'/index.php?id='.$page['uid'],$addQueryParams).$sectionMark;
|
||
} else { // Internal link or current domain's linking scheme should be used
|
||
if ($forceTarget) {
|
||
$target = $forceTarget;
|
||
}
|
||
$LD = $GLOBALS['TSFE']->tmpl->linkData($page,$target,$conf['no_cache'],'','',$addQueryParams,$theTypeP);
|
||
if (strlen($tCR_domain)) {
|
||
if (strlen($targetDomain)) {
|
||
// We will add domain only if URL does not have it already.
|
||
if ($enableLinksAcrossDomains) {
|
||
... | ... | |
}
|
||
}
|
||
$urlParts = parse_url($LD['totalURL']);
|
||
if ($urlParts['host'] == '') {
|
||
$LD['totalURL'] = 'http://' . $tCR_domain . ($LD['totalURL']{0} == '/' ? '' : '/') . $LD['totalURL'];
|
||
if ($urlParts['host'] == '' && $currentDomain != $targetDomain) {
|
||
$LD['totalURL'] = 'http://' . $targetDomain . ($LD['totalURL']{0} == '/' ? '' : '/') . $LD['totalURL'];
|
||
}
|
||
}
|
||
$this->lastTypoLinkUrl = $this->URLqMark($LD['totalURL'],'').$sectionMark;
|