Bug #19275 » 0009275_v2.patch
t3lib/class.t3lib_page.php (working copy) | ||
---|---|---|
* @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.
|
||
*/
|
||
function getRecordOverlay($table,$row,$sys_language_content,$OLmode='') {
|
||
global $TCA;
|
||
$sys_language_content = intval($sys_language_content);
|
||
if ($row['uid']>0 && $row['pid']>0) {
|
||
if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField']) {
|
||
if (!$TCA[$table]['ctrl']['transOrigPointerTable']) { // Will not be able to work with other tables (Just didn't implement it yet; Requires a scan over all tables [ctrl] part for first FIND the table that carries localization information for this table (which could even be more than a single table) and then use that. Could be implemented, but obviously takes a little more....)
|
||
if ($row['uid'] > 0 && $row['pid'] > 0 && isset($GLOBALS['TCA'][$table]['ctrl'])) {
|
||
$thisCtrl = $GLOBALS['TCA'][$table]['ctrl'];
|
||
// If the localization is on a separate table (e.g. pages):
|
||
if (isset($thisCtrl['transForeignTable']) && $thisCtrl['transForeignTable'] && isset($GLOBALS['TCA'][$thisCtrl['transForeignTable']]['ctrl'])) {
|
||
$foreignCtrl = $GLOBALS['TCA'][$thisCtrl['transForeignTable']]['ctrl'];
|
||
if (isset($foreignCtrl['transOrigPointerTable']) && $foreignCtrl['transOrigPointerTable'] == $table && isset($foreignCtrl['transOrigPointerField']) && $foreignCtrl['transOrigPointerField'] && isset($foreignCtrl['languageField']) && $foreignCtrl['languageField']) {
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'*',
|
||
$thisCtrl['transForeignTable'],
|
||
$foreignCtrl['transOrigPointerField'] . '=' . intval($row['uid']) .
|
||
' AND ' . $foreignCtrl['languageField'] . '=' . $sys_language_content .
|
||
$this->enableFields($thisCtrl['transForeignTable']),
|
||
'',
|
||
'',
|
||
'1'
|
||
);
|
||
// If translated record is available, use it:
|
||
if ($overlayRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
|
||
// Fetch versioning preview overlay (if any):
|
||
$this->versionOL($thisCtrl['transForeignTable'], $overlayRow);
|
||
// Unset fields thas must not be overlaid:
|
||
unset($overlayRow['uid']);
|
||
unset($overlayRow['pid']);
|
||
// Merge original record with fields that are available in original and overlay record:
|
||
$row = array_merge($row, array_intersect_key($overlayRow, $row));
|
||
// Set hint that we have an overlaid record now:
|
||
$row['_IS_OVERLAY'] = true;
|
||
// If non translated records shall not be shown, do it:
|
||
} elseif ($OLmode === 'hideNonTranslated') {
|
||
unset($row);
|
||
}
|
||
$GLOBALS['TYPO3_DB']->sql_free_result($res);
|
||
}
|
||
// If the localization is on the same table (e.g. tt_content):
|
||
} elseif ($thisCtrl['languageField'] && $thisCtrl['transOrigPointerField']) {
|
||
if (!$thisCtrl['transOrigPointerTable']) { // Will not be able to work with other tables (Just didn't implement it yet; Requires a scan over all tables [ctrl] part for first FIND the table that carries localization information for this table (which could even be more than a single table) and then use that. Could be implemented, but obviously takes a little more....)
|
||
// Will try to overlay a record only if the sys_language_content value is larger than zero.
|
||
if ($sys_language_content>0) {
|
||
// Must be default language or [All], otherwise no overlaying:
|
||
if ($row[$TCA[$table]['ctrl']['languageField']]<=0) {
|
||
if ($row[$thisCtrl['languageField']] <= 0) {
|
||
// Select overlay record:
|
||
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
|
||
'*',
|
||
$table,
|
||
'pid='.intval($row['pid']).
|
||
' AND '.$TCA[$table]['ctrl']['languageField'].'='.intval($sys_language_content).
|
||
' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
|
||
' AND ' . $thisCtrl['languageField'] . '=' . $sys_language_content .
|
||
' AND ' . $thisCtrl['transOrigPointerField'] . '=' . intval($row['uid']) .
|
||
$this->enableFields($table),
|
||
'',
|
||
'',
|
||
... | ... | |
$row['_LOCALIZED_UID'] = $olrow['uid'];
|
||
}
|
||
}
|
||
} elseif ($OLmode==='hideNonTranslated' && $row[$TCA[$table]['ctrl']['languageField']]==0) { // Unset, if non-translated records should be hidden. ONLY done if the source record really is default language and not [All] in which case it is allowed.
|
||
} elseif ($OLmode === 'hideNonTranslated' && $row[$thisCtrl['languageField']] == 0) { // Unset, if non-translated records should be hidden. ONLY done if the source record really is default language and not [All] in which case it is allowed.
|
||
unset($row);
|
||
}
|
||
// Otherwise, check if sys_language_content is different from the value of the record - that means a japanese site might try to display french content.
|
||
} elseif ($sys_language_content!=$row[$TCA[$table]['ctrl']['languageField']]) {
|
||
} elseif ($sys_language_content != $row[$thisCtrl['languageField']]) {
|
||
unset($row);
|
||
}
|
||
} else {
|
||
// When default language is displayed, we never want to return a record carrying another language!:
|
||
if ($row[$TCA[$table]['ctrl']['languageField']]>0) {
|
||
if ($row[$thisCtrl['languageField']] > 0) {
|
||
unset($row);
|
||
}
|
||
}
|
- « Previous
- 1
- 2
- Next »