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