[BUGFIX] Prevent double dots in data-table string for csh
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / Container / FlexFormNoTabsContainer.php
1 <?php
2 namespace TYPO3\CMS\Backend\Form\Container;
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\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Backend\Form\NodeFactory;
19
20 /**
21 * Handle a flex form that has no tabs.
22 *
23 * This container is called by FlexFormLanguageContainer if only a default sheet
24 * exists. It evaluates the display condition and hands over rendering of single
25 * fields to FlexFormElementContainer.
26 */
27 class FlexFormNoTabsContainer extends AbstractContainer {
28
29 /**
30 * Entry method
31 *
32 * @return array As defined in initializeResultArray() of AbstractNode
33 */
34 public function render() {
35 $table = $this->globalOptions['table'];
36 $row = $this->globalOptions['databaseRow'];
37 $fieldName = $this->globalOptions['fieldName']; // field name of the flex form field in DB
38 $parameterArray = $this->globalOptions['parameterArray'];
39 $flexFormDataStructureArray = $this->globalOptions['flexFormDataStructureArray'];
40 $flexFormSheetNameInRowData = 'sDEF';
41 $flexFormCurrentLanguage = $this->globalOptions['flexFormCurrentLanguage'];
42 $flexFormRowData = $this->globalOptions['flexFormRowData'];
43 $flexFormRowDataSubPart = $flexFormRowData['data'][$flexFormSheetNameInRowData][$flexFormCurrentLanguage];
44 $resultArray = $this->initializeResultArray();
45
46 // That was taken from GeneralUtility::resolveSheetDefInDS - no idea if it is important
47 unset($flexFormDataStructureArray['meta']);
48
49 // Evaluate display condition for this "sheet" if there is one
50 $displayConditionResult = TRUE;
51 if (!empty($flexFormDataStructureArray['ROOT']['TCEforms']['displayCond'])) {
52 $displayConditionDefinition = $flexFormDataStructureArray['ROOT']['TCEforms']['displayCond'];
53 $displayConditionResult = $this->evaluateFlexFormDisplayCondition(
54 $displayConditionDefinition,
55 $flexFormRowDataSubPart
56 );
57 }
58 if (!$displayConditionResult) {
59 return $resultArray;
60 }
61
62 if (!is_array($flexFormDataStructureArray['ROOT']['el'])) {
63 $resultArray['html'] = 'Data Structure ERROR: No [\'ROOT\'][\'el\'] element found in flex form definition.';
64 return $resultArray;
65 }
66
67 // Assemble key for loading the correct CSH file
68 // @todo: what is that good for? That is for the title of single elements ... see FlexFormElementContainer!
69 $dsPointerFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['ds_pointerField'], TRUE);
70 $parameterArray['_cshKey'] = $table . '.' . $fieldName;
71 foreach ($dsPointerFields as $key) {
72 if ((string)$row[$key] !== '') {
73 $parameterArray['_cshKey'] .= '.' . $row[$key];
74 }
75 }
76
77 $options = $this->globalOptions;
78 $options['flexFormDataStructureArray'] = $flexFormDataStructureArray['ROOT']['el'];
79 $options['flexFormRowData'] = $flexFormRowDataSubPart;
80 $options['flexFormFormPrefix'] = '[data][' . $flexFormSheetNameInRowData . '][' . $flexFormCurrentLanguage . ']';
81 $options['parameterArray'] = $parameterArray;
82
83 $options['renderType'] = 'flexFormElementContainer';
84 /** @var NodeFactory $nodeFactory */
85 $nodeFactory = $this->globalOptions['nodeFactory'];
86 return $nodeFactory->create($options)->render();
87 }
88
89 }