[CLEANUP] Fix case mismatch of classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / Form / Resolver / RichTextNodeResolver.php
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea\Form\Resolver;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Form\NodeFactory;
18 use TYPO3\CMS\Backend\Form\NodeResolverInterface;
19 use TYPO3\CMS\Backend\Utility\BackendUtility;
20 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
21 use TYPO3\CMS\Rtehtmlarea\Form\Element\RichTextElement;
22
23 /**
24 * This resolver will return the RichTextElement render class of ext:rtehtmlarea if RTE is enabled for this field.
25 */
26 class RichTextNodeResolver implements NodeResolverInterface
27 {
28 /**
29 * Global options from NodeFactory
30 *
31 * @var array
32 */
33 protected $data;
34
35 /**
36 * Default constructor receives full data array
37 *
38 * @param NodeFactory $nodeFactory
39 * @param array $data
40 */
41 public function __construct(NodeFactory $nodeFactory, array $data)
42 {
43 $this->data = $data;
44 }
45
46 /**
47 * Returns RichTextElement as class name if RTE widget should be rendered.
48 *
49 * @return string|void New class name or void if this resolver does not change current class name.
50 */
51 public function resolve()
52 {
53 $table = $this->data['tableName'];
54 $fieldName = $this->data['fieldName'];
55 $row = $this->data['databaseRow'];
56 $parameterArray = $this->data['parameterArray'];
57 $backendUser = $this->getBackendUserAuthentication();
58
59 if (// This field is not read only
60 !$parameterArray['fieldConf']['config']['readOnly']
61 // If RTE is generally enabled by user settings and RTE object registry can return something valid
62 && $backendUser->isRTE()
63 ) {
64 // @todo: Most of this stuff is prepared by data providers within $this->data already
65 $specialConfiguration = BackendUtility::getSpecConfParts($parameterArray['fieldConf']['defaultExtras']);
66 // If "richtext" is within defaultExtras
67 if (isset($specialConfiguration['richtext'])) {
68 // Operates by reference on $row! 'pid' is changed ...
69 BackendUtility::fixVersioningPid($table, $row);
70 list($recordPid, $tsConfigPid) = BackendUtility::getTSCpidCached($table, $row['uid'], $row['pid']);
71 // If the pid-value is not negative (that is, a pid could NOT be fetched)
72 if ($tsConfigPid >= 0) {
73 // Fetch page ts config and do some magic with it to find out if RTE is disabled on TS level.
74 $rteSetup = $backendUser->getTSConfig('RTE', BackendUtility::getPagesTSconfig($recordPid));
75 $rteTcaTypeValue = $this->data['recordTypeValue'];
76 $rteSetupConfiguration = BackendUtility::RTEsetup($rteSetup['properties'], $table, $fieldName, $rteTcaTypeValue);
77 if (!$rteSetupConfiguration['disabled']) {
78 // Finally, we're sure the editor should really be rendered ...
79 return RichTextElement::class;
80 }
81 }
82 }
83 }
84 return null;
85 }
86
87 /**
88 * @return BackendUserAuthentication
89 */
90 protected function getBackendUserAuthentication()
91 {
92 return $GLOBALS['BE_USER'];
93 }
94 }