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