‪TYPO3CMS  10.4
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()
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['requireJsModules'][] = 'TYPO3/CMS/Backend/Tabs';
67 
68  $domIdPrefix = 'DTM-' . GeneralUtility::shortMD5($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 
105  protected function ‪getLanguageService()
106  {
107  return ‪$GLOBALS['LANG'];
108  }
109 }
‪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:116
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪array initializeResultArray()
Definition: AbstractNode.php:90
‪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\TabsContainer\render
‪array render()
Definition: TabsContainer.php:35
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\explodeSingleFieldShowItemConfiguration
‪array explodeSingleFieldShowItemConfiguration($field)
Definition: AbstractContainer.php:90
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:42
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer
Definition: AbstractContainer.php:28
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Backend\Form\Container\TabsContainer\getLanguageService
‪LanguageService getLanguageService()
Definition: TabsContainer.php:105
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46