‪TYPO3CMS  ‪main
DefaultLanguageDifferences.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
25 
33 {
34  public function ‪__construct(
35  private readonly ‪DiffUtility $diffUtility,
36  ) {}
37 
43  public function ‪render(): array
44  {
45  $result = $this->‪initializeResultArray();
46 
47  $row = $this->data['databaseRow'];
48  $table = $this->data['tableName'];
49  $fieldName = $this->data['fieldName'];
50  $fieldConfig = $this->data['processedTca']['columns'][$fieldName];
51  $l10nDisplay = $this->data['parameterArray']['fieldConf']['l10n_display'] ?? '';
52  $defaultLanguageRow = $this->data['defaultLanguageRow'] ?? null;
53  $defaultLanguageDiffRow = $this->data['defaultLanguageDiffRow'][$table . ':' . $row['uid']] ?? null;
54 
55  if (!is_array($defaultLanguageDiffRow)
56  || ‪GeneralUtility::inList($l10nDisplay, 'hideDiff')
57  || ‪GeneralUtility::inList($l10nDisplay, 'defaultAsReadonly')
58  || !isset($defaultLanguageDiffRow[$fieldName])
59  || $fieldConfig['config']['type'] === 'inline'
60  || $fieldConfig['config']['type'] === 'file'
61  || $fieldConfig['config']['type'] === 'flex'
62  ) {
63  // Early return if there is no diff row or if display is disabled
64  return $result;
65  }
66 
67  $languageService = $this->‪getLanguageService();
68  $html = [];
69  if ((string)$defaultLanguageDiffRow[$fieldName] !== (string)$defaultLanguageRow[$fieldName]) {
70  // Create diff-result:
71  $this->diffUtility->stripTags = false;
72  $diffResult = $this->diffUtility->makeDiffDisplay(
73  (string)BackendUtility::getProcessedValue($table, $fieldName, $defaultLanguageDiffRow[$fieldName], 0, true),
74  (string)BackendUtility::getProcessedValue($table, $fieldName, $defaultLanguageRow[$fieldName], 0, true)
75  );
76  $html[] = '<div class="t3-form-original-language-diff">';
77  $html[] = '<div class="t3-form-original-language-diffheader">';
78  $html[] = htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.changeInOrig'));
79  $html[] = '</div>';
80  $html[] = '<div class="t3-form-original-language-diffcontent">';
81  $html[] = '<div class="diff">';
82  $html[] = '<div class="diff-item">';
83  $html[] = '<div class="diff-item-result diff-item-result-inline">' . $diffResult . '</div>';
84  $html[] = '</div>';
85  $html[] = '</div>';
86  $html[] = '</div>';
87  $html[] = '</div>';
88  }
89  $result['html'] = implode(LF, $html);
90  return $result;
91  }
92 
94  {
95  return ‪$GLOBALS['LANG'];
96  }
97 }
‪TYPO3\CMS\Core\Utility\DiffUtility
Definition: DiffUtility.php:28
‪TYPO3\CMS\Backend\Form\FieldWizard\DefaultLanguageDifferences
Definition: DefaultLanguageDifferences.php:33
‪TYPO3\CMS\Backend\Form\FieldWizard\DefaultLanguageDifferences\getLanguageService
‪getLanguageService()
Definition: DefaultLanguageDifferences.php:93
‪TYPO3\CMS\Backend\Form\FieldWizard\DefaultLanguageDifferences\__construct
‪__construct(private readonly DiffUtility $diffUtility,)
Definition: DefaultLanguageDifferences.php:34
‪TYPO3\CMS\Backend\Form\FieldWizard
Definition: DefaultLanguageDifferences.php:18
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility\inList
‪static bool inList($list, $item)
Definition: GeneralUtility.php:422
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\Form\FieldWizard\DefaultLanguageDifferences\render
‪array render()
Definition: DefaultLanguageDifferences.php:43
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪initializeResultArray()
Definition: AbstractNode.php:77