Project

General

Profile

Bug #22884 » disabled_domain+less_queries+cleanup.diff

Administrator Admin, 2010-06-15 15:38

View differences:

class.tslib_content.php (working copy)
require_once(t3lib_extMgm::extPath('obts').'_tsobject/_tso.php');
}
/**
* This class contains all main TypoScript features.
* This includes the rendering of TypoScript content objects (cObjects).
......
var $cObjHookObjectsArr = array(); // Containig hooks for userdefined cObjects
protected $stdWrapHookObjects = array(); // Containing hook objects for stdWrap
protected $getImgResourceHookObjects; // Containing hook objects for getImgResource
protected $foundDomains = NULL; // Containing sys_domain entries
protected $firstFoundDomains = NULL; // Containing sys_domain entries
protected $firstFoundForcedDomains = NULL; // Containing sys_domain entries
/**
* Set to true by doConvertToUserIntObject() if USER object wants to become USER_INT
......
// Find all domain records in the rootline of the target page
$targetPageRootline = $GLOBALS['TSFE']->sys_page->getRootLine($page['uid']);
$foundDomains = array();
$firstFoundDomains = array();
$firstFoundForcedDomains = array();
$targetPageRootlinePids = array();
foreach ($targetPageRootline as $data) {
$targetPageRootlinePids[] = intval($data['uid']);
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'pid, domainName, forced',
'sys_domain',
'pid IN (' . implode(',', $targetPageRootlinePids) . ') ' .
' AND redirectTo=\'\' ' . $this->enableFields('sys_domain'),
'',
'sorting ASC'
);
// 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)) {
$foundDomains[] = preg_replace('/\/$/', '', $row['domainName']);
if (!isset($firstFoundDomains[$row['pid']])) {
$firstFoundDomains[$row['pid']] = preg_replace('/\/$/', '', $row['domainName']);
// execute only once and save result into class variable
if (!isset($this->foundDomains)
&& !isset($this->firstFoundDomains)
&& !isset($this->firstFoundForcedDomains)) {
// init
$this->foundDomains = $this->firstFoundDomains = $this->firstFoundForcedDomains = array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'pid, domainName, forced',
'sys_domain',
'pid IN (' . implode(',', $targetPageRootlinePids) . ') ' .
' AND redirectTo=\'\' ' . $this->enableFields('sys_domain') .
' AND hidden = 0 ' ,
'',
'sorting ASC'
);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
// echo '<h1>looking for domains...</h1>';
$this->foundDomains[] = preg_replace('/\/$/', '', $row['domainName']);
if (!isset($this->firstFoundDomains[$row['pid']])) {
$this->firstFoundDomains[$row['pid']] = preg_replace('/\/$/', '', $row['domainName']);
}
if ($row['forced'] && !isset($this->firstFoundForcedDomains[$row['pid']])) {
$this->firstFoundForcedDomains[$row['pid']] = preg_replace('/\/$/', '', $row['domainName']);
}
}
if ($row['forced'] && !isset($firstFoundForcedDomains[$row['pid']])) {
$firstFoundForcedDomains[$row['pid']] = preg_replace('/\/$/', '', $row['domainName']);
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
}
$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($firstFoundForcedDomains) > 0)) {
if (count($this->foundDomains) > 0
&& (!in_array($currentDomain, $this->foundDomains) || count($this->firstFoundForcedDomains) > 0)) {
// Do not prepend the domain if its the current hostname
foreach ($targetPageRootlinePids as $pid) {
// Always use the 'forced' domain if we found one
if (isset($firstFoundForcedDomains[$pid])) {
$targetDomain = $firstFoundForcedDomains[$pid];
if (isset($this->firstFoundForcedDomains[$pid])) {
$targetDomain = $this->firstFoundForcedDomains[$pid];
break;
}
// Use the first found domain record
if ($targetDomain === '' && isset($firstFoundDomains[$pid])) {
$targetDomain = $firstFoundDomains[$pid];
if ($targetDomain === '' && isset($this->firstFoundDomains[$pid])) {
$targetDomain = $this->firstFoundDomains[$pid];
}
}
// Do not prepend the domain if its the current hostname
if ($targetDomain === $currentDomain) {
$targetDomain = '';
}
......
$absoluteUrlScheme = $conf['forceAbsoluteUrl.']['scheme'];
}
}
// in any case
if ($forceTarget) {
$target = $forceTarget;
}
// If target page has a different domain and the current domain's linking scheme (e.g. simulateStaticDocuments/RealURL/...) should not be used
if (strlen($targetDomain) && $targetDomain !== $currentDomain && !$enableLinksAcrossDomains) {
$target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget;
if ($conf['extTarget.']) {
$target = $this->stdWrap($target, $conf['extTarget.']);
}
if ($forceTarget) {
$target = $forceTarget;
}
$LD['target'] = $target;
$this->lastTypoLinkUrl = $this->URLqMark($absoluteUrlScheme . '://' . $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, $targetDomain);
if (strlen($targetDomain)) {
// We will add domain only if URL does not have it already.
if ($enableLinksAcrossDomains) {
// Get rid of the absRefPrefix if necessary. absRefPrefix is applicable only
// to the current web site. If we have domain here it means we link across
// domains. absRefPrefix can contain domain name, which will screw up
// the link to the external domain.
$prefixLength = strlen($GLOBALS['TSFE']->config['config']['absRefPrefix']);
if (substr($LD['totalURL'], 0, $prefixLength) == $GLOBALS['TSFE']->config['config']['absRefPrefix']) {
$prefixLength = strlen($GLOBALS['TSFE']->absRefPrefix);
if (substr($LD['totalURL'], 0, $prefixLength) == $GLOBALS['TSFE']->absRefPrefix) {
$LD['totalURL'] = substr($LD['totalURL'], $prefixLength);
}
}
}
$urlParts = parse_url($LD['totalURL']);
if ($urlParts['host'] == '') {
$LD['totalURL'] = $absoluteUrlScheme . '://' . $targetDomain . ($LD['totalURL']{0} == '/' ? '' : '/') . $LD['totalURL'];
}
}
$this->lastTypoLinkUrl = $this->URLqMark($LD['totalURL'],'').$sectionMark;
}
$this->lastTypoLinkTarget = $LD['target'];
(3-3/3)