[BUGFIX] Translation of a form makes the form wizard unusable 96/12996/9
authorMario Rimann <mario.rimann@typo3.org>
Tue, 15 Jan 2013 09:20:27 +0000 (10:20 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 13 Mar 2013 21:43:49 +0000 (22:43 +0100)
As soon as the form-configuration for the form wizard gets
loaded, the leading "[Translate to XYZ:] " is stripped off to get the
wizard working (with the leading text, the form config could not
be serialized as needed and the wizard didn't show a single field).

The stripping is only done on localized records.

Change-Id: I0cab1d371abf5ae01b524c39acedcd1a3a5db9c4
Fixes: #39127
Releases: 4.7, 6.0, 6.1
Reviewed-on: https://review.typo3.org/12996
Tested-by: Mario Rimann
Reviewed-by: Stefan Galinski
Tested-by: Stefan Galinski
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/form/Classes/Domain/Repository/ContentRepository.php

index 65a17ae..2343eaa 100644 (file)
@@ -46,9 +46,18 @@ class ContentRepository {
                $recordId = (int) $getPostVariables['uid'];
                $row = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $recordId);
                if (is_array($row)) {
+                       // strip off the leading "[Translate to XY]" text after localizing the original record
+                       $languageField = $GLOBALS['TCA']['tt_content']['ctrl']['languageField'];
+                       $transOrigPointerField = $GLOBALS['TCA']['tt_content']['ctrl']['transOrigPointerField'];
+                       if ($row[$languageField] > 0 && $row[$transOrigPointerField] > 0) {
+                               $bodytext = preg_replace('/^\[.*?\] /', '', $row['bodytext'], 1);
+                       } else {
+                               $bodytext = $row['bodytext'];
+                       }
+
                        /** @var $typoScriptParser t3lib_tsparser */
                        $typoScriptParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_tsparser');
-                       $typoScriptParser->parse($row['bodytext']);
+                       $typoScriptParser->parse($bodytext);
                        /** @var $record \TYPO3\CMS\Form\Domain\Model\Content */
                        $record = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Domain\\Model\\Content');
                        $record->setUid($row['uid']);