3dfa8ccee29fdcb74cf6987323bfa0f5d70ddec6
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / FormDataProvider / TcaColumnsProcessCommon.php
1 <?php
2 namespace TYPO3\CMS\Backend\Form\FormDataProvider;
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\FormDataProviderInterface;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * Mark columns that are common to many tables for further processing
22 */
23 class TcaColumnsProcessCommon implements FormDataProviderInterface
24 {
25
26 /**
27 * Determine which common fields are in use and add those to the list of
28 * columns that must be processed by the next data providers. Common fields
29 * are for example uid, transOrigPointerField or transOrigDiffSourceField.
30 *
31 * @param array $result
32 *
33 * @return array
34 */
35 public function addData(array $result)
36 {
37 // enables the backend to display a visual comparison between a new version and its original
38 $tableProperties = $result['processedTca']['ctrl'];
39 if (!empty($tableProperties['origUid'])) {
40 $result['columnsToProcess'][] = $tableProperties['origUid'];
41 }
42
43 // determines which one of the 'types' configurations are used for displaying the fields in the backend
44 if (!empty($tableProperties['type'])) {
45 // Allow for relation_field:foreign_type_field syntax
46 $fieldName = GeneralUtility::trimExplode(':', $tableProperties['type'], true, 2);
47 $result['columnsToProcess'][] = $fieldName[0];
48 }
49
50 // field that contains the language of the record
51 if (!empty($tableProperties['languageField'])) {
52 $result['columnsToProcess'][] = $tableProperties['languageField'];
53 }
54
55 // field that contains the pointer to the original record
56 if (!empty($tableProperties['transOrigPointerField'])) {
57 $result['columnsToProcess'][] = $tableProperties['transOrigPointerField'];
58 }
59
60 // field that contains the value of the original language record
61 if (!empty($tableProperties['transOrigDiffSourceField'])) {
62 $result['columnsToProcess'][] = $tableProperties['transOrigDiffSourceField'];
63 }
64
65 // fields added to subtypes_addlist (can be pi_flexform)
66 if (!empty($result['processedTca']['types']['list']['subtypes_addlist'][$result['databaseRow']['list_type']])) {
67 $fields = GeneralUtility::trimExplode(
68 ',',
69 $result['processedTca']['types']['list']['subtypes_addlist'][$result['databaseRow']['list_type']],
70 true
71 );
72 foreach ($fields as $field) {
73 $result['columnsToProcess'][] = $field;
74 }
75 }
76
77 return $result;
78 }
79 }