0009275.patch

Administrator Admin, 2008-09-02 22:08

Download (5.43 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
					// If non translated records shall not be shown, do it:
371
					} elseif ($OLmode === 'hideNonTranslated') {
372
						unset($row);
373
					}
374
					$GLOBALS['TYPO3_DB']->sql_free_result($res);
375
				}
376
			// If the localization is on the same table (e.g. tt_content):
377
			} elseif ($thisCtrl['languageField'] && $thisCtrl['transOrigPointerField']) {
378
				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....)
379

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

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

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

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