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