‪TYPO3CMS  9.5
FlexFormTabsContainer.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 
27 {
33  protected ‪$defaultFieldInformation = [
34  'tcaDescription' => [
35  'renderType' => 'tcaDescription',
36  ],
37  ];
38 
44  public function ‪render()
45  {
46  $languageService = $this->‪getLanguageService();
47 
48  $table = $this->data['tableName'];
49  $row = $this->data['databaseRow'];
50  $fieldName = $this->data['fieldName']; // field name of the flex form field in DB
51  $parameterArray = $this->data['parameterArray'];
52  $flexFormDataStructureArray = $this->data['flexFormDataStructureArray'];
53  $flexFormRowData = $this->data['flexFormRowData'];
54 
55  $resultArray = $this->‪initializeResultArray();
56 
57  $resultArray['requireJsModules'][] = 'TYPO3/CMS/Backend/Tabs';
58 
59  $domIdPrefix = 'DTM-' . GeneralUtility::shortMD5($this->data['parameterArray']['itemFormElName']);
60  $tabCounter = 0;
61  $tabElements = [];
62  foreach ($flexFormDataStructureArray['sheets'] as $sheetName => $sheetDataStructure) {
63  $flexFormRowSheetDataSubPart = $flexFormRowData['data'][$sheetName]['lDEF'] ?: [];
64 
65  if (!is_array($sheetDataStructure['ROOT']['el'])) {
66  $resultArray['html'] .= LF . 'No Data Structure ERROR: No [\'ROOT\'][\'el\'] found for sheet "' . $sheetName . '".';
67  continue;
68  }
69 
70  $tabCounter++;
71 
72  // Assemble key for loading the correct CSH file
73  // @todo: what is that good for? That is for the title of single elements ... see FlexFormElementContainer!
74  $dsPointerFields = GeneralUtility::trimExplode(',', ‪$GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['ds_pointerField'], true);
75  $parameterArray['_cshKey'] = $table . '.' . $fieldName;
76  foreach ($dsPointerFields as $key) {
77  if (is_string($row[$key]) && $row[$key] !== '') {
78  $parameterArray['_cshKey'] .= '.' . $row[$key];
79  } elseif (is_array($row[$key]) && isset($row[$key][0]) && is_string($row[$key][0]) && $row[$key][0] !== '') {
80  $parameterArray['_cshKey'] .= '.' . $row[$key][0];
81  }
82  }
83 
84  $options = ‪$this->data;
85  $options['flexFormDataStructureArray'] = $sheetDataStructure['ROOT']['el'];
86  $options['flexFormRowData'] = $flexFormRowSheetDataSubPart;
87  $options['flexFormSheetName'] = $sheetName;
88  $options['flexFormFormPrefix'] = '[data][' . $sheetName . '][lDEF]';
89  $options['parameterArray'] = $parameterArray;
90  // Merge elements of this tab into a single list again and hand over to
91  // palette and single field container to render this group
92  $options['tabAndInlineStack'][] = [
93  'tab',
94  $domIdPrefix . '-' . $tabCounter,
95  ];
96  $options['renderType'] = 'flexFormElementContainer';
97  $childReturn = $this->nodeFactory->create($options)->render();
98 
99  if ($childReturn['html'] !== '') {
100  $tabElements[] = [
101  'label' => !empty(trim($sheetDataStructure['ROOT']['sheetTitle'])) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetTitle'])) : $sheetName,
102  'content' => $childReturn['html'],
103  'description' => trim($sheetDataStructure['ROOT']['sheetDescription']) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetDescription'])) : '',
104  'linkTitle' => trim($sheetDataStructure['ROOT']['sheetShortDescr']) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetShortDescr'])) : '',
105  ];
106  }
107  $resultArray = $this->‪mergeChildReturnIntoExistingResult($resultArray, $childReturn, false);
108  }
109 
110  $fieldInformationResult = $this->‪renderFieldInformation();
111  $resultArray['html'] = '<div>' . $fieldInformationResult['html'] . '</div>';
112  $resultArray = $this->‪mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false);
113 
114  $resultArray['html'] .= $this->‪renderTabMenu($tabElements, $domIdPrefix);
115  return $resultArray;
116  }
117 
121  protected function ‪getLanguageService()
122  {
123  return ‪$GLOBALS['LANG'];
124  }
125 }
‪TYPO3\CMS\Backend\Form\Container\FlexFormTabsContainer\$defaultFieldInformation
‪array $defaultFieldInformation
Definition: FlexFormTabsContainer.php:32
‪TYPO3\CMS\Backend\Form\AbstractNode\mergeChildReturnIntoExistingResult
‪array mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)
Definition: AbstractNode.php:115
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪array initializeResultArray()
Definition: AbstractNode.php:88
‪TYPO3\CMS\Backend\Form\Container\FlexFormTabsContainer\getLanguageService
‪LanguageService getLanguageService()
Definition: FlexFormTabsContainer.php:120
‪TYPO3\CMS\Backend\Form\Container
Definition: AbstractContainer.php:2
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\renderTabMenu
‪string renderTabMenu(array $menuItems, $domId, $defaultTabIndex=1)
Definition: AbstractContainer.php:111
‪TYPO3\CMS\Backend\Form\Container\FlexFormTabsContainer\render
‪array render()
Definition: FlexFormTabsContainer.php:43
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:40
‪TYPO3\CMS\Backend\Form\Container\FlexFormTabsContainer
Definition: FlexFormTabsContainer.php:27
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer
Definition: AbstractContainer.php:27
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\renderFieldInformation
‪array renderFieldInformation()
Definition: AbstractContainer.php:33
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45