TYPO3 CMS  TYPO3_7-6
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  public function render()
34  {
35  $languageService = $this->getLanguageService();
36 
37  $table = $this->data['tableName'];
38  $row = $this->data['databaseRow'];
39  $fieldName = $this->data['fieldName']; // field name of the flex form field in DB
40  $parameterArray = $this->data['parameterArray'];
41  $flexFormDataStructureArray = $this->data['flexFormDataStructureArray'];
42  $flexFormRowData = $this->data['flexFormRowData'];
43 
44  $resultArray = $this->initializeResultArray();
45  $resultArray['requireJsModules'][] = 'TYPO3/CMS/Backend/Tabs';
46 
47  $domIdPrefix = 'DTM-' . GeneralUtility::shortMD5($this->data['parameterArray']['itemFormElName']);
48  $tabCounter = 0;
49  $tabElements = [];
50  foreach ($flexFormDataStructureArray['sheets'] as $sheetName => $sheetDataStructure) {
51  $flexFormRowSheetDataSubPart = $flexFormRowData['data'][$sheetName]['lDEF'] ?: [];
52 
53  if (!is_array($sheetDataStructure['ROOT']['el'])) {
54  $resultArray['html'] .= LF . 'No Data Structure ERROR: No [\'ROOT\'][\'el\'] found for sheet "' . $sheetName . '".';
55  continue;
56  }
57 
58  $tabCounter ++;
59 
60  // Assemble key for loading the correct CSH file
61  // @todo: what is that good for? That is for the title of single elements ... see FlexFormElementContainer!
62  $dsPointerFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['ds_pointerField'], true);
63  $parameterArray['_cshKey'] = $table . '.' . $fieldName;
64  foreach ($dsPointerFields as $key) {
65  if (is_string($row[$key]) && $row[$key] !== '') {
66  $parameterArray['_cshKey'] .= '.' . $row[$key];
67  } elseif (is_array($row[$key]) && isset($row[$key][0]) && is_string($row[$key][0]) && $row[$key][0] !== '') {
68  $parameterArray['_cshKey'] .= '.' . $row[$key][0];
69  }
70  }
71 
72  $options = $this->data;
73  $options['flexFormDataStructureArray'] = $sheetDataStructure['ROOT']['el'];
74  $options['flexFormRowData'] = $flexFormRowSheetDataSubPart;
75  $options['flexFormFormPrefix'] = '[data][' . $sheetName . '][lDEF]';
76  $options['parameterArray'] = $parameterArray;
77  // Merge elements of this tab into a single list again and hand over to
78  // palette and single field container to render this group
79  $options['tabAndInlineStack'][] = [
80  'tab',
81  $domIdPrefix . '-' . $tabCounter,
82  ];
83  $options['renderType'] = 'flexFormElementContainer';
84  $childReturn = $this->nodeFactory->create($options)->render();
85 
86  $tabElements[] = [
87  'label' => !empty(trim($sheetDataStructure['ROOT']['sheetTitle'])) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetTitle'])) : $sheetName,
88  'content' => $childReturn['html'],
89  'description' => trim($sheetDataStructure['ROOT']['sheetDescription']) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetDescription'])) : '',
90  'linkTitle' => trim($sheetDataStructure['ROOT']['sheetShortDescr']) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetShortDescr'])) : '',
91  ];
92 
93  $childReturn['html'] = '';
94  $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $childReturn);
95  }
96 
97  $resultArray['html'] = $this->renderTabMenu($tabElements, $domIdPrefix);
98  return $resultArray;
99  }
100 
104  protected function getLanguageService()
105  {
106  return $GLOBALS['LANG'];
107  }
108 }
renderTabMenu(array $menuItems, $domId, $defaultTabIndex=1)
mergeChildReturnIntoExistingResult(array $existing, array $childReturn)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']