TYPO3 CMS  TYPO3_7-6
TcaColumnsProcessShowitem.php
Go to the documentation of this file.
1 <?php
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 
19 
24 {
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 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)