TYPO3 CMS  TYPO3_8-7
DefaultLanguageDifferences.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
23 
31 {
37  public function render(): array
38  {
39  $result = $this->initializeResultArray();
40 
41  $row = $this->data['databaseRow'];
42  $table = $this->data['tableName'];
43  $fieldName = $this->data['fieldName'];
44  $fieldConfig = $this->data['processedTca']['columns'][$fieldName];
45  $l10nDisplay = $this->data['parameterArray']['fieldConf']['l10n_display'] ?? '';
46  $defaultLanguageRow = $this->data['defaultLanguageRow'] ?? null;
47  $defaultLanguageDiffRow = $this->data['defaultLanguageDiffRow'][$table . ':' . $row['uid']] ?? null;
48 
49  if (!is_array($defaultLanguageDiffRow)
50  || GeneralUtility::inList($l10nDisplay, 'hideDiff')
51  || GeneralUtility::inList($l10nDisplay, 'defaultAsReadonly')
52  || !isset($defaultLanguageDiffRow[$fieldName])
53  || $fieldConfig['config']['type'] === 'inline'
54  || $fieldConfig['config']['type'] === 'flex'
55  ) {
56  // Early return if there is no diff row or if display is disabled
57  return $result;
58  }
59 
60  $languageService = $this->getLanguageService();
61  $html = [];
62  if ((string)$defaultLanguageDiffRow[$fieldName] !== (string)$defaultLanguageRow[$fieldName]) {
63  // Create diff-result:
64  $diffUtility = GeneralUtility::makeInstance(DiffUtility::class);
65  $diffUtility->stripTags = false;
66  $diffResult = $diffUtility->makeDiffDisplay(
67  BackendUtility::getProcessedValue($table, $fieldName, $defaultLanguageDiffRow[$fieldName], 0, 1),
68  BackendUtility::getProcessedValue($table, $fieldName, $defaultLanguageRow[$fieldName], 0, 1)
69  );
70  $html[] = '<div class="t3-form-original-language-diff">';
71  $html[] = '<div class="t3-form-original-language-diffheader">';
72  $html[] = htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.changeInOrig'));
73  $html[] = '</div>';
74  $html[] = '<div class="t3-form-original-language-diffcontent">';
75  $html[] = '<div class="diff">';
76  $html[] = '<div class="diff-item">';
77  $html[] = '<div class="diff-item-result diff-item-result-inline">' . $diffResult . '</div>';
78  $html[] = '</div>';
79  $html[] = '</div>';
80  $html[] = '</div>';
81  $html[] = '</div>';
82  }
83  $result['html'] = implode(LF, $html);
84  return $result;
85  }
86 
90  protected function getLanguageService()
91  {
92  return $GLOBALS['LANG'];
93  }
94 }
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']