‪TYPO3CMS  9.5
FlexFormContainerContainer.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 
22 
29 {
35  public function ‪render()
36  {
37  $languageService = $this->‪getLanguageService();
38 
39  $table = $this->data['tableName'];
40  $row = $this->data['databaseRow'];
41  $fieldName = $this->data['fieldName'];
42  $flexFormFormPrefix = $this->data['flexFormFormPrefix'];
43  $flexFormContainerElementCollapsed = $this->data['flexFormContainerElementCollapsed'];
44  $flexFormDataStructureArray = $this->data['flexFormDataStructureArray'];
45  $parameterArray = $this->data['parameterArray'];
46 
47  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
48  $toggleIcons = '<span class="t3js-flex-control-toggle-icon-open" style="' . ($flexFormContainerElementCollapsed ? 'display: none;' : '') . '">'
49  . $iconFactory->getIcon('actions-view-list-collapse', ‪Icon::SIZE_SMALL)->render()
50  . '</span>';
51  $toggleIcons .= '<span class="t3js-flex-control-toggle-icon-close" style="' . ($flexFormContainerElementCollapsed ? '' : 'display: none;') . '">'
52  . $iconFactory->getIcon('actions-view-list-expand', ‪Icon::SIZE_SMALL)->render()
53  . '</span>';
54 
55  $flexFormContainerIdentifier = $this->data['flexFormContainerIdentifier'];
56  $actionFieldName = '_ACTION_FLEX_FORM'
57  . $parameterArray['itemFormElName']
58  . $this->data['flexFormFormPrefix']
59  . '[_ACTION]'
60  . '[' . $flexFormContainerIdentifier . ']';
61  $toggleFieldName = 'data[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'
62  . $flexFormFormPrefix
63  . '[' . $flexFormContainerIdentifier . ']'
64  . '[_TOGGLE]';
65 
66  $moveAndDeleteContent = [];
67  $userHasAccessToDefaultLanguage = $this->‪getBackendUserAuthentication()->‪checkLanguageAccess(0);
68  if ($userHasAccessToDefaultLanguage) {
69  $moveAndDeleteContent[] = '<span class="btn btn-default t3js-sortable-handle"><span title="' . htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:sortable.dragmove')) . '">' . $iconFactory->getIcon('actions-move-move', ‪Icon::SIZE_SMALL)->render() . '</span></span>';
70  $moveAndDeleteContent[] = '<span class="btn btn-default t3js-delete"><span title="' . htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:delete')) . '">' . $iconFactory->getIcon('actions-edit-delete', ‪Icon::SIZE_SMALL)->render() . '</span></span>';
71  }
72 
73  $options = ‪$this->data;
74  // Append container specific stuff to field prefix
75  $options['flexFormFormPrefix'] = $flexFormFormPrefix . '[' . $flexFormContainerIdentifier . '][' . $this->data['flexFormContainerName'] . '][el]';
76  $options['flexFormDataStructureArray'] = $flexFormDataStructureArray['el'];
77  $options['renderType'] = 'flexFormElementContainer';
78  $containerContentResult = $this->nodeFactory->create($options)->render();
79 
80  $containerTitle = '';
81  if (!empty(trim($flexFormDataStructureArray['title']))) {
82  $containerTitle = $languageService->sL(trim($flexFormDataStructureArray['title']));
83  }
84 
85  $resultArray = $this->‪initializeResultArray();
86 
87  $html = [];
88  $html[] = '<div class="t3-form-field-container-flexsections t3-flex-section t3js-flex-section">';
89  $html[] = '<input class="t3-flex-control t3js-flex-control-action" type="hidden" name="' . htmlspecialchars($actionFieldName) . '" value="" />';
90  $html[] = '<div class="panel panel-default panel-condensed">';
91  $html[] = '<div class="panel-heading t3js-flex-section-header" data-toggle="formengine-flex">';
92  $html[] = '<div class="form-irre-header">';
93  $html[] = '<div class="form-irre-header-cell form-irre-header-icon">';
94  $html[] = $toggleIcons;
95  $html[] = '</div>';
96  $html[] = '<div class="form-irre-header-cell form-irre-header-body">';
97  $html[] = '<span class="t3js-record-title">' . htmlspecialchars($containerTitle) . '</span>';
98  $html[] = '</div>';
99  $html[] = '<div class="form-irre-header-cell form-irre-header-control">';
100  $html[] = '<div class="btn-group btn-group-sm">';
101  $html[] = implode(LF, $moveAndDeleteContent);
102  $html[] = '</div>';
103  $html[] = '</div>';
104  $html[] = '</div>';
105  $html[] = '</div>';
106  $html[] = '<div class="panel-collapse t3js-flex-section-content"' . ($flexFormContainerElementCollapsed ? ' style="display:none;"' : '') . '>';
107  $html[] = $containerContentResult['html'];
108  $html[] = '</div>';
109  $html[] = '<input';
110  $html[] = 'class="t3-flex-control t3js-flex-control-toggle"';
111  $html[] = 'type="hidden"';
112  $html[] = 'name="' . htmlspecialchars($toggleFieldName) . '"';
113  $html[] = 'value="' . ($flexFormContainerElementCollapsed ? '1' : '0') . '"';
114  $html[] = '/>';
115  $html[] = '</div>';
116  $html[] = '</div>';
117 
118  $resultArray['html'] = implode(LF, $html);
119  $resultArray = $this->‪mergeChildReturnIntoExistingResult($resultArray, $containerContentResult, false);
120 
121  return $resultArray;
122  }
123 
127  protected function ‪getBackendUserAuthentication()
128  {
129  return ‪$GLOBALS['BE_USER'];
130  }
131 
135  protected function ‪getLanguageService()
136  {
137  return ‪$GLOBALS['LANG'];
138  }
139 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:29
‪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\Core\Imaging\Icon
Definition: Icon.php:25
‪TYPO3\CMS\Backend\Form\Container
Definition: AbstractContainer.php:2
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:31
‪TYPO3\CMS\Backend\Form\AbstractNode\$data
‪array $data
Definition: AbstractNode.php:40
‪TYPO3\CMS\Backend\Form\Container\AbstractContainer
Definition: AbstractContainer.php:27
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\checkLanguageAccess
‪bool checkLanguageAccess($langValue)
Definition: BackendUserAuthentication.php:733
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Backend\Form\Container\FlexFormContainerContainer\getLanguageService
‪LanguageService getLanguageService()
Definition: FlexFormContainerContainer.php:135
‪TYPO3\CMS\Backend\Form\Container\FlexFormContainerContainer\getBackendUserAuthentication
‪BackendUserAuthentication getBackendUserAuthentication()
Definition: FlexFormContainerContainer.php:127
‪$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\FlexFormContainerContainer\render
‪array render()
Definition: FlexFormContainerContainer.php:35
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Form\Container\FlexFormContainerContainer
Definition: FlexFormContainerContainer.php:29