[TASK] Adapt FormEngine translated records to Bootstrap
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / Element / FlexElement.php
1 <?php
2 namespace TYPO3\CMS\Backend\Form\Element;
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
17 use TYPO3\CMS\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Backend\Utility\IconUtility;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20
21 /**
22 * Generation of TCEform elements of the type "flexform"
23 */
24 class FlexElement extends AbstractFormElement {
25
26 /**
27 * Handler for Flex Forms
28 *
29 * @param string $table The table name of the record
30 * @param string $field The field name which this element is supposed to edit
31 * @param array $row The record data array where the value(s) for the field can be found
32 * @param array $additionalInformation An array with additional configuration options.
33 * @return string The HTML code for the TCEform field
34 */
35 public function render($table, $field, $row, &$additionalInformation) {
36 // Data Structure:
37 $dataStructArray = BackendUtility::getFlexFormDS($additionalInformation['fieldConf']['config'], $row, $table, $field);
38 $item = '';
39 // Manipulate Flexform DS via TSConfig and group access lists
40 if (is_array($dataStructArray)) {
41 $flexFormHelper = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Form\FlexFormsHelper::class);
42 $dataStructArray = $flexFormHelper->modifyFlexFormDS($dataStructArray, $table, $field, $row, $additionalInformation['fieldConf']);
43 unset($flexFormHelper);
44 }
45 // Get data structure:
46 if (is_array($dataStructArray)) {
47 // Get data:
48 $xmlData = $additionalInformation['itemFormElValue'];
49 $xmlHeaderAttributes = GeneralUtility::xmlGetHeaderAttribs($xmlData);
50 $storeInCharset = strtolower($xmlHeaderAttributes['encoding']);
51 if ($storeInCharset) {
52 $currentCharset = $this->getLanguageService()->charSet;
53 $xmlData = $this->getLanguageService()->csConvObj->conv($xmlData, $storeInCharset, $currentCharset, 1);
54 }
55 $editData = GeneralUtility::xml2array($xmlData);
56 // Must be XML parsing error...
57 if (!is_array($editData)) {
58 $editData = array();
59 } elseif (!isset($editData['meta']) || !is_array($editData['meta'])) {
60 $editData['meta'] = array();
61 }
62 // Find the data structure if sheets are found:
63 $sheet = $editData['meta']['currentSheetId'] ? $editData['meta']['currentSheetId'] : 'sDEF';
64 // Sheet to display
65 // Create language menu:
66 $langChildren = $dataStructArray['meta']['langChildren'] ? 1 : 0;
67 $langDisabled = $dataStructArray['meta']['langDisable'] ? 1 : 0;
68 $editData['meta']['currentLangId'] = array();
69 // Look up page overlays:
70 $checkPageLanguageOverlay = $this->getBackendUserAuthentication()->getTSConfigVal('options.checkPageLanguageOverlay') ? TRUE : FALSE;
71 if ($checkPageLanguageOverlay) {
72 $where_clause = 'pid=' . (int)$row['pid'] . BackendUtility::deleteClause('pages_language_overlay')
73 . BackendUtility::versioningPlaceholderClause('pages_language_overlay');
74 $pageOverlays = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'pages_language_overlay', $where_clause, '', '', '', 'sys_language_uid');
75 }
76 $languages = $this->formEngine->getAvailableLanguages();
77 foreach ($languages as $lInfo) {
78 if (
79 $this->getBackendUserAuthentication()->checkLanguageAccess($lInfo['uid'])
80 && (!$checkPageLanguageOverlay || $lInfo['uid'] <= 0 || is_array($pageOverlays[$lInfo['uid']]))
81 ) {
82 $editData['meta']['currentLangId'][] = $lInfo['ISOcode'];
83 }
84 }
85 if (!is_array($editData['meta']['currentLangId']) || !count($editData['meta']['currentLangId'])) {
86 $editData['meta']['currentLangId'] = array('DEF');
87 }
88 $editData['meta']['currentLangId'] = array_unique($editData['meta']['currentLangId']);
89 $additionalInformation['_noEditDEF'] = FALSE;
90 if ($langChildren || $langDisabled) {
91 $rotateLang = array('DEF');
92 } else {
93 if (!in_array('DEF', $editData['meta']['currentLangId'])) {
94 array_unshift($editData['meta']['currentLangId'], 'DEF');
95 $additionalInformation['_noEditDEF'] = TRUE;
96 }
97 $rotateLang = $editData['meta']['currentLangId'];
98 }
99 // Tabs sheets
100 if (is_array($dataStructArray['sheets'])) {
101 $tabsToTraverse = array_keys($dataStructArray['sheets']);
102 } else {
103 $tabsToTraverse = array($sheet);
104 }
105
106 $this->getControllerDocumentTemplate()->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/FormEngineFlexForm');
107
108 /** @var $elementConditionMatcher \TYPO3\CMS\Backend\Form\ElementConditionMatcher */
109 $elementConditionMatcher = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Form\ElementConditionMatcher::class);
110
111 foreach ($rotateLang as $lKey) {
112 if (!$langChildren && !$langDisabled) {
113 $item .= '<strong>' . $this->formEngine->getLanguageIcon($table, $row, ('v' . $lKey)) . $lKey . ':</strong>';
114 }
115 // Default language, other options are "lUK" or whatever country code (independent of system!!!)
116 $lang = 'l' . $lKey;
117 $tabParts = array();
118 $sheetContent = '';
119 foreach ($tabsToTraverse as $sheet) {
120 list($dataStruct, $sheet) = GeneralUtility::resolveSheetDefInDS($dataStructArray, $sheet);
121 // If sheet has displayCond
122 if ($dataStruct['ROOT']['TCEforms']['displayCond']) {
123 $splitCondition = GeneralUtility::trimExplode(':', $dataStruct['ROOT']['TCEforms']['displayCond']);
124 $skipCondition = FALSE;
125 $fakeRow = array();
126 switch ($splitCondition[0]) {
127 case 'FIELD':
128 list($sheetName, $fieldName) = GeneralUtility::trimExplode('.', $splitCondition[1]);
129 $fieldValue = $editData['data'][$sheetName][$lang][$fieldName];
130 $splitCondition[1] = $fieldName;
131 $dataStruct['ROOT']['TCEforms']['displayCond'] = join(':', $splitCondition);
132 $fakeRow = array($fieldName => $fieldValue);
133 break;
134 case 'HIDE_FOR_NON_ADMINS':
135
136 case 'VERSION':
137
138 case 'HIDE_L10N_SIBLINGS':
139
140 case 'EXT':
141 break;
142 case 'REC':
143 $fakeRow = array('uid' => $row['uid']);
144 break;
145 default:
146 $skipCondition = TRUE;
147 }
148 $displayConditionResult = TRUE;
149 if ($dataStruct['ROOT']['TCEforms']['displayCond']) {
150 $displayConditionResult = $elementConditionMatcher->match($dataStruct['ROOT']['TCEforms']['displayCond'], $fakeRow, 'vDEF');
151 }
152 // If sheets displayCond leads to false
153 if (!$skipCondition && !$displayConditionResult) {
154 // Don't create this sheet
155 continue;
156 }
157 }
158 // Render sheet:
159 if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) {
160 // Default language, other options are "lUK" or whatever country code (independent of system!!!)
161 $additionalInformation['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF';
162 $additionalInformation['_lang'] = $lang;
163 // Assemble key for loading the correct CSH file
164 $dsPointerFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$field]['config']['ds_pointerField'], TRUE);
165 $additionalInformation['_cshKey'] = $table . '.' . $field;
166 foreach ($dsPointerFields as $key) {
167 $additionalInformation['_cshKey'] .= '.' . $row[$key];
168 }
169 // Push the sheet level tab to DynNestedStack
170 $tabIdentString = '';
171 if (is_array($dataStructArray['sheets'])) {
172 $tabIdentString = $this->getDocumentTemplate()->getDynTabMenuId('TCEFORMS:flexform:' . $additionalInformation['itemFormElName'] . $additionalInformation['_lang']);
173 $this->formEngine->pushToDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) + 1));
174 }
175 // Render flexform:
176 $tRows = $this->getSingleField_typeFlex_draw($dataStruct['ROOT']['el'], $editData['data'][$sheet][$lang], $table, $field, $row, $additionalInformation, '[data][' . $sheet . '][' . $lang . ']');
177 $sheetContent = '<div class="typo3-TCEforms-flexForm t3-form-flexform">' . $tRows . '</div>';
178 // Pop the sheet level tab from DynNestedStack
179 if (is_array($dataStructArray['sheets'])) {
180 $this->formEngine->popFromDynNestedStack('tab', $tabIdentString . '-' . (count($tabParts) + 1));
181 }
182 } else {
183 $sheetContent = 'Data Structure ERROR: No ROOT element found for sheet "' . $sheet . '".';
184 }
185 // Add to tab:
186 $tabParts[] = array(
187 'label' => $dataStruct['ROOT']['TCEforms']['sheetTitle'] ? $this->formEngine->sL($dataStruct['ROOT']['TCEforms']['sheetTitle']) : $sheet,
188 'description' => $dataStruct['ROOT']['TCEforms']['sheetDescription'] ? $this->formEngine->sL($dataStruct['ROOT']['TCEforms']['sheetDescription']) : '',
189 'linkTitle' => $dataStruct['ROOT']['TCEforms']['sheetShortDescr'] ? $this->formEngine->sL($dataStruct['ROOT']['TCEforms']['sheetShortDescr']) : '',
190 'content' => $sheetContent
191 );
192 }
193 if (is_array($dataStructArray['sheets'])) {
194 $item .= $this->formEngine->getDynTabMenu($tabParts, 'TCEFORMS:flexform:' . $additionalInformation['itemFormElName'] . $additionalInformation['_lang']);
195 } else {
196 $item .= $sheetContent;
197 }
198 }
199 } else {
200 $item = 'Data Structure ERROR: ' . $dataStructArray;
201 }
202 return $item;
203 }
204
205
206 /**
207 * Recursive rendering of flexforms
208 *
209 * @param array $dataStruct (part of) Data Structure for which to render. Keys on first level is flex-form fields
210 * @param array $editData (part of) Data array of flexform corresponding to the input DS. Keys on first level is flex-form field names
211 * @param string $table Table name, eg. tt_content
212 * @param string $field Field name, eg. tx_templavoila_flex
213 * @param array $row The particular record from $table in which the field $field is found
214 * @param array $PA Array of standard information for rendering of a form field in TCEforms, see other rendering functions too
215 * @param string $formPrefix Form field prefix, eg. "[data][sDEF][lDEF][...][...]
216 * @param int $level Indicates nesting level for the function call
217 * @param string $idPrefix Prefix for ID-values
218 * @param bool $toggleClosed Defines whether the next flexform level is open or closed. Comes from _TOGGLE pseudo field in FlexForm xml.
219 * @return string HTMl code for form.
220 */
221 public function getSingleField_typeFlex_draw($dataStruct, $editData, $table, $field, $row, &$PA, $formPrefix = '', $level = 0, $idPrefix = 'ID', $toggleClosed = FALSE) {
222 $output = '';
223 $mayRestructureFlexforms = $this->getBackendUserAuthentication()->checkLanguageAccess(0);
224 // Data Structure array must be ... and array of course...
225 if (is_array($dataStruct)) {
226 foreach ($dataStruct as $key => $value) {
227 // Traversing fields in structure:
228 if (is_array($value)) {
229 // The value of each entry must be an array.
230 // ********************
231 // Making the row:
232 // ********************
233 // Title of field:
234 // <title>LLL:EXT:cms/locallang_ttc.xml:media.sources</title>
235 $theTitle = $value['title'];
236
237 // If there is a title, check for LLL label
238 if (strlen($theTitle) > 0) {
239 $theTitle = htmlspecialchars(GeneralUtility::fixed_lgd_cs($this->formEngine->sL($theTitle),
240 (int)$this->getBackendUserAuthentication()->uc['titleLen']));
241 }
242 // If it's a "section" or "container":
243 if ($value['type'] == 'array') {
244 // Creating IDs for form fields:
245 // It's important that the IDs "cascade" - otherwise we can't dynamically expand the flex form
246 // because this relies on simple string substitution of the first parts of the id values.
247 // This is a suffix used for forms on this level
248 $thisId = GeneralUtility::shortMd5(uniqid('id', TRUE));
249 // $idPrefix is the prefix for elements on lower levels in the hierarchy and we combine this
250 // with the thisId value to form a new ID on this level.
251 $idTagPrefix = $idPrefix . '-' . $thisId;
252 // If it's a "section" containing other elements:
253 if ($value['section']) {
254 // Load script.aculo.us if flexform sections can be moved by drag'n'drop:
255 $this->getControllerDocumentTemplate()->getPageRenderer()->loadScriptaculous();
256 // Render header of section:
257 $output .= '<div class="t3-form-field-label-flexsection"><strong>' . $theTitle . '</strong></div>';
258 // Render elements in data array for section:
259 $tRows = array();
260 if (is_array($editData[$key]['el'])) {
261 foreach ($editData[$key]['el'] as $k3 => $v3) {
262 $cc = $k3;
263 if (is_array($v3)) {
264 $theType = key($v3);
265 $theDat = $v3[$theType];
266 $newSectionEl = $value['el'][$theType];
267 if (is_array($newSectionEl)) {
268 $tRows[] = $this->getSingleField_typeFlex_draw(array($theType => $newSectionEl),
269 array($theType => $theDat), $table, $field, $row, $PA,
270 $formPrefix . '[' . $key . '][el][' . $cc . ']', $level + 1,
271 $idTagPrefix, $v3['_TOGGLE']);
272 }
273 }
274 }
275 }
276 // Now, we generate "templates" for new elements that could be added to this section
277 // by traversing all possible types of content inside the section:
278 // We have to handle the fact that requiredElements and such may be set during this
279 // rendering process and therefore we save and reset the state of some internal variables
280 // ... little crude, but works...
281 // Preserving internal variables we don't want to change:
282 $TEMP_requiredElements = $this->formEngine->requiredElements;
283 // Traversing possible types of new content in the section:
284 $newElementsLinks = array();
285 foreach ($value['el'] as $nnKey => $nCfg) {
286 $additionalJS_post_saved = $this->formEngine->additionalJS_post;
287 $this->formEngine->additionalJS_post = array();
288 $additionalJS_submit_saved = $this->formEngine->additionalJS_submit;
289 $this->formEngine->additionalJS_submit = array();
290 $newElementTemplate = $this->getSingleField_typeFlex_draw(array($nnKey => $nCfg),
291 array(), $table, $field, $row, $PA,
292 $formPrefix . '[' . $key . '][el][' . $idTagPrefix . '-form]', $level + 1,
293 $idTagPrefix);
294 // Makes a "Add new" link:
295 $var = str_replace('.', '', uniqid('idvar', TRUE));
296 $replace = 'replace(/' . $idTagPrefix . '-/g,"' . $idTagPrefix . '-"+' . $var . '+"-")';
297 $replace .= '.replace(/(tceforms-(datetime|date)field-)/g,"$1" + (new Date()).getTime())';
298 $onClickInsert = 'var ' . $var . ' = "' . 'idx"+(new Date()).getTime();'
299 // Do not replace $isTagPrefix in setActionStatus() because it needs section id!
300 . 'new Insertion.Bottom($("' . $idTagPrefix . '"), ' . json_encode($newElementTemplate)
301 . '.' . $replace . '); TYPO3.jQuery("#' . $idTagPrefix . '").t3FormEngineFlexFormElement();'
302 . 'eval(unescape("' . rawurlencode(implode(';', $this->formEngine->additionalJS_post)) . '").' . $replace . ');'
303 . 'TBE_EDITOR.addActionChecks("submit", unescape("'
304 . rawurlencode(implode(';', $this->formEngine->additionalJS_submit)) . '").' . $replace . ');'
305 . 'TYPO3.TCEFORMS.update();'
306 . 'return false;';
307 // Kasper's comment (kept for history):
308 // Maybe there is a better way to do this than store the HTML for the new element
309 // in rawurlencoded format - maybe it even breaks with certain charsets?
310 // But for now this works...
311 $this->formEngine->additionalJS_post = $additionalJS_post_saved;
312 $this->formEngine->additionalJS_submit = $additionalJS_submit_saved;
313 $title = '';
314 if (isset($nCfg['title'])) {
315 $title = $this->formEngine->sL($nCfg['title']);
316 }
317 $newElementsLinks[] = '<a href="#" onclick="' . htmlspecialchars($onClickInsert) . '">'
318 . IconUtility::getSpriteIcon('actions-document-new')
319 . htmlspecialchars(GeneralUtility::fixed_lgd_cs($title, 30)) . '</a>';
320 }
321 // Reverting internal variables we don't want to change:
322 $this->formEngine->requiredElements = $TEMP_requiredElements;
323 // Adding the sections
324
325 // add the "toggle all" button for the sections
326 $toggleAll = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.toggleall', TRUE);
327 $output .= '
328 <div class="t3-form-field-toggle-flexsection t3-form-flexsection-toggle">
329 <a href="#">'. IconUtility::getSpriteIcon('actions-move-right', array('title' => $toggleAll)) . $toggleAll . '</a>
330 </div>
331 <div id="' . $idTagPrefix . '" class="t3-form-field-container-flexsection t3-flex-container" data-t3-flex-allow-restructure="' . ($mayRestructureFlexforms ? 1 : 0) . '">' . implode('', $tRows) . '</div>';
332
333 // add the "new" link
334 if ($mayRestructureFlexforms) {
335 $output .= '<div class="t3-form-field-add-flexsection"><strong>'
336 . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.addnew', TRUE)
337 . ':</strong> ' . implode(' | ', $newElementsLinks) . '</div>';
338 }
339
340 $output = '<div class="t3-form-field-container t3-form-flex">' . $output . '</div>';
341 } else {
342 // It is a container of a single section
343 $toggleIconOpenState = ($toggleClosed ? 'display: none;' : '');
344 $toggleIconCloseState = (!$toggleClosed ? 'display: none;' : '');
345
346 $toggleIcons = IconUtility::getSpriteIcon('actions-move-down', array('class' => 't3-flex-control-toggle-icon-open', 'style' => $toggleIconOpenState));
347 $toggleIcons .= IconUtility::getSpriteIcon('actions-move-right', array('class' => 't3-flex-control-toggle-icon-close', 'style' => $toggleIconCloseState));
348
349 // Notice: Creating "new" elements after others seemed to be too difficult to do
350 // and since moving new elements created in the bottom is now so easy
351 // with drag'n'drop I didn't see the need.
352 // Putting together header of a section. Sections can be removed, copied, opened/closed, moved up and down:
353 // I didn't know how to make something right-aligned without a table, so I put it in a table.
354 // can be made into <div>'s if someone like to.
355 // Notice: The fact that I make a "Sortable.create" right onmousedown is that if we
356 // initialize this when rendering the form in PHP new and copied elements will not
357 // be possible to move as a sortable. But this way a new sortable is initialized every time
358 // someone tries to move and it will always work.
359 $ctrlHeader = '
360 <div class="pull-left">
361 <a href="#" class="t3-flex-control-toggle-button">' . $toggleIcons . '</a>
362 <span class="t3-record-title">' . $theTitle . '</span>
363 </div>';
364
365 if ($mayRestructureFlexforms) {
366 $ctrlHeader .= '<div class="pull-right">'
367 . IconUtility::getSpriteIcon('actions-move-move', array('title' => 'Drag to Move', 'class' => 't3-js-sortable-handle'))
368 . IconUtility::getSpriteIcon('actions-edit-delete', array('title' => 'Delete', 'class' => 't3-delete'))
369 . '</div>';
370 }
371
372 $ctrlHeader = '<div class="t3-form-field-header-flexsection t3-flex-section-header">' . $ctrlHeader . '</div>';
373
374 $s = GeneralUtility::revExplode('[]', $formPrefix, 2);
375 $actionFieldName = '_ACTION_FLEX_FORM' . $PA['itemFormElName'] . $s[0] . '][_ACTION][' . $s[1];
376 // Push the container to DynNestedStack as it may be toggled
377 $this->formEngine->pushToDynNestedStack('flex', $idTagPrefix);
378 // Putting together the container:
379 $this->formEngine->additionalJS_delete = array();
380 $singleField_typeFlex_draw = $this->getSingleField_typeFlex_draw($value['el'],
381 $editData[$key]['el'], $table, $field, $row, $PA,
382 ($formPrefix . '[' . $key . '][el]'), ($level + 1), $idTagPrefix);
383 $output .= '
384 <div id="' . $idTagPrefix . '" class="t3-form-field-container-flexsections t3-flex-section">
385 <input class="t3-flex-control t3-flex-control-action" type="hidden" name="' . htmlspecialchars($actionFieldName) . '" value=""/>
386
387 ' . $ctrlHeader . '
388 <div class="t3-form-field-record-flexsection t3-flex-section-content"'
389 . ($toggleClosed ? ' style="display:none;"' : '') . '>' . $singleField_typeFlex_draw . '
390 </div>
391 <input class="t3-flex-control t3-flex-control-toggle" id="' . $idTagPrefix . '-toggleClosed" type="hidden" name="'
392 . htmlspecialchars('data[' . $table . '][' . $row['uid'] . '][' . $field . ']' . $formPrefix . '[_TOGGLE]')
393 . '" value="' . ($toggleClosed ? 1 : 0) . '" />
394 </div>';
395 $output = str_replace('/*###REMOVE###*/', GeneralUtility::slashJS(htmlspecialchars(implode('', $this->formEngine->additionalJS_delete))), $output);
396 // NOTICE: We are saving the toggle-state directly in the flexForm XML and "unauthorized"
397 // according to the data structure. It means that flexform XML will report unclean and
398 // a cleaning operation will remove the recorded togglestates. This is not a fatal problem.
399 // Ideally we should save the toggle states in meta-data but it is much harder to do that.
400 // And this implementation was easy to make and with no really harmful impact.
401 // Pop the container from DynNestedStack
402 $this->formEngine->popFromDynNestedStack('flex', $idTagPrefix);
403 }
404 } elseif (is_array($value['TCEforms']['config'])) {
405 // Rendering a single form element:
406 if (is_array($PA['_valLang'])) {
407 $rotateLang = $PA['_valLang'];
408 } else {
409 $rotateLang = array($PA['_valLang']);
410 }
411 $conditionData = is_array($editData) ? $editData : array();
412 // Add current $row to data processed by \TYPO3\CMS\Backend\Form\ElementConditionMatcher
413 $conditionData['parentRec'] = $row;
414 $tRows = array();
415
416 /** @var $elementConditionMatcher \TYPO3\CMS\Backend\Form\ElementConditionMatcher */
417 $elementConditionMatcher = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Form\ElementConditionMatcher::class);
418
419 foreach ($rotateLang as $vDEFkey) {
420 $vDEFkey = 'v' . $vDEFkey;
421 $displayConditionResult = TRUE;
422 if ($value['TCEforms']['displayCond']) {
423 $displayConditionResult = $elementConditionMatcher->match($value['TCEforms']['displayCond'], $conditionData, $vDEFkey);
424 }
425 if ($displayConditionResult) {
426 $fakePA = array();
427 $fakePA['fieldConf'] = array(
428 'label' => $this->formEngine->sL(trim($value['TCEforms']['label'])),
429 'config' => $value['TCEforms']['config'],
430 'defaultExtras' => $value['TCEforms']['defaultExtras'],
431 'onChange' => $value['TCEforms']['onChange']
432 );
433 if ($PA['_noEditDEF'] && $PA['_lang'] === 'lDEF') {
434 $fakePA['fieldConf']['config'] = array(
435 'type' => 'none',
436 'rows' => 2
437 );
438 }
439 if (
440 $fakePA['fieldConf']['onChange'] === 'reload'
441 || !empty($GLOBALS['TCA'][$table]['ctrl']['type'])
442 && (string)$key === $GLOBALS['TCA'][$table]['ctrl']['type']
443 || !empty($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'])
444 && GeneralUtility::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'], $key)
445 ) {
446 if ($this->getBackendUserAuthentication()->jsConfirmation(1)) {
447 $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
448 } else {
449 $alertMsgOnChange = 'if(TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm();}';
450 }
451 } else {
452 $alertMsgOnChange = '';
453 }
454 $fakePA['fieldChangeFunc'] = $PA['fieldChangeFunc'];
455 if (strlen($alertMsgOnChange)) {
456 $fakePA['fieldChangeFunc']['alert'] = $alertMsgOnChange;
457 }
458 $fakePA['onFocus'] = $PA['onFocus'];
459 $fakePA['label'] = $PA['label'];
460 $fakePA['itemFormElName'] = $PA['itemFormElName'] . $formPrefix . '[' . $key . '][' . $vDEFkey . ']';
461 $fakePA['itemFormElName_file'] = $PA['itemFormElName_file'] . $formPrefix . '[' . $key . '][' . $vDEFkey . ']';
462 $fakePA['itemFormElID'] = $fakePA['itemFormElName'];
463 if (isset($editData[$key][$vDEFkey])) {
464 $fakePA['itemFormElValue'] = $editData[$key][$vDEFkey];
465 } else {
466 $fakePA['itemFormElValue'] = $fakePA['fieldConf']['config']['default'];
467 }
468 $theFormEl = $this->formEngine->getSingleField_SW($table, $field, $row, $fakePA);
469 $theTitle = htmlspecialchars($fakePA['fieldConf']['label']);
470 if (!in_array('DEF', $rotateLang)) {
471 $defInfo = '<div class="t3-form-original-language">'
472 . $this->formEngine->getLanguageIcon($table, $row, 0)
473 . $this->formEngine->previewFieldValue($editData[$key]['vDEF'], $fakePA['fieldConf'], $field)
474 . '&nbsp;</div>';
475 } else {
476 $defInfo = '';
477 }
478 if (!$PA['_noEditDEF']) {
479 $prLang = $this->formEngine->getAdditionalPreviewLanguages();
480 foreach ($prLang as $prL) {
481 $defInfo .= '<div class="t3-form-original-language">'
482 . $this->formEngine->getLanguageIcon($table, $row, ('v' . $prL['ISOcode']))
483 . $this->formEngine->previewFieldValue($editData[$key][('v' . $prL['ISOcode'])], $fakePA['fieldConf'], $field)
484 . '&nbsp;</div>';
485 }
486 }
487 $languageIcon = '';
488 if ($vDEFkey != 'vDEF') {
489 $languageIcon = $this->formEngine->getLanguageIcon($table, $row, $vDEFkey);
490 }
491 // Put row together
492 // possible linebreaks in the label through xml: \n => <br/>, usage of nl2br()
493 // not possible, so it's done through str_replace
494 $processedTitle = str_replace('\\n', '<br />', $theTitle);
495 $tRows[] = '<div class="t3-form-field-container t3-form-field-container-flex">'
496 . '<div class="t3-form-field-label t3-form-field-label-flex">' . $languageIcon
497 . BackendUtility::wrapInHelp($PA['_cshKey'], $key, $processedTitle) . '</div>
498 <div class="t3-form-field t3-form-field-flex">' . $theFormEl . $defInfo
499 . $this->formEngine->renderVDEFDiff($editData[$key], $vDEFkey) . '</div>
500 </div>';
501 }
502 }
503 if (count($tRows)) {
504 $output .= implode('', $tRows);
505 }
506 }
507 }
508 }
509 }
510 return $output;
511 }
512 }