[BUGFIX] Respect localized placeholders in TCA again 43/44143/5
authorDaniel Goerz <ervaude@gmail.com>
Sun, 18 Oct 2015 18:48:29 +0000 (20:48 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 20 Oct 2015 05:13:23 +0000 (07:13 +0200)
Change-Id: I3678ff847d43303086610f6d24ba494c0f285d29
Resolves: #70821
Resolves: #70833
Releases: master
Reviewed-on: https://review.typo3.org/44143
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInputPlaceholders.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaInputPlaceholdersTest.php
typo3/sysext/core/Configuration/DefaultConfiguration.php

index 80a3687..0832b1f 100644 (file)
@@ -57,9 +57,15 @@ class TcaInputPlaceholders extends AbstractItemProvider implements FormDataProvi
                 $result['processedTca']['columns'][$fieldName]['config']['placeholder'] = $this->getPlaceholderValue($fieldNameArray, $result);
             }
 
+            // Resolve placeholders from language files
+            if (StringUtility::beginsWith($fieldConfig['config']['placeholder'], 'LLL:')) {
+                $result['processedTca']['columns'][$fieldName]['config']['placeholder'] = $this->getLanguageService()->sl($fieldConfig['config']['placeholder']);
+            }
+
             // Remove empty placeholders
             if (empty($fieldConfig['config']['placeholder'])) {
                 unset($result['processedTca']['columns'][$fieldName]['config']['placeholder']);
+                continue;
             }
         }
 
index b90a849..289c047 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Backend\Form\FormDataGroup\TcaInputPlaceholderRecord;
 use TYPO3\CMS\Backend\Form\FormDataProvider\TcaInputPlaceholders;
 use TYPO3\CMS\Core\Tests\UnitTestCase;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
 
 /**
  * Test case
@@ -403,4 +404,36 @@ class TcaInputPlaceholdersTest extends UnitTestCase
 
         $this->assertSame($expected, $this->subject->addData($input));
     }
+
+    /**
+     * @test
+     */
+    public function addDataCallsLanguageServiceForLocalizedPlaceholders()
+    {
+        $labelString = 'LLL:EXT:some_ext/Resources/Private/Language/locallang.xlf:my_placeholder';
+        $localizedString = 'My Placeholder';
+        $input = [
+            'tableName' => 'aTable',
+            'databaseRow' => [],
+            'processedTca' => [
+                'columns' => [
+                    'aField' => [
+                        'config' => [
+                            'type' => 'input',
+                            'placeholder' => $labelString,
+                        ]
+                    ]
+                ],
+            ],
+        ];
+        $expected = $input;
+        $expected['processedTca']['columns']['aField']['config']['placeholder'] = $localizedString;
+
+        /** @var LanguageService|ObjectProphecy $languageService */
+        $languageService = $this->prophesize(LanguageService::class);
+        $GLOBALS['LANG'] = $languageService->reveal();
+        $languageService->sL($labelString)->shouldBeCalled()->willReturn($localizedString);
+
+        $this->assertSame($expected, $this->subject->addData($input));
+    }
 }
index 1dc10d7..4e90802 100644 (file)
@@ -553,6 +553,11 @@ return array(
                             \TYPO3\CMS\Backend\Form\FormDataProvider\TcaInlineConfiguration::class,
                         ),
                     ),
+                    \TYPO3\CMS\Backend\Form\FormDataProvider\TcaInputPlaceholders::class => array(
+                        'depends' => array(
+                            \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDefaultValues::class,
+                        )
+                    )
                 ),
                 'tcaInputPlaceholderRecord' => array(
                     \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseEditRow::class => array(),