Commit adfa7822 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

Revert "[BUGFIX] Fix language of placeholder for relations"

This reverts commit 5be3ec13.

Further issues popped up in the master patch.

Reverts: #75040
Releases: master
Change-Id: I8ed284060b9b8ef018f4097c772032e81e3e885b
Reviewed-on: https://review.typo3.org/54826


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 6db0ff19
......@@ -14,11 +14,9 @@ namespace TYPO3\CMS\Backend\Form\FormDataProvider;
* The TYPO3 project - inspiring people to share!
*/
use Doctrine\DBAL\Connection;
use TYPO3\CMS\Backend\Form\FormDataCompiler;
use TYPO3\CMS\Backend\Form\FormDataGroup\TcaInputPlaceholderRecord;
use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -121,18 +119,7 @@ class TcaInputPlaceholders implements FormDataProviderInterface
}
if (!empty($possibleUids) && !empty($fieldNameArray)) {
if (count($possibleUids) > 1
&& !empty($GLOBALS['TCA'][$foreignTableName]['ctrl']['languageField'])
&& isset($result['currentSysLanguage'])
) {
$possibleUids = $this->getPossibleUidsByCurrentSysLanguage($possibleUids, $foreignTableName, $result['currentSysLanguage']);
}
$relatedFormData = $this->getRelatedFormData($foreignTableName, $possibleUids[0], $fieldNameArray[0]);
if (!empty($GLOBALS['TCA'][$result['tableName']]['ctrl']['languageField'])
&& (isset($result['databaseRow'][$GLOBALS['TCA'][$result['tableName']]['ctrl']['languageField']]))
) {
$relatedFormData['currentSysLanguage'] = $result['databaseRow'][$GLOBALS['TCA'][$result['tableName']]['ctrl']['languageField']][0];
}
$value = $this->getPlaceholderValue($fieldNameArray, $relatedFormData, $recursionLevel + 1);
}
......@@ -215,51 +202,6 @@ class TcaInputPlaceholders implements FormDataProviderInterface
return $allowedTable;
}
/**
* E.g. sys_file is not translatable, thus the uid of the translation of it's metadata has to be retrieved here.
*
* Get the uid of e.g. a file metadata entry for a given sys_language_uid and the possible translated data.
* If there is no translation available, return the uid of default language.
* If there is no value at all, return the "possible uids".
*
* @param array $possibleUids
* @param string $foreignTableName
* @param int $currentLanguage
* @return array
*/
protected function getPossibleUidsByCurrentSysLanguage(array $possibleUids, $foreignTableName, $currentLanguage)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($foreignTableName);
$newUids = $queryBuilder->select('uid')
->from($foreignTableName)
->where(
$queryBuilder->expr()->in(
'uid',
$queryBuilder->createNamedParameter($possibleUids, Connection::PARAM_INT_ARRAY)
),
$queryBuilder->expr()->in(
$GLOBALS['TCA'][$foreignTableName]['ctrl']['languageField'],
$queryBuilder->createNamedParameter([$currentLanguage, 0], Connection::PARAM_INT_ARRAY)
)
)
->orderBy($GLOBALS['TCA'][$foreignTableName]['ctrl']['languageField'], 'ASC')
->setMaxResults(2)
->execute()
->fetchAll(\PDO::FETCH_NUM);
if (!empty($newUids)) {
// translation available
if (!empty($newUids[1])) {
return $newUids[1];
}
// no translation available, use default
return $newUids[0];
}
return $possibleUids;
}
/**
* @return LanguageService
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment