TYPO3 CMS  TYPO3_7-6
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  $table = $this->data['tableName'];
38  $row = $this->data['databaseRow'];
39  $fieldName = $this->data['fieldName'];
40  $flexFormFormPrefix = $this->data['flexFormFormPrefix'];
41  $flexFormContainerElementCollapsed = $this->data['flexFormContainerElementCollapsed'];
42  $flexFormContainerTitle = $this->data['flexFormContainerTitle'];
43  $flexFormFieldIdentifierPrefix = $this->data['flexFormFieldIdentifierPrefix'];
44  $parameterArray = $this->data['parameterArray'];
45 
46  // Every container adds its own part to the id prefix
47  $flexFormFieldIdentifierPrefix = $flexFormFieldIdentifierPrefix . '-' . GeneralUtility::shortMd5(uniqid('id', true));
48 
49  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
50  $toggleIcons = '<span class="t3js-flex-control-toggle-icon-open" style="' . ($flexFormContainerElementCollapsed ? 'display: none;' : '') . '">'
51  . $iconFactory->getIcon('actions-view-list-collapse', Icon::SIZE_SMALL)->render()
52  . '</span>';
53  $toggleIcons .= '<span class="t3js-flex-control-toggle-icon-close" style="' . ($flexFormContainerElementCollapsed ? '' : 'display: none;') . '">'
54  . $iconFactory->getIcon('actions-view-list-expand', Icon::SIZE_SMALL)->render()
55  . '</span>';
56 
57  $flexFormContainerCounter = $this->data['flexFormContainerCounter'];
58  $actionFieldName = '_ACTION_FLEX_FORM'
59  . $parameterArray['itemFormElName']
60  . $this->data['flexFormFormPrefix']
61  . '[_ACTION]'
62  . '[' . $flexFormContainerCounter . ']';
63  $toggleFieldName = 'data[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'
64  . $flexFormFormPrefix
65  . '[' . $flexFormContainerCounter . ']'
66  . '[_TOGGLE]';
67 
68  $moveAndDeleteContent = [];
69  $userHasAccessToDefaultLanguage = $this->getBackendUserAuthentication()->checkLanguageAccess(0);
70  if ($userHasAccessToDefaultLanguage) {
71  $moveAndDeleteContent[] = '<span class="btn btn-default t3js-sortable-handle"><span title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:sortable.dragmove', true) . '">' . $iconFactory->getIcon('actions-move-move', Icon::SIZE_SMALL)->render() . '</span></span>';
72  $moveAndDeleteContent[] = '<span class="btn btn-default t3js-delete"><span title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:delete', true) . '">' . $iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</span></span>';
73  }
74 
75  $options = $this->data;
76  $options['flexFormFieldIdentifierPrefix'] = $flexFormFieldIdentifierPrefix;
77  // Append container specific stuff to field prefix
78  $options['flexFormFormPrefix'] = $flexFormFormPrefix . '[' . $flexFormContainerCounter . '][' . $this->data['flexFormContainerName'] . '][el]';
79  $options['renderType'] = 'flexFormElementContainer';
80  $containerContentResult = $this->nodeFactory->create($options)->render();
81 
82  $html = [];
83  $html[] = '<div id="' . $flexFormFieldIdentifierPrefix . '" class="t3-form-field-container-flexsections t3-flex-section t3js-flex-section">';
84  $html[] = '<input class="t3-flex-control t3js-flex-control-action" type="hidden" name="' . htmlspecialchars($actionFieldName) . '" value="" />';
85  $html[] = '<div class="panel panel-default panel-condensed">';
86  $html[] = '<div class="panel-heading t3js-flex-section-header" data-toggle="formengine-flex">';
87  $html[] = '<div class="form-irre-header">';
88  $html[] = '<div class="form-irre-header-cell form-irre-header-icon">';
89  $html[] = $toggleIcons;
90  $html[] = '</div>';
91  $html[] = '<div class="form-irre-header-cell form-irre-header-body">';
92  $html[] = '<span class="t3js-record-title">' . $flexFormContainerTitle . '</span>';
93  $html[] = '</div>';
94  $html[] = '<div class="form-irre-header-cell form-irre-header-control">';
95  $html[] = '<div class="btn-group btn-group-sm">';
96  $html[] = implode(LF, $moveAndDeleteContent);
97  $html[] = '</div>';
98  $html[] = '</div>';
99  $html[] = '</div>';
100  $html[] = '</div>';
101  $html[] = '<div class="panel-collapse t3js-flex-section-content"' . ($flexFormContainerElementCollapsed ? ' style="display:none;"' : '') . '>';
102  $html[] = $containerContentResult['html'];
103  $html[] = '</div>';
104  $html[] = '<input';
105  $html[] = 'class="t3-flex-control t3js-flex-control-toggle"';
106  $html[] = 'id="' . $flexFormFieldIdentifierPrefix . '-toggleClosed"';
107  $html[] = 'type="hidden"';
108  $html[] = 'name="' . htmlspecialchars($toggleFieldName) . '"';
109  $html[] = 'value="' . ($flexFormContainerElementCollapsed ? '1' : '0') . '"';
110  $html[] = '/>';
111  $html[] = '</div>';
112  $html[] = '</div>';
113 
114  $containerContentResult['html'] = '';
115  $resultArray = $this->initializeResultArray();
116  $resultArray['html'] = implode(LF, $html);
117  $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $containerContentResult);
118 
119  return $resultArray;
120  }
121 
125  protected function getBackendUserAuthentication()
126  {
127  return $GLOBALS['BE_USER'];
128  }
129 
133  protected function getLanguageService()
134  {
135  return $GLOBALS['LANG'];
136  }
137 }
mergeChildReturnIntoExistingResult(array $existing, array $childReturn)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']