‪TYPO3CMS  10.4
TcaText.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 
31 {
38  public function ‪addData(array $result)
39  {
40  foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
41  if (empty($fieldConfig['config']['type']) || $fieldConfig['config']['type'] !== 'text') {
42  continue;
43  }
44 
45  // Check if richtext is enabled for the field and the user did not disable RTE in general
46  if (($fieldConfig['config']['enableRichtext'] ?? false) && $this->‪getBackendUser()->isRTE()) {
47  $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
48  $richtextConfiguration = $richtextConfigurationProvider->getConfiguration(
49  $result['tableName'],
50  $fieldName,
51  $result['effectivePid'],
52  (string)$result['recordTypeValue'],
53  $fieldConfig['config']
54  );
55  // Transform if richtext is not disabled in configuration
56  if (!($richtextConfiguration['disabled'] ?? false)) {
57  // remember RTE preset name
58  $result['processedTca']['columns'][$fieldName]['config']['richtextConfigurationName'] = $fieldConfig['config']['richtextConfiguration'] ?? '';
59  // Add final resolved configuration to TCA array
60  $result['processedTca']['columns'][$fieldName]['config']['richtextConfiguration'] = $richtextConfiguration;
61  // If eval=null is set for field, value might be null ... don't transform anything in this case.
62  if ($result['databaseRow'][$fieldName] !== null) {
63  // Process "from-db-to-rte" on current value
64  $richTextParser = GeneralUtility::makeInstance(RteHtmlParser::class);
65  $result['databaseRow'][$fieldName] = $richTextParser->transformTextForRichTextEditor($result['databaseRow'][$fieldName], $richtextConfiguration['proc.'] ?? []);
66  }
67  }
68  }
69  }
70 
71  return $result;
72  }
73 
75  {
76  return ‪$GLOBALS['BE_USER'];
77  }
78 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaText\getBackendUser
‪getBackendUser()
Definition: TcaText.php:74
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaText\addData
‪array addData(array $result)
Definition: TcaText.php:38
‪TYPO3\CMS\Core\Html\RteHtmlParser
Definition: RteHtmlParser.php:38
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaText
Definition: TcaText.php:31
‪TYPO3\CMS\Core\Configuration\Richtext
Definition: Richtext.php:33