‪TYPO3CMS  ‪main
FullRecordContainer.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 
30 {
36  public function ‪render(): array
37  {
38  $recordTypeValue = $this->data['recordTypeValue'];
39 
40  // List of items to be rendered
41  $itemList = $this->data['processedTca']['types'][$recordTypeValue]['showitem'];
42 
43  $fieldsArray = ‪GeneralUtility::trimExplode(',', $itemList, true);
44 
45  // Streamline the fields array
46  // First, make sure there is always a --div-- definition for the first element
47  if (!str_starts_with($fieldsArray[0], '--div--')) {
48  array_unshift($fieldsArray, '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general');
49  }
50  // If first tab has no label definition, add "general" label
51  $firstTabHasLabel = count(‪GeneralUtility::trimExplode(';', $fieldsArray[0])) > 1;
52  if (!$firstTabHasLabel) {
53  $fieldsArray[0] = '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general';
54  }
55  // If there are at least two --div-- definitions, inner container will be a TabContainer, else a NoTabContainer
56  $tabCount = 0;
57  foreach ($fieldsArray as $field) {
58  if (str_starts_with($field, '--div--')) {
59  $tabCount++;
60  }
61  }
62  $hasTabs = true;
63  if ($tabCount < 2) {
64  // Remove first tab definition again if there is only one tab defined
65  array_shift($fieldsArray);
66  $hasTabs = false;
67  }
68 
70  ‪$data['fieldsArray'] = $fieldsArray;
71  if ($hasTabs) {
72  ‪$data['renderType'] = 'tabsContainer';
73  } else {
74  ‪$data['renderType'] = 'noTabsContainer';
75  }
76 
77  return $this->nodeFactory->create(‪$data)->render();
78  }
79 
81  {
82  return ‪$GLOBALS['LANG'];
83  }
84 }
‪TYPO3\CMS\Backend\Form\Container
Definition: AbstractContainer.php:16
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:35
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer
Definition: AbstractContainer.php:29
‪TYPO3\CMS\Backend\Form\Container\FullRecordContainer\render
‪array render()
Definition: FullRecordContainer.php:36
‪TYPO3\CMS\Backend\Form\Container\FullRecordContainer\getLanguageService
‪getLanguageService()
Definition: FullRecordContainer.php:80
‪TYPO3\CMS\Backend\Form\Container\FullRecordContainer
Definition: FullRecordContainer.php:30
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode(string $delim, string $string, bool $removeEmptyValues=false, int $limit=0)
Definition: GeneralUtility.php:822