TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
TabsContainer.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Form\Container;
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 {
34  public function render()
35  {
36  $languageService = $this->getLanguageService();
37 
38  // All the fields to handle in a flat list
39  $fieldsArray = $this->data['fieldsArray'];
40 
41  // Create a nested array from flat fieldArray list
42  $tabsArray = [];
43  // First element will be a --div--, so it is safe to start -1 here to trigger 0 as first array index
44  $currentTabIndex = -1;
45  foreach ($fieldsArray as $fieldString) {
46  $fieldArray = $this->explodeSingleFieldShowItemConfiguration($fieldString);
47  if ($fieldArray['fieldName'] === '--div--') {
48  $currentTabIndex++;
49  if (empty($fieldArray['fieldLabel'])) {
50  throw new \RuntimeException(
51  'A --div-- has no label (--div--;fieldLabel) in showitem of ' . implode(',', $fieldsArray),
52  1426454001
53  );
54  }
55  $tabsArray[$currentTabIndex] = [
56  'label' => $languageService->sL($fieldArray['fieldLabel']),
57  'elements' => [],
58  ];
59  } else {
60  $tabsArray[$currentTabIndex]['elements'][] = $fieldArray;
61  }
62  }
63 
64  $resultArray = $this->initializeResultArray();
65  $resultArray['requireJsModules'][] = 'TYPO3/CMS/Backend/Tabs';
66 
67  $domIdPrefix = 'DTM-' . GeneralUtility::shortMD5($this->data['tableName'] . $this->data['databaseRow']['uid']);
68  $tabCounter = 0;
69  $tabElements = [];
70  foreach ($tabsArray as $tabWithLabelAndElements) {
71  $tabCounter ++;
72  $elements = $tabWithLabelAndElements['elements'];
73 
74  // Merge elements of this tab into a single list again and hand over to
75  // palette and single field container to render this group
76  $options = $this->data;
77  $options['tabAndInlineStack'][] = [
78  'tab',
79  $domIdPrefix . '-' . $tabCounter,
80  ];
81  $options['fieldsArray'] = [];
82  foreach ($elements as $element) {
83  $options['fieldsArray'][] = implode(';', $element);
84  }
85  $options['renderType'] = 'paletteAndSingleContainer';
86  $childArray = $this->nodeFactory->create($options)->render();
87 
88  $tabElements[] = [
89  'label' => $tabWithLabelAndElements['label'],
90  'content' => $childArray['html'],
91  ];
92  $childArray['html'] = '';
93  $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $childArray);
94  }
95 
96  $resultArray['html'] = $this->renderTabMenu($tabElements, $domIdPrefix);
97  return $resultArray;
98  }
99 
103  protected function getLanguageService()
104  {
105  return $GLOBALS['LANG'];
106  }
107 }
renderTabMenu(array $menuItems, $domId, $defaultTabIndex=1)
mergeChildReturnIntoExistingResult(array $existing, array $childReturn)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']