‪TYPO3CMS  ‪main
TabsContainer.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 {
35  public function ‪render(): array
36  {
37  $languageService = $this->‪getLanguageService();
38 
39  // All the fields to handle in a flat list
40  $fieldsArray = $this->data['fieldsArray'];
41 
42  // Create a nested array from flat fieldArray list
43  $tabsArray = [];
44  // First element will be a --div--, so it is safe to start -1 here to trigger 0 as first array index
45  $currentTabIndex = -1;
46  foreach ($fieldsArray as $fieldString) {
47  $fieldArray = $this->‪explodeSingleFieldShowItemConfiguration($fieldString);
48  if ($fieldArray['fieldName'] === '--div--') {
49  $currentTabIndex++;
50  if (empty($fieldArray['fieldLabel'])) {
51  throw new \RuntimeException(
52  'A --div-- has no label (--div--;fieldLabel) in showitem of ' . implode(',', $fieldsArray),
53  1426454001
54  );
55  }
56  $tabsArray[$currentTabIndex] = [
57  'label' => $languageService->sL($fieldArray['fieldLabel']),
58  'elements' => [],
59  ];
60  } else {
61  $tabsArray[$currentTabIndex]['elements'][] = $fieldArray;
62  }
63  }
64 
65  $resultArray = $this->‪initializeResultArray();
66  $resultArray['javaScriptModules'][] = ‪JavaScriptModuleInstruction::create('@typo3/backend/tabs.js');
67 
68  $domIdPrefix = 'DTM-' . md5($this->data['tableName'] . $this->data['databaseRow']['uid']);
69  $tabCounter = 0;
70  $tabElements = [];
71  foreach ($tabsArray as $tabWithLabelAndElements) {
72  $tabCounter++;
73  $elements = $tabWithLabelAndElements['elements'];
74 
75  // Merge elements of this tab into a single list again and hand over to
76  // palette and single field container to render this group
77  $options = ‪$this->data;
78  $options['tabAndInlineStack'][] = [
79  'tab',
80  $domIdPrefix . '-' . $tabCounter,
81  ];
82  $options['fieldsArray'] = [];
83  foreach ($elements as $element) {
84  $options['fieldsArray'][] = implode(';', $element);
85  }
86  $options['renderType'] = 'paletteAndSingleContainer';
87  $childArray = $this->nodeFactory->create($options)->render();
88 
89  if ($childArray['html'] !== '') {
90  $tabElements[] = [
91  'label' => $tabWithLabelAndElements['label'],
92  'content' => $childArray['html'],
93  ];
94  }
95  $resultArray = $this->‪mergeChildReturnIntoExistingResult($resultArray, $childArray, false);
96  }
97 
98  $resultArray['html'] = $this->‪renderTabMenu($tabElements, $domIdPrefix);
99  return $resultArray;
100  }
101 
103  {
104  return ‪$GLOBALS['LANG'];
105  }
106 }
‪TYPO3\CMS\Backend\Form\Container\TabsContainer
Definition: TabsContainer.php:28
‪TYPO3\CMS\Backend\Form\AbstractNode\mergeChildReturnIntoExistingResult
‪array mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)
Definition: AbstractNode.php:104
‪TYPO3\CMS\Core\Page\JavaScriptModuleInstruction\create
‪static create(string $name, string $exportName=null)
Definition: JavaScriptModuleInstruction.php:47
‪TYPO3\CMS\Backend\Form\Container
Definition: AbstractContainer.php:16
‪TYPO3\CMS\Core\Page\JavaScriptModuleInstruction
Definition: JavaScriptModuleInstruction.php:23
‪TYPO3\CMS\Backend\Form\Container\TabsContainer\render
‪array render()
Definition: TabsContainer.php:35
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\explodeSingleFieldShowItemConfiguration
‪explodeSingleFieldShowItemConfiguration(string $field)
Definition: AbstractContainer.php:107
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\renderTabMenu
‪renderTabMenu(array $menuItems, string $domId)
Definition: AbstractContainer.php:127
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:35
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer
Definition: AbstractContainer.php:29
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Backend\Form\Container\TabsContainer\getLanguageService
‪getLanguageService()
Definition: TabsContainer.php:102
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪initializeResultArray()
Definition: AbstractNode.php:77