0009275_v2.patch

Administrator Admin, 2008-09-03 09:36

Download (5.53 KB)

View differences:

t3lib/class.t3lib_page.php (working copy)
338 338
	 * @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.
339 339
	 */
340 340
	function getRecordOverlay($table,$row,$sys_language_content,$OLmode='')	{
341
		global $TCA;
341
		$sys_language_content = intval($sys_language_content);
342 342

  
343
		if ($row['uid']>0 && $row['pid']>0)	{
344
			if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'])	{
345
				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....)
343
		if ($row['uid'] > 0 && $row['pid'] > 0 && isset($GLOBALS['TCA'][$table]['ctrl'])) {
344
			$thisCtrl = $GLOBALS['TCA'][$table]['ctrl'];
346 345

  
346
			// If the localization is on a separate table (e.g. pages):
347
			if (isset($thisCtrl['transForeignTable']) && $thisCtrl['transForeignTable'] && isset($GLOBALS['TCA'][$thisCtrl['transForeignTable']]['ctrl'])) {
348
				$foreignCtrl = $GLOBALS['TCA'][$thisCtrl['transForeignTable']]['ctrl'];
349
				if (isset($foreignCtrl['transOrigPointerTable']) && $foreignCtrl['transOrigPointerTable'] == $table && isset($foreignCtrl['transOrigPointerField']) && $foreignCtrl['transOrigPointerField'] && isset($foreignCtrl['languageField']) && $foreignCtrl['languageField']) {
350
					$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
351
						'*',
352
						$thisCtrl['transForeignTable'],
353
						$foreignCtrl['transOrigPointerField'] . '=' . intval($row['uid']) .
354
							' AND ' . $foreignCtrl['languageField'] . '=' . $sys_language_content .
355
							$this->enableFields($thisCtrl['transForeignTable']),
356
						'',
357
						'',
358
						'1'
359
					);
360

  
361
					// If translated record is available, use it:
362
					if ($overlayRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
363
						// Fetch versioning preview overlay (if any):
364
						$this->versionOL($thisCtrl['transForeignTable'], $overlayRow);
365
						// Unset fields thas must not be overlaid:
366
						unset($overlayRow['uid']);
367
						unset($overlayRow['pid']);
368
						// Merge original record with fields that are available in original and overlay record:
369
						$row = array_merge($row, array_intersect_key($overlayRow, $row));
370
						// Set hint that we have an overlaid record now:
371
						$row['_IS_OVERLAY'] = true;
372
					// If non translated records shall not be shown, do it:
373
					} elseif ($OLmode === 'hideNonTranslated') {
374
						unset($row);
375
					}
376
					$GLOBALS['TYPO3_DB']->sql_free_result($res);
377
				}
378
			// If the localization is on the same table (e.g. tt_content):
379
			} elseif ($thisCtrl['languageField'] && $thisCtrl['transOrigPointerField']) {
380
				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....)
381

  
347 382
						// Will try to overlay a record only if the sys_language_content value is larger than zero.
348 383
					if ($sys_language_content>0)	{
349 384

  
350 385
							// Must be default language or [All], otherwise no overlaying:
351
						if ($row[$TCA[$table]['ctrl']['languageField']]<=0)	{
386
						if ($row[$thisCtrl['languageField']] <= 0) {
352 387

  
353 388
								// Select overlay record:
354 389
							$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
355 390
								'*',
356 391
								$table,
357 392
								'pid='.intval($row['pid']).
358
									' AND '.$TCA[$table]['ctrl']['languageField'].'='.intval($sys_language_content).
359
									' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
393
									' AND ' . $thisCtrl['languageField'] . '=' . $sys_language_content .
394
									' AND ' . $thisCtrl['transOrigPointerField'] . '=' . intval($row['uid']) .
360 395
									$this->enableFields($table),
361 396
								'',
362 397
								'',
......
379 414
										$row['_LOCALIZED_UID'] = $olrow['uid'];
380 415
									}
381 416
								}
382
							} 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.
417
							} 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.
383 418
								unset($row);
384 419
							}
385 420

  
386 421
							// 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.
387
						} elseif ($sys_language_content!=$row[$TCA[$table]['ctrl']['languageField']])	{
422
						} elseif ($sys_language_content != $row[$thisCtrl['languageField']]) {
388 423
							unset($row);
389 424
						}
390 425
					} else {
391 426
							// When default language is displayed, we never want to return a record carrying another language!:
392
						if ($row[$TCA[$table]['ctrl']['languageField']]>0)	{
427
						if ($row[$thisCtrl['languageField']] > 0) {
393 428
							unset($row);
394 429
						}
395 430
					}