TYPO3 CMS  TYPO3_8-7
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:lang/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:lang/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  $html = [];
86  $html[] = '<div class="t3-form-field-container-flexsections t3-flex-section t3js-flex-section">';
87  $html[] = '<input class="t3-flex-control t3js-flex-control-action" type="hidden" name="' . htmlspecialchars($actionFieldName) . '" value="" />';
88  $html[] = '<div class="panel panel-default panel-condensed">';
89  $html[] = '<div class="panel-heading t3js-flex-section-header" data-toggle="formengine-flex">';
90  $html[] = '<div class="form-irre-header">';
91  $html[] = '<div class="form-irre-header-cell form-irre-header-icon">';
92  $html[] = $toggleIcons;
93  $html[] = '</div>';
94  $html[] = '<div class="form-irre-header-cell form-irre-header-body">';
95  $html[] = '<span class="t3js-record-title">' . htmlspecialchars($containerTitle) . '</span>';
96  $html[] = '</div>';
97  $html[] = '<div class="form-irre-header-cell form-irre-header-control">';
98  $html[] = '<div class="btn-group btn-group-sm">';
99  $html[] = implode(LF, $moveAndDeleteContent);
100  $html[] = '</div>';
101  $html[] = '</div>';
102  $html[] = '</div>';
103  $html[] = '</div>';
104  $html[] = '<div class="panel-collapse t3js-flex-section-content"' . ($flexFormContainerElementCollapsed ? ' style="display:none;"' : '') . '>';
105  $html[] = $containerContentResult['html'];
106  $html[] = '</div>';
107  $html[] = '<input';
108  $html[] = 'class="t3-flex-control t3js-flex-control-toggle"';
109  $html[] = 'type="hidden"';
110  $html[] = 'name="' . htmlspecialchars($toggleFieldName) . '"';
111  $html[] = 'value="' . ($flexFormContainerElementCollapsed ? '1' : '0') . '"';
112  $html[] = '/>';
113  $html[] = '</div>';
114  $html[] = '</div>';
115 
116  $resultArray = $this->initializeResultArray();
117  $resultArray['html'] = implode(LF, $html);
118  $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $containerContentResult, false);
119 
120  return $resultArray;
121  }
122 
126  protected function getBackendUserAuthentication()
127  {
128  return $GLOBALS['BE_USER'];
129  }
130 
134  protected function getLanguageService()
135  {
136  return $GLOBALS['LANG'];
137  }
138 }
static makeInstance($className,... $constructorArguments)
mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']