‪TYPO3CMS  9.5
TabsContainer.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 {
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  if ($childArray['html'] !== '') {
89  $tabElements[] = [
90  'label' => $tabWithLabelAndElements['label'],
91  'content' => $childArray['html'],
92  ];
93  }
94  $resultArray = $this->‪mergeChildReturnIntoExistingResult($resultArray, $childArray, false);
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 }
‪TYPO3\CMS\Backend\Form\Container\TabsContainer
Definition: TabsContainer.php:27
‪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
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\TabsContainer\render
‪array render()
Definition: TabsContainer.php:34
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\explodeSingleFieldShowItemConfiguration
‪array explodeSingleFieldShowItemConfiguration($field)
Definition: AbstractContainer.php:89
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:40
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer
Definition: AbstractContainer.php:27
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Backend\Form\Container\TabsContainer\getLanguageService
‪LanguageService getLanguageService()
Definition: TabsContainer.php:104
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45