‪TYPO3CMS  ‪main
TcaColumnsProcessShowitem.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 
25 {
32  public function ‪addData(array $result)
33  {
34  $recordTypeValue = $result['recordTypeValue'];
35 
36  if (!isset($result['processedTca']['types'][$recordTypeValue]['showitem'])
37  || !is_string($result['processedTca']['types'][$recordTypeValue]['showitem'])
38  ) {
39  throw new \UnexpectedValueException(
40  'No or invalid showitem definition in TCA table ' . $result['tableName'] . ' for type ' . $recordTypeValue,
41  1438614542
42  );
43  }
44 
45  if (empty($result['processedTca']['columns'])) {
46  // We are sure this is an array by InitializeProcessedTca data provider
47  return $result;
48  }
49 
50  if ($result['isInlineChild'] && !$result['isInlineChildExpanded']) {
51  // If the record is an inline child that is not expanded, it is not necessary to calculate all fields
52  return $result;
53  }
54 
55  $showItemFieldString = $result['processedTca']['types'][$recordTypeValue]['showitem'];
56  $showItemFieldArray = ‪GeneralUtility::trimExplode(',', $showItemFieldString, true);
57 
58  foreach ($showItemFieldArray as $fieldConfigurationString) {
59  $fieldConfigurationArray = ‪GeneralUtility::trimExplode(';', $fieldConfigurationString);
60  $fieldName = $fieldConfigurationArray[0];
61  if ($fieldName === '--div--') {
62  continue;
63  }
64  if ($fieldName === '--palette--') {
65  if (isset($fieldConfigurationArray[2])) {
66  $paletteName = $fieldConfigurationArray[2];
67  if (!empty($result['processedTca']['palettes'][$paletteName]['showitem'])) {
68  $paletteFields = ‪GeneralUtility::trimExplode(',', $result['processedTca']['palettes'][$paletteName]['showitem'], true);
69  foreach ($paletteFields as $paletteFieldConfiguration) {
70  $paletteFieldConfigurationArray = ‪GeneralUtility::trimExplode(';', $paletteFieldConfiguration);
71  $result['columnsToProcess'][] = $paletteFieldConfigurationArray[0];
72  }
73  }
74  }
75  } else {
76  $result['columnsToProcess'][] = $fieldName;
77  }
78  }
79 
80  return $result;
81  }
82 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessShowitem\addData
‪array addData(array $result)
Definition: TcaColumnsProcessShowitem.php:32
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessShowitem
Definition: TcaColumnsProcessShowitem.php:25
‪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\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode(string $delim, string $string, bool $removeEmptyValues=false, int $limit=0)
Definition: GeneralUtility.php:822