‪TYPO3CMS  10.4
OtherLanguageContent.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 
32 {
38  public function ‪render(): array
39  {
40  $result = $this->‪initializeResultArray();
41 
42  $fieldName = $this->data['fieldName'];
43  $fieldConfig = $this->data['processedTca']['columns'][$fieldName];
44  $l10nDisplay = $this->data['parameterArray']['fieldConf']['l10n_display'] ?? '';
45  $defaultLanguageRow = $this->data['defaultLanguageRow'] ?? null;
46  if (!is_array($defaultLanguageRow)
47  || GeneralUtility::inList($l10nDisplay, 'hideDiff')
48  || GeneralUtility::inList($l10nDisplay, 'defaultAsReadonly')
49  || $fieldConfig['config']['type'] === 'inline'
50  || $fieldConfig['config']['type'] === 'flex'
51  || ($fieldConfig['config']['type'] === 'group' && isset($fieldConfig['config']['MM']))
52  || ($fieldConfig['config']['type'] === 'select' && isset($fieldConfig['config']['MM']))
53  ) {
54  // Early return if there is no default language row or the display is disabled
55  return $result;
56  }
57 
58  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
59  $table = $this->data['tableName'];
60  $html = [];
61  $defaultLanguageValue = ‪BackendUtility::getProcessedValue(
62  $table,
63  $fieldName,
64  $defaultLanguageRow[$fieldName],
65  0,
66  true,
67  false,
68  $defaultLanguageRow['uid'],
69  true,
70  $defaultLanguageRow['pid']
71  ) ?? '';
72  if ($defaultLanguageValue !== '') {
73  $iconIdentifier = ($this->data['systemLanguageRows'][0]['flagIconIdentifier'] ?? false) ?: 'flags-multiple';
74  $html[] = '<div class="t3-form-original-language">';
75  $html[] = $iconFactory->getIcon($iconIdentifier, ‪Icon::SIZE_SMALL)->render();
76  $html[] = $this->‪previewFieldValue($defaultLanguageValue);
77  $html[] = '</div>';
78  }
79  $additionalPreviewLanguages = $this->data['additionalLanguageRows'];
80  foreach ($additionalPreviewLanguages as $previewLanguage) {
81  $defaultLanguageValue = ‪BackendUtility::getProcessedValue(
82  $table,
83  $fieldName,
84  $previewLanguage[$fieldName],
85  0,
86  true
87  ) ?? '';
88  if ($defaultLanguageValue !== '') {
89  $html[] = '<div class="t3-form-original-language">';
90  $html[] = $iconFactory->getIcon($this->data['systemLanguageRows'][$previewLanguage['sys_language_uid']]['flagIconIdentifier'], ‪Icon::SIZE_SMALL)->render();
91  $html[] = $this->‪previewFieldValue($defaultLanguageValue);
92  $html[] = '</div>';
93  }
94  }
95  $result['html'] = implode(LF, $html);
96  return $result;
97  }
98 
105  protected function ‪previewFieldValue($value)
106  {
107  return nl2br(htmlspecialchars((string)$value));
108  }
109 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪array initializeResultArray()
Definition: AbstractNode.php:90
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Backend\Form\FieldWizard\OtherLanguageContent
Definition: OtherLanguageContent.php:32
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Backend\Form\FieldWizard\OtherLanguageContent\previewFieldValue
‪string previewFieldValue($value)
Definition: OtherLanguageContent.php:105
‪TYPO3\CMS\Backend\Form\FieldWizard
Definition: DefaultLanguageDifferences.php:18
‪TYPO3\CMS\Backend\Form\FieldWizard\OtherLanguageContent\render
‪array render()
Definition: OtherLanguageContent.php:38
‪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
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46