Bug #52126 ยป 52126_TYPO3_61.diff

Patch for TYPO3 6.1 - Xavier Perseguers, 2014-12-15 16:20

View differences:

typo3/sysext/backend/Classes/Utility/BackendUtility.php
2097 2097
			case 'group':
2098 2098
				// resolve the titles for DB records
2099 2099
				if ($theColConf['internal_type'] === 'db') {
2100
					$finalValues = array();
2101
					$relationTableName = $theColConf['allowed'];
2102
					$explodedValues = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $value, TRUE);
2103

  
2104
					foreach ($explodedValues as $explodedValue) {
2105

  
2106
						if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($explodedValue)) {
2107
							$relationTableNameForField = $relationTableName;
2100
					if ($theColConf['MM']) {
2101
						if ($uid) {
2102
							// Display the title of MM related records in lists
2103
							if ($noRecordLookup) {
2104
								$MMfield = $theColConf['foreign_table'] . '.uid';
2105
							} else {
2106
								$MMfields = array($theColConf['foreign_table'] . '.' . $GLOBALS['TCA'][$theColConf['foreign_table']]['ctrl']['label']);
2107
								$altLabelFields = explode(',', $GLOBALS['TCA'][$theColConf['foreign_table']]['ctrl']['label_alt']);
2108
								foreach ($altLabelFields as $f) {
2109
									$f = trim($f);
2110
									if ($f !== '') {
2111
										$MMfields[] = $theColConf['foreign_table'] . '.' . $f;
2112
									}
2113
								}
2114
								$MMfield = join(',', $MMfields);
2115
							}
2116
							/** @var $dbGroup \TYPO3\CMS\Core\Database\RelationHandler */
2117
							$dbGroup = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
2118
							$dbGroup->start($value, $theColConf['foreign_table'], $theColConf['MM'], $uid, $table, $theColConf);
2119
							$selectUids = $dbGroup->tableArray[$theColConf['foreign_table']];
2120
							if (!empty($selectUids) && is_array($selectUids)) {
2121
								$MMres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
2122
									'uid, ' . $MMfield,
2123
									$theColConf['foreign_table'],
2124
									'uid IN (' . implode(',', $selectUids) . ')' . static::deleteClause($theColConf['foreign_table'])
2125
								);
2126
								$mmlA = array();
2127
								while ($MMrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($MMres)) {
2128
									// Keep sorting of $selectUids
2129
									$mmlA[array_search($MMrow['uid'], $selectUids)] = $noRecordLookup
2130
										? $MMrow['uid']
2131
										: static::getRecordTitle($theColConf['foreign_table'], $MMrow, FALSE, $forceResult);
2132
								}
2133
								$GLOBALS['TYPO3_DB']->sql_free_result($MMres);
2134
								if (!empty($mmlA)) {
2135
									ksort($mmlA);
2136
									$l = implode('; ', $mmlA);
2137
								} else {
2138
									$l = 'N/A';
2139
								}
2140
							} else {
2141
								$l = 'N/A';
2142
							}
2108 2143
						} else {
2109
							list($relationTableNameForField, $explodedValue) = self::splitTable_Uid($explodedValue);
2144
							$l = 'N/A';
2110 2145
						}
2146
					} else {
2147
						$finalValues = array();
2148
						$relationTableName = $theColConf['allowed'];
2149
						$explodedValues = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $value, TRUE);
2111 2150

  
2112
						$relationRecord = static::getRecordWSOL($relationTableNameForField, $explodedValue);
2113
						$finalValues[] = static::getRecordTitle($relationTableNameForField, $relationRecord);
2114
					}
2151
						foreach ($explodedValues as $explodedValue) {
2152
							if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($explodedValue)) {
2153
								$relationTableNameForField = $relationTableName;
2154
							} else {
2155
								list($relationTableNameForField, $explodedValue) = self::splitTable_Uid($explodedValue);
2156
							}
2115 2157

  
2116
					$l = implode(', ', $finalValues);
2158
							$relationRecord = static::getRecordWSOL($relationTableNameForField, $explodedValue);
2159
							$finalValues[] = static::getRecordTitle($relationTableNameForField, $relationRecord);
2160
						}
2161
						$l = implode(', ', $finalValues);
2162
					}
2117 2163
				} else {
2118 2164
					$l = implode(', ', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $value, TRUE));
2119 2165
				}
    (1-1/1)