‪TYPO3CMS  ‪main
AbstractContainer.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 
24 
28 abstract class ‪AbstractContainer extends ‪AbstractNode
29 {
32 
38  {
39  $this->nodeFactory = ‪$nodeFactory;
40  }
41 
43  {
44  $this->backendViewFactory = ‪$backendViewFactory;
45  }
46 
52  protected function ‪renderFieldInformation(): array
53  {
54  $options = ‪$this->data;
55  $fieldInformation = ‪$this->defaultFieldInformation;
56  $currentRenderType = $this->data['renderType'];
57  $fieldInformationFromTca = $options['processedTca']['ctrl']['container'][$currentRenderType]['fieldInformation'] ?? [];
58  ArrayUtility::mergeRecursiveWithOverrule($fieldInformation, $fieldInformationFromTca);
59  $options['renderType'] = 'fieldInformation';
60  $options['renderData']['fieldInformation'] = $fieldInformation;
61  return $this->nodeFactory->create($options)->render();
62  }
63 
69  protected function ‪renderFieldControl(): array
70  {
71  $options = ‪$this->data;
72  $fieldControl = ‪$this->defaultFieldControl;
73  $currentRenderType = $this->data['renderType'];
74  $fieldControlFromTca = $options['processedTca']['ctrl']['container'][$currentRenderType]['fieldControl'] ?? [];
75  ArrayUtility::mergeRecursiveWithOverrule($fieldControl, $fieldControlFromTca);
76  $options['renderType'] = 'fieldControl';
77  $options['renderData']['fieldControl'] = $fieldControl;
78  return $this->nodeFactory->create($options)->render();
79  }
80 
86  protected function ‪renderFieldWizard(): array
87  {
88  $options = ‪$this->data;
89  $fieldWizard = ‪$this->defaultFieldWizard;
90  $currentRenderType = $this->data['renderType'];
91  $fieldWizardFromTca = $options['processedTca']['ctrl']['container'][$currentRenderType]['fieldWizard'] ?? [];
92  ArrayUtility::mergeRecursiveWithOverrule($fieldWizard, $fieldWizardFromTca);
93  $options['renderType'] = 'fieldWizard';
94  $options['renderData']['fieldWizard'] = $fieldWizard;
95  return $this->nodeFactory->create($options)->render();
96  }
97 
107  protected function ‪explodeSingleFieldShowItemConfiguration(string $field): array
108  {
109  $fieldArray = ‪GeneralUtility::trimExplode(';', $field);
110  if (empty($fieldArray[0])) {
111  throw new \RuntimeException('Field must not be empty', 1426448465);
112  }
113  return [
114  'fieldName' => $fieldArray[0],
115  'fieldLabel' => !empty($fieldArray[1]) ? $fieldArray[1] : null,
116  'paletteName' => !empty($fieldArray[2]) ? $fieldArray[2] : null,
117  ];
118  }
119 
127  protected function ‪renderTabMenu(array $menuItems, string $domId): string
128  {
129  $view = $this->backendViewFactory->create($this->data['request']);
130  $view->assignMultiple([
131  'id' => $domId,
132  'items' => $menuItems,
133  'defaultTabIndex' => 1,
134  'wrapContent' => false,
135  'storeLastActiveTab' => true,
136  ]);
137  return $view->render('Form/Tabs');
138  }
139 
140  protected function ‪wrapWithFieldsetAndLegend(string $fieldContent): string
141  {
142  $legend = htmlspecialchars($this->data['parameterArray']['fieldConf']['label']);
143  if ($this->‪getBackendUserAuthentication()->shallDisplayDebugInformation()) {
144  $fieldName = $this->data['flexFormContainerFieldName'] ?? $this->data['flexFormFieldName'] ?? $this->data['fieldName'];
145  $legend .= ' <code>[' . htmlspecialchars($fieldName) . ']</code>';
146  }
147  return '<fieldset><legend class="form-legend">' . $legend . '</legend>' . $fieldContent . '</fieldset>';
148  }
149 
151  {
152  return ‪$GLOBALS['BE_USER'];
153  }
154 }
‪TYPO3\CMS\Backend\Form\AbstractNode\$defaultFieldInformation
‪array $defaultFieldInformation
Definition: AbstractNode.php:41
‪TYPO3\CMS\Backend\View\BackendViewFactory
Definition: BackendViewFactory.php:35
‪TYPO3\CMS\Backend\Form\Container
Definition: AbstractContainer.php:16
‪TYPO3\CMS\Backend\Form\AbstractNode\$defaultFieldControl
‪array $defaultFieldControl
Definition: AbstractNode.php:48
‪TYPO3\CMS\Backend\Form\AbstractNode\$defaultFieldWizard
‪array $defaultFieldWizard
Definition: AbstractNode.php:55
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\wrapWithFieldsetAndLegend
‪wrapWithFieldsetAndLegend(string $fieldContent)
Definition: AbstractContainer.php:140
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\$nodeFactory
‪NodeFactory $nodeFactory
Definition: AbstractContainer.php:30
‪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\Container\AbstractContainer\getBackendUserAuthentication
‪getBackendUserAuthentication()
Definition: AbstractContainer.php:150
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:35
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer
Definition: AbstractContainer.php:29
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\injectBackendViewFactory
‪injectBackendViewFactory(BackendViewFactory $backendViewFactory)
Definition: AbstractContainer.php:42
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\renderFieldInformation
‪array renderFieldInformation()
Definition: AbstractContainer.php:52
‪TYPO3\CMS\Backend\Form\NodeFactory
Definition: NodeFactory.php:39
‪TYPO3\CMS\Core\Utility\ArrayUtility
Definition: ArrayUtility.php:26
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\renderFieldControl
‪array renderFieldControl()
Definition: AbstractContainer.php:69
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\renderFieldWizard
‪array renderFieldWizard()
Definition: AbstractContainer.php:86
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\$backendViewFactory
‪BackendViewFactory $backendViewFactory
Definition: AbstractContainer.php:31
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer\injectNodeFactory
‪injectNodeFactory(NodeFactory $nodeFactory)
Definition: AbstractContainer.php:37
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode(string $delim, string $string, bool $removeEmptyValues=false, int $limit=0)
Definition: GeneralUtility.php:822