Project

General

Profile

Bug #22884 » disabled_domain+less_queries.diff

Administrator Admin, 2010-06-15 14:07

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)) {
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
(2-2/3)