[BUGFIX] Highlight changes of translation diff in FormEngine again 53/47253/8
authorFrank Naegler <frank.naegler@typo3.org>
Mon, 14 Mar 2016 15:33:10 +0000 (16:33 +0100)
committerJan Helke <typo3@helke.de>
Fri, 18 Mar 2016 10:55:53 +0000 (11:55 +0100)
The difference between translation changes of records are now
highlighted again in FormEngine.

Resolves: #73501
Releases: master, 7.6
Change-Id: I88f4a67c5392cf9ddca4410ddb07d57439a26b3a
Reviewed-on: https://review.typo3.org/47253
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Build/Resources/Public/Less/Component/diff.less
typo3/sysext/backend/Classes/Form/Container/SingleFieldContainer.php
typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseLanguageRows.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseLanguageRowsTest.php
typo3/sysext/install/Resources/Public/Css/InstallTool.css
typo3/sysext/t3skin/Resources/Public/Css/backend.css

index 3cb4b8b..4384be7 100644 (file)
@@ -61,7 +61,7 @@
        width: 100%;
        white-space: pre;
        word-break: break-all;
-    word-wrap: break-word;
+       word-wrap: break-word;
        del {
                color: @diff-color-remove;
                background-color: lighten(@diff-color-remove, 58%);
@@ -72,4 +72,8 @@
                background-color: lighten(@diff-color-add, 58%);
                text-decoration: none;
        }
+
+       &.diff-item-result-inline {
+               white-space: normal;
+       }
 }
index 2a18bc1..ad315dc 100644 (file)
@@ -389,27 +389,36 @@ class SingleFieldContainer extends AbstractContainer
      */
     protected function renderDefaultLanguageDiff($table, $field, $row, $item)
     {
-        if (is_array($this->data['defaultLanguageDataDiff'][$table . ':' . $row['uid']])) {
+        if (is_array($this->data['defaultLanguageDiffRow'][$table . ':' . $row['uid']])) {
             // Initialize:
             $dLVal = array(
-                'old' => $this->data['defaultLanguageDataDiff'][$table . ':' . $row['uid']],
-                'new' => $this->data['defaultLanguageData'][$table . ':' . $row['uid']]
+                'old' => $this->data['defaultLanguageDiffRow'][$table . ':' . $row['uid']],
+                'new' => $this->data['defaultLanguageRow']
             );
             // There must be diff-data:
             if (isset($dLVal['old'][$field])) {
                 if ((string)$dLVal['old'][$field] !== (string)$dLVal['new'][$field]) {
                     // Create diff-result:
+                    /** @var DiffUtility $diffUtility */
                     $diffUtility = GeneralUtility::makeInstance(DiffUtility::class);
                     $diffres = $diffUtility->makeDiffDisplay(
                         BackendUtility::getProcessedValue($table, $field, $dLVal['old'][$field], 0, 1),
                         BackendUtility::getProcessedValue($table, $field, $dLVal['new'][$field], 0, 1)
                     );
-                    $item .= '<div class="t3-form-original-language-diff">
-                                               <div class="t3-form-original-language-diffheader">' .
-                            htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.changeInOrig')) .
-                        '</div>
-                                               <div class="t3-form-original-language-diffcontent">' . $diffres . '</div>
-                                       </div>';
+                    $item .= '
+                                               <div class="t3-form-original-language-diff">
+                                                       <div class="t3-form-original-language-diffheader">'
+                                . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.changeInOrig'))
+                                                       . '</div>
+                                                       <div class="t3-form-original-language-diffcontent">
+                                                               <div class="diff">
+                                                                       <div class="diff-item">
+                                                                               <div class="diff-item-result diff-item-result-inline">' . $diffres . '</div>
+                                                                       </div>
+                                                               </div>
+                                                       </div>
+                                               </div>
+                                       ';
                 }
             }
         }
index 571374c..be76457 100644 (file)
@@ -69,7 +69,8 @@ class DatabaseLanguageRows implements FormDataProviderInterface
                 if (!empty($result['processedTca']['ctrl']['transOrigDiffSourceField'])
                     && !empty($result['databaseRow'][$result['processedTca']['ctrl']['transOrigDiffSourceField']])
                 ) {
-                    $result['defaultLanguageDiffRow'] = unserialize($result['databaseRow'][$result['processedTca']['ctrl']['transOrigDiffSourceField']]);
+                    $defaultLanguageKey = $result['tableName'] . ':' . (int)$result['databaseRow']['uid'];
+                    $result['defaultLanguageDiffRow'][$defaultLanguageKey] = unserialize($result['databaseRow'][$result['processedTca']['ctrl']['transOrigDiffSourceField']]);
                 }
 
                 // Add language overlays from further localizations if requested
index a46b4fa..ee0a22e 100644 (file)
@@ -181,7 +181,7 @@ class DatabaseLanguageRowsTest extends UnitTestCase
 
         $expected = $input;
         $expected['defaultLanguageRow'] = $defaultLanguageRow;
-        $expected['defaultLanguageDiffRow'] = $diffSource;
+        $expected['defaultLanguageDiffRow']['tt_content:42'] = $diffSource;
 
         $this->assertEquals($expected, $this->subject->addData($input));
     }
index ee7dff3..5318835 100644 (file)
@@ -7275,6 +7275,9 @@ button.close {
   background-color: #ebfce3;
   text-decoration: none;
 }
+.diff-item-result.diff-item-result-inline {
+  white-space: normal;
+}
 .module {
   height: 100%;
   width: 100%;
index 6970682..44226b8 100644 (file)
@@ -7284,6 +7284,9 @@ button.close {
   background-color: #ebfce3;
   text-decoration: none;
 }
+.diff-item-result.diff-item-result-inline {
+  white-space: normal;
+}
 .module {
   height: 100%;
   width: 100%;