Project

General

Profile

Bug #17354 » l10nFallback.patch

Stefan Galinski, 2012-03-28 13:30

View differences:

t3lib/class.t3lib_page.php
function getPageOverlay($pageInput, $lUid = -1) {
// Initialize:
$specialLanguageRequested = TRUE;
if ($lUid < 0) {
$specialLanguageRequested = FALSE;
$lUid = $this->sys_language_uid;
}
$row = NULL;
......
}
if (count($fieldArr)) {
$orFallbackLanguage = '';
if (!$specialLanguageRequested && !in_array($GLOBALS['TSFE']->sys_language_fallback, array(0, $lUid))) {
$orFallbackLanguage = ' OR sys_language_uid = ' . $GLOBALS['TSFE']->sys_language_fallback;
}
/*
NOTE to enabledFields('pages_language_overlay'):
Currently the showHiddenRecords of TSFE set will allow pages_language_overlay records to be selected as they are child-records of a page.
......
*/
// Selecting overlay record:
$fieldArr[] = 'sys_language_uid';
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
implode(',', $fieldArr),
'pages_language_overlay',
'pid=' . intval($page_id) . '
AND sys_language_uid=' . intval($lUid) .
AND (sys_language_uid=' . intval($lUid) . $orFallbackLanguage . ')'.
$this->enableFields('pages_language_overlay'),
'',
'',
'1'
2
);
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
// Prefer the lUid row instead
$row = NULL;
while (($temp = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
$row = $temp;
if ($row['sys_language_uid'] == $lUid) {
break;
}
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
$this->versionOL('pages_language_overlay', $row);
......
}
/**
* Creates a language overlay for records that are stored inside tables that containing the
* translation informations itself. In opposite to getRecordOverlay this method checks the
* sys_language_fallback variable if the fetched record wasn't overlaid.
*
* @param string $table
* @param array $row Record to overlay. Must containt uid, pid and $table]['ctrl']['languageField']
* @param integer $sys_language_content Pointer to the sys_language uid for content on the site.
* @param string $OLmode Overlay mode. If "hideNonTranslated" then records without translation will not be returned un-translated but unset (and return value is FALSE)
* @return mixed Returns the input record, possibly overlaid with a translation. But if $OLmode is "hideNonTranslated" then it will return FALSE if no translation is found.
*/
public function getRecordOverlayWithFallback($table, $row, $sys_language_content, $OLmode = '') {
$fallback = $GLOBALS['TSFE']->sys_language_fallback;
$record = $this->getRecordOverlay($table, $row, $sys_language_content, $OLmode);
if ($fallback && $sys_language_content && $fallback !== $sys_language_content && $OLmode !== 'hideNonTranslated') {
if (!is_array($record) || !isset($record['_LOCALIZED_UID'])) {
$record = $this->getRecordOverlay($table, $row, $fallback, $OLmode);
}
}
return $record;
}
/**
* Creates language-overlay for records in general (where translation is found in records from the same table)
*
* @param string Table name
......
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_page.php']);
}
?>
?>
typo3/sysext/cms/tslib/class.tslib_fe.php
var $sys_language_uid=0; // Site language, 0 (zero) is default, int+ is uid pointing to a sys_language record. Should reflect which language menus, templates etc is displayed in (master language) - but not necessarily the content which could be falling back to default (see sys_language_content)
var $sys_language_mode=''; // Site language mode for content fall back.
var $sys_language_content=0; // Site content selection uid (can be different from sys_language_uid if content is to be selected from a fall-back language. Depends on sys_language_mode)
public $sys_language_fallback = 0; // Almost the same as sys_language_content, but can differ if a content_fallback mode was requested
var $sys_language_contentOL=0; // Site content overlay flag; If set - and sys_language_content is > 0 - , records selected will try to look for a translation pointing to their uid. (If configured in [ctrl][languageField] / [ctrl][transOrigP...]
var $sys_language_isocode = ''; // Is set to the iso code of the sys_language_content if that is properly defined by the sys_language record representing the sys_language_uid. (Requires the extension "static_info_tables")
......
}
// Get values from TypoScript:
$this->sys_language_uid = $this->sys_language_content = intval($this->config['config']['sys_language_uid']);
$this->sys_language_uid = $this->sys_language_content = $this->sys_language_fallback = intval($this->config['config']['sys_language_uid']);
list($this->sys_language_mode,$sys_language_content) = t3lib_div::trimExplode(';', $this->config['config']['sys_language_mode']);
$this->sys_language_contentOL = $this->config['config']['sys_language_overlay'];
......
$fallBackOrder = t3lib_div::intExplode(',', $sys_language_content);
foreach($fallBackOrder as $orderValue) {
if (!strcmp($orderValue,'0') || count($this->sys_page->getPageOverlay($this->id, $orderValue))) {
$this->sys_language_content = $orderValue; // Setting content uid (but leaving the sys_language_uid)
// Setting content uid (but leaving the sys_language_uid)
$this->sys_language_content = $this->sys_language_fallback = $orderValue;
$this->page = $this->sys_page->getPageOverlay($this->page, $orderValue);
break;
}
}
......
break;
default:
// Default is that everything defaults to the default language...
$this->sys_language_uid = $this->sys_language_content = 0;
$this->sys_language_uid = $this->sys_language_fallback = $this->sys_language_content = 0;
break;
}
}
......
} else {
// Setting sys_language if an overlay record was found (which it is only if a language is used)
$this->page = $this->sys_page->getPageOverlay($this->page, $this->sys_language_uid);
if ($this->sys_language_mode === 'content_fallback') {
$fallBackOrder = t3lib_div::intExplode(',', $sys_language_content);
foreach ($fallBackOrder as $languageId) {
if (!$languageId) {
continue;
}
$overlaidPage = $this->sys_page->getPageOverlay($this->id, $languageId);
if (count($overlaidPage)) {
$this->sys_language_fallback = $languageId;
break;
}
}
}
}
}
typo3/sysext/cms/tslib/content/class.tslib_content_content.php
if ($conf['table'] == 'pages') {
$row = $GLOBALS['TSFE']->sys_page->getPageOverlay($row);
} else {
$row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($conf['table'], $row, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
$row = $GLOBALS['TSFE']->sys_page->getRecordOverlayWithFallback($conf['table'], $row, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
}
}
typo3/sysext/cms/tslib/content/class.tslib_content_records.php
// Language overlay:
if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
$row = $GLOBALS['TSFE']->sys_page->getRecordOverlay(
$row = $GLOBALS['TSFE']->sys_page->getRecordOverlayWithFallback(
$val['table'],
$row,
$GLOBALS['TSFE']->sys_language_content,
(7-7/12)