‪TYPO3CMS  9.5
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:core/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 }
‪TYPO3\CMS\Core\Utility\DiffUtility
Definition: DiffUtility.php:23
‪TYPO3\CMS\Backend\Form\FieldWizard\DefaultLanguageDifferences\getLanguageService
‪LanguageService getLanguageService()
Definition: DefaultLanguageDifferences.php:90
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪array initializeResultArray()
Definition: AbstractNode.php:88
‪TYPO3\CMS\Backend\Form\FieldWizard\DefaultLanguageDifferences
Definition: DefaultLanguageDifferences.php:31
‪TYPO3\CMS\Backend\Form\FieldWizard
Definition: DefaultLanguageDifferences.php:3
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪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:1933
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Form\FieldWizard\DefaultLanguageDifferences\render
‪array render()
Definition: DefaultLanguageDifferences.php:37