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