Commit e445a103 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[TASK] FormEngine: Simplify element name resolving

Data submitted by FormEngine to DataHandler is prefixed in four
different ways:
* data - Transferred data
* cmd - A dataHandler command to execute
* data_files - Contains uploaded files
* action[control] - Overwrite fields data for NULL handling

These four prefixes are given along from FormEngine to the
whole container and element structure and never change.

To simplify this stuff, the patch removes the prefixes and
hardcodes them, and introduces a new globalOptions
$elementBaseName that contains the stuff behind the prefixes.
Quite some methods can be simplified this way and become
more obvious. Usage of $elementBaseName will be extended
with the next patch.

Change-Id: I8103b1d2068382e0b01bbe5d9bd79aeba2d00b08
Resolves: #66894
Releases: master
Reviewed-on: http://review.typo3.org/39462

Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 3480cf1a
...@@ -137,7 +137,7 @@ abstract class AbstractNode { ...@@ -137,7 +137,7 @@ abstract class AbstractNode {
/** @var FormDataTraverser $traverser */ /** @var FormDataTraverser $traverser */
$traverseFields = GeneralUtility::trimExplode('|', substr($value, 6)); $traverseFields = GeneralUtility::trimExplode('|', substr($value, 6));
$traverser = GeneralUtility::makeInstance(FormDataTraverser::class); $traverser = GeneralUtility::makeInstance(FormDataTraverser::class);
$value = $traverser->getTraversedFieldValue($traverseFields, $table, $row, $this->globalOptions['inlineFirstPid'], $this->globalOptions['prependFormFieldNames']); $value = $traverser->getTraversedFieldValue($traverseFields, $table, $row, $this->globalOptions['inlineFirstPid']);
} }
return $value; return $value;
......
...@@ -136,7 +136,6 @@ class FlexFormElementContainer extends AbstractContainer { ...@@ -136,7 +136,6 @@ class FlexFormElementContainer extends AbstractContainer {
$fakeParameterArray['onFocus'] = $parameterArray['onFocus']; $fakeParameterArray['onFocus'] = $parameterArray['onFocus'];
$fakeParameterArray['label'] = $parameterArray['label']; $fakeParameterArray['label'] = $parameterArray['label'];
$fakeParameterArray['itemFormElName'] = $parameterArray['itemFormElName'] . $flexFormFormPrefix . '[' . $flexFormFieldName . '][' . $vDEFkey . ']'; $fakeParameterArray['itemFormElName'] = $parameterArray['itemFormElName'] . $flexFormFormPrefix . '[' . $flexFormFieldName . '][' . $vDEFkey . ']';
$fakeParameterArray['itemFormElName_file'] = $parameterArray['itemFormElName_file'] . $flexFormFormPrefix . '[' . $flexFormFieldName . '][' . $vDEFkey . ']';
$fakeParameterArray['itemFormElID'] = $fakeParameterArray['itemFormElName']; $fakeParameterArray['itemFormElID'] = $fakeParameterArray['itemFormElName'];
if (isset($flexFormRowData[$flexFormFieldName][$vDEFkey])) { if (isset($flexFormRowData[$flexFormFieldName][$vDEFkey])) {
$fakeParameterArray['itemFormElValue'] = $flexFormRowData[$flexFormFieldName][$vDEFkey]; $fakeParameterArray['itemFormElValue'] = $flexFormRowData[$flexFormFieldName][$vDEFkey];
...@@ -146,6 +145,7 @@ class FlexFormElementContainer extends AbstractContainer { ...@@ -146,6 +145,7 @@ class FlexFormElementContainer extends AbstractContainer {
$options = $this->globalOptions; $options = $this->globalOptions;
$options['parameterArray'] = $fakeParameterArray; $options['parameterArray'] = $fakeParameterArray;
$options['elementBaseName'] = $this->globalOptions['elementBaseName'] . $flexFormFormPrefix . '[' . $flexFormFieldName . '][' . $vDEFkey . ']';
/** @var NodeFactory $nodeFactory */ /** @var NodeFactory $nodeFactory */
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class); $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
$child = $nodeFactory->create($flexFormFieldArray['TCEforms']['config']['type']); $child = $nodeFactory->create($flexFormFieldArray['TCEforms']['config']['type']);
......
...@@ -111,7 +111,7 @@ class InlineControlContainer extends AbstractContainer { ...@@ -111,7 +111,7 @@ class InlineControlContainer extends AbstractContainer {
); );
// Extract FlexForm parts (if any) from element name, e.g. array('vDEF', 'lDEF', 'FlexField', 'vDEF') // Extract FlexForm parts (if any) from element name, e.g. array('vDEF', 'lDEF', 'FlexField', 'vDEF')
if (!empty($parameterArray['itemFormElName'])) { if (!empty($parameterArray['itemFormElName'])) {
$flexFormParts = FormEngineUtility::extractFlexFormParts($parameterArray['itemFormElName'], $this->globalOptions['prependFormFieldNames']); $flexFormParts = FormEngineUtility::extractFlexFormParts($parameterArray['itemFormElName']);
if ($flexFormParts !== NULL) { if ($flexFormParts !== NULL) {
$newStructureItem['flexform'] = $flexFormParts; $newStructureItem['flexform'] = $flexFormParts;
} }
...@@ -119,13 +119,13 @@ class InlineControlContainer extends AbstractContainer { ...@@ -119,13 +119,13 @@ class InlineControlContainer extends AbstractContainer {
$inlineStackProcessor->pushStableStructureItem($newStructureItem); $inlineStackProcessor->pushStableStructureItem($newStructureItem);
// e.g. data[<table>][<uid>][<field>] // e.g. data[<table>][<uid>][<field>]
$nameForm = $inlineStackProcessor->getCurrentStructureFormPrefix($this->globalOptions['prependFormFieldNames']); $nameForm = $inlineStackProcessor->getCurrentStructureFormPrefix();
// e.g. data-<pid>-<table1>-<uid1>-<field1>-<table2>-<uid2>-<field2> // e.g. data-<pid>-<table1>-<uid1>-<field1>-<table2>-<uid2>-<field2>
$nameObject = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->globalOptions['inlineFirstPid']); $nameObject = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->globalOptions['inlineFirstPid']);
// Get the records related to this inline record // Get the records related to this inline record
$inlineRelatedRecordResolver = GeneralUtility::makeInstance(InlineRelatedRecordResolver::class); $inlineRelatedRecordResolver = GeneralUtility::makeInstance(InlineRelatedRecordResolver::class);
$relatedRecords = $inlineRelatedRecordResolver->getRelatedRecords($table, $field, $row, $parameterArray, $config, $this->globalOptions['inlineFirstPid'], $this->globalOptions['prependFormFieldNames']); $relatedRecords = $inlineRelatedRecordResolver->getRelatedRecords($table, $field, $row, $parameterArray, $config, $this->globalOptions['inlineFirstPid']);
// Set the first and last record to the config array // Set the first and last record to the config array
$relatedRecordsUids = array_keys($relatedRecords['records']); $relatedRecordsUids = array_keys($relatedRecords['records']);
......
...@@ -89,7 +89,7 @@ class InlineRecordContainer extends AbstractContainer { ...@@ -89,7 +89,7 @@ class InlineRecordContainer extends AbstractContainer {
// Send a mapping information to the browser via JSON: // Send a mapping information to the browser via JSON:
// e.g. data[<curTable>][<curId>][<curField>] => data-<pid>-<parentTable>-<parentId>-<parentField>-<curTable>-<curId>-<curField> // e.g. data[<curTable>][<curId>][<curField>] => data-<pid>-<parentTable>-<parentId>-<parentField>-<curTable>-<curId>-<curField>
$formPrefix = $inlineStackProcessor->getCurrentStructureFormPrefix($this->globalOptions['prependFormFieldNames']); $formPrefix = $inlineStackProcessor->getCurrentStructureFormPrefix();
$domObjectId = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->globalOptions['inlineFirstPid']); $domObjectId = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->globalOptions['inlineFirstPid']);
$this->inlineData['map'][$formPrefix] = $domObjectId; $this->inlineData['map'][$formPrefix] = $domObjectId;
...@@ -151,18 +151,18 @@ class InlineRecordContainer extends AbstractContainer { ...@@ -151,18 +151,18 @@ class InlineRecordContainer extends AbstractContainer {
$top = $this->inlineStackProcessor->getStructureLevel(0); $top = $this->inlineStackProcessor->getStructureLevel(0);
$ucFieldName = 'uc[inlineView][' . $top['table'] . '][' . $top['uid'] . ']' . $appendFormFieldNames; $ucFieldName = 'uc[inlineView][' . $top['table'] . '][' . $top['uid'] . ']' . $appendFormFieldNames;
// Set additional fields for processing for saving // Set additional fields for processing for saving
$html .= '<input type="hidden" name="' . $this->globalOptions['prependFormFieldNames'] . $appendFormFieldNames . '[pid]" value="' . $record['pid'] . '"/>'; $html .= '<input type="hidden" name="data' . $appendFormFieldNames . '[pid]" value="' . $record['pid'] . '"/>';
$html .= '<input type="hidden" name="' . $ucFieldName . '" value="' . $isExpanded . '" />'; $html .= '<input type="hidden" name="' . $ucFieldName . '" value="' . $isExpanded . '" />';
} else { } else {
// Set additional field for processing for saving // Set additional field for processing for saving
$html .= '<input type="hidden" name="' . $this->globalOptions['prependCmdFieldNames'] . $appendFormFieldNames . '[delete]" value="1" disabled="disabled" />'; $html .= '<input type="hidden" name="cmd' . $appendFormFieldNames . '[delete]" value="1" disabled="disabled" />';
if (!$isExpanded if (!$isExpanded
&& !empty($GLOBALS['TCA'][$foreign_table]['ctrl']['enablecolumns']['disabled']) && !empty($GLOBALS['TCA'][$foreign_table]['ctrl']['enablecolumns']['disabled'])
&& $ajaxLoad && $ajaxLoad
) { ) {
$checked = !empty($record['hidden']) ? ' checked="checked"' : ''; $checked = !empty($record['hidden']) ? ' checked="checked"' : '';
$html .= '<input type="checkbox" name="' . $this->globalOptions['prependFormFieldNames'] . $appendFormFieldNames . '[hidden]_0" value="1"' . $checked . ' />'; $html .= '<input type="checkbox" name="data' . $appendFormFieldNames . '[hidden]_0" value="1"' . $checked . ' />';
$html .= '<input type="input" name="' . $this->globalOptions['prependFormFieldNames'] . $appendFormFieldNames . '[hidden]" value="' . $record['hidden'] . '" />'; $html .= '<input type="input" name="data' . $appendFormFieldNames . '[hidden]" value="' . $record['hidden'] . '" />';
} }
} }
// If this record should be shown collapsed // If this record should be shown collapsed
...@@ -264,12 +264,12 @@ class InlineRecordContainer extends AbstractContainer { ...@@ -264,12 +264,12 @@ class InlineRecordContainer extends AbstractContainer {
// If this is a new record, add a pid value to store this record and the pointer value for the intermediate table // If this is a new record, add a pid value to store this record and the pointer value for the intermediate table
if ($isNewRecord) { if ($isNewRecord) {
$comboFormFieldName = $this->globalOptions['prependFormFieldNames'] . '[' . $comboConfig['foreign_table'] . '][' . $comboRecord['uid'] . '][pid]'; $comboFormFieldName = 'data[' . $comboConfig['foreign_table'] . '][' . $comboRecord['uid'] . '][pid]';
$resultArray['html'] .= '<input type="hidden" name="' . $comboFormFieldName . '" value="' . $comboRecord['pid'] . '" />'; $resultArray['html'] .= '<input type="hidden" name="' . $comboFormFieldName . '" value="' . $comboRecord['pid'] . '" />';
} }
// If the foreign_selector field is also responsible for uniqueness, tell the browser the uid of the "other" side of the relation // If the foreign_selector field is also responsible for uniqueness, tell the browser the uid of the "other" side of the relation
if ($isNewRecord || $config['foreign_unique'] === $foreign_selector) { if ($isNewRecord || $config['foreign_unique'] === $foreign_selector) {
$parentFormFieldName = $this->globalOptions['prependFormFieldNames'] . $appendFormFieldNames . '[' . $foreign_selector . ']'; $parentFormFieldName = 'data' . $appendFormFieldNames . '[' . $foreign_selector . ']';
$resultArray['html'] .= '<input type="hidden" name="' . $parentFormFieldName . '" value="' . $comboRecord['uid'] . '" />'; $resultArray['html'] .= '<input type="hidden" name="' . $parentFormFieldName . '" value="' . $comboRecord['uid'] . '" />';
} }
} }
......
...@@ -89,10 +89,9 @@ class SingleFieldContainer extends AbstractContainer { ...@@ -89,10 +89,9 @@ class SingleFieldContainer extends AbstractContainer {
// Override fieldConf by fieldTSconfig: // Override fieldConf by fieldTSconfig:
$parameterArray['fieldConf']['config'] = FormEngineUtility::overrideFieldConf($parameterArray['fieldConf']['config'], $parameterArray['fieldTSConfig']); $parameterArray['fieldConf']['config'] = FormEngineUtility::overrideFieldConf($parameterArray['fieldConf']['config'], $parameterArray['fieldTSConfig']);
$parameterArray['itemFormElName'] = $this->globalOptions['prependFormFieldNames'] . '[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'; $parameterArray['itemFormElName'] = 'data[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']';
// Form field name, in case of file uploads $parameterArray['itemFormElID'] = 'data_' . $table . '_' . $row['uid'] . '_' . $fieldName;
$parameterArray['itemFormElName_file'] = $this->globalOptions['prependFormFieldNames_file'] . '[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'; $newElementBaseName = $this->globalOptions['elementBaseName'] . '[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']';
$parameterArray['itemFormElID'] = $this->globalOptions['prependFormFieldNames'] . '_' . $table . '_' . $row['uid'] . '_' . $fieldName;
// The value to show in the form field. // The value to show in the form field.
$parameterArray['itemFormElValue'] = $row[$fieldName]; $parameterArray['itemFormElValue'] = $row[$fieldName];
...@@ -160,6 +159,7 @@ class SingleFieldContainer extends AbstractContainer { ...@@ -160,6 +159,7 @@ class SingleFieldContainer extends AbstractContainer {
// Based on the type of the item, call a render function on a child element // Based on the type of the item, call a render function on a child element
$options = $this->globalOptions; $options = $this->globalOptions;
$options['parameterArray'] = $parameterArray; $options['parameterArray'] = $parameterArray;
$options['elementBaseName'] = $newElementBaseName;
/** @var NodeFactory $childFactory */ /** @var NodeFactory $childFactory */
$childFactory = GeneralUtility::makeInstance(NodeFactory::class); $childFactory = GeneralUtility::makeInstance(NodeFactory::class);
$childElement = $childFactory->create($parameterArray['fieldConf']['config']['type']); $childElement = $childFactory->create($parameterArray['fieldConf']['config']['type']);
...@@ -208,7 +208,7 @@ class SingleFieldContainer extends AbstractContainer { ...@@ -208,7 +208,7 @@ class SingleFieldContainer extends AbstractContainer {
$checked = ''; $checked = '';
} }
$formElementName = $this->globalOptions['prependFormFieldNames'] . '[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'; $formElementName = 'data[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']';
$onChange = htmlspecialchars( $onChange = htmlspecialchars(
'typo3form.fieldSetNull(' . GeneralUtility::quoteJSvalue($formElementName) . ', !this.checked)' 'typo3form.fieldSetNull(' . GeneralUtility::quoteJSvalue($formElementName) . ', !this.checked)'
); );
......
...@@ -218,7 +218,7 @@ class GroupElement extends AbstractFormElement { ...@@ -218,7 +218,7 @@ class GroupElement extends AbstractFormElement {
$html .= ' $html .= '
<div id="' . $parameterArray['itemFormElID_file'] . '"> <div id="' . $parameterArray['itemFormElID_file'] . '">
<input type="file"' . $multipleAttribute . ' <input type="file"' . $multipleAttribute . '
name="' . $parameterArray['itemFormElName_file'] . $multipleFilenameSuffix . '" name="data_files' . $this->globalOptions['elementBaseName'] . $multipleFilenameSuffix . '"
size="35" onchange="' . implode('', $parameterArray['fieldChangeFunc']) . '" size="35" onchange="' . implode('', $parameterArray['fieldChangeFunc']) . '"
/> />
</div>'; </div>';
......
...@@ -424,7 +424,7 @@ class SelectElement extends AbstractFormElement { ...@@ -424,7 +424,7 @@ class SelectElement extends AbstractFormElement {
$uniqueIds = NULL; $uniqueIds = NULL;
if (is_array($inlineParent) && $inlineParent['uid']) { if (is_array($inlineParent) && $inlineParent['uid']) {
$inlineObjectName = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->globalOptions['inlineFirstPid']); $inlineObjectName = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->globalOptions['inlineFirstPid']);
$inlineFormName = $inlineStackProcessor->getCurrentStructureFormPrefix($this->globalOptions['prependFormFieldNames']); $inlineFormName = $inlineStackProcessor->getCurrentStructureFormPrefix();
if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) { if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
$uniqueIds = $this->globalOptions['inlineData']['unique'][$inlineObjectName . '-' . $table]['used']; $uniqueIds = $this->globalOptions['inlineData']['unique'][$inlineObjectName . '-' . $table]['used'];
$PA['fieldChangeFunc']['inlineUnique'] = 'inline.updateUnique(this,\'' . $inlineObjectName $PA['fieldChangeFunc']['inlineUnique'] = 'inline.updateUnique(this,\'' . $inlineObjectName
......
...@@ -70,13 +70,6 @@ class FormDataTraverser { ...@@ -70,13 +70,6 @@ class FormDataTraverser {
*/ */
protected $inlineFirstPid; protected $inlineFirstPid;
/**
* General prefix of forms
*
* @var string
*/
protected $prependFormFieldNames;
/** /**
* Traverses the array of given field names by using the TCA. * Traverses the array of given field names by using the TCA.
* *
...@@ -84,14 +77,12 @@ class FormDataTraverser { ...@@ -84,14 +77,12 @@ class FormDataTraverser {
* @param string $tableName The starting table name. * @param string $tableName The starting table name.
* @param array $row The starting record row. * @param array $row The starting record row.
* @param int $inlineFirstPid Inline first pid * @param int $inlineFirstPid Inline first pid
* @param string $prependFormFieldNames General prefix of forms
* @return mixed The value of the last field in the chain. * @return mixed The value of the last field in the chain.
*/ */
public function getTraversedFieldValue(array $fieldNameArray, $tableName, array $row, $inlineFirstPid, $prependFormFieldNames) { public function getTraversedFieldValue(array $fieldNameArray, $tableName, array $row, $inlineFirstPid) {
$this->currentTable = $tableName; $this->currentTable = $tableName;
$this->currentRow = $row; $this->currentRow = $row;
$this->inlineFirstPid = $inlineFirstPid; $this->inlineFirstPid = $inlineFirstPid;
$this->prependFormFieldNames = $prependFormFieldNames;
$fieldValue = ''; $fieldValue = '';
if (count($fieldNameArray) > 0) { if (count($fieldNameArray) > 0) {
$this->initializeOriginalLanguageUid(); $this->initializeOriginalLanguageUid();
...@@ -244,7 +235,7 @@ class FormDataTraverser { ...@@ -244,7 +235,7 @@ class FormDataTraverser {
$PA = array('itemFormElValue' => $value); $PA = array('itemFormElValue' => $value);
$inlineRelatedRecordResolver = GeneralUtility::makeInstance(InlineRelatedRecordResolver::class); $inlineRelatedRecordResolver = GeneralUtility::makeInstance(InlineRelatedRecordResolver::class);
$items = $inlineRelatedRecordResolver->getRelatedRecords($this->currentTable, $fieldName, $this->currentRow, $PA, $fieldConfig, $this->inlineFirstPid, $this->prependFormFieldNames); $items = $inlineRelatedRecordResolver->getRelatedRecords($this->currentTable, $fieldName, $this->currentRow, $PA, $fieldConfig, $this->inlineFirstPid);
if ($items['count'] > 0) { if ($items['count'] > 0) {
$this->currentTable = $fieldConfig['foreign_table']; $this->currentTable = $fieldConfig['foreign_table'];
foreach ($items['records'] as $inlineRecord) { foreach ($items['records'] as $inlineRecord) {
......
...@@ -114,28 +114,6 @@ class FormEngine { ...@@ -114,28 +114,6 @@ class FormEngine {
*/ */
protected $renderReadonly = FALSE; protected $renderReadonly = FALSE;
// INTERNAL, static
/**
* The string to prepend formfield names with.
*
* @var string
*/
public $prependFormFieldNames = 'data';
/**
* The string to prepend commands for tcemain::process_cmdmap with
*
* @var string
*/
public $prependCmdFieldNames = 'cmd';
/**
* The string to prepend FILE form field names with
*
* @var string
*/
public $prependFormFieldNames_file = 'data_files';
/** /**
* @var InlineStackProcessor * @var InlineStackProcessor
*/ */
...@@ -452,9 +430,7 @@ class FormEngine { ...@@ -452,9 +430,7 @@ class FormEngine {
'databaseRow' => $this->databaseRow, 'databaseRow' => $this->databaseRow,
'additionalPreviewLanguages' => $this->additionalPreviewLanguages, 'additionalPreviewLanguages' => $this->additionalPreviewLanguages,
'localizationMode' => $this->localizationMode, // @todo: find out the details, Warning, this overlaps with inline behaviour localizationMode 'localizationMode' => $this->localizationMode, // @todo: find out the details, Warning, this overlaps with inline behaviour localizationMode
'prependFormFieldNames' => $this->prependFormFieldNames, 'elementBaseName' => '',
'prependFormFieldNames_file' => $this->prependFormFieldNames_file,
'prependCmdFieldNames' => $this->prependCmdFieldNames,
'tabAndInlineStack' => array(), 'tabAndInlineStack' => array(),
'inlineFirstPid' => $this->getInlineFirstPid(), 'inlineFirstPid' => $this->getInlineFirstPid(),
'inlineExpandCollapseStateArray' => $this->getInlineExpandCollapseStateArrayForTableUid($this->table, $this->databaseRow['uid']), 'inlineExpandCollapseStateArray' => $this->getInlineExpandCollapseStateArrayForTableUid($this->table, $this->databaseRow['uid']),
...@@ -1358,7 +1334,6 @@ class FormEngine { ...@@ -1358,7 +1334,6 @@ class FormEngine {
// We want to load jQuery-ui inside our js. Enable this using requirejs. // We want to load jQuery-ui inside our js. Enable this using requirejs.
$this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js'); $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js');
$out .= ' $out .= '
inline.setPrependFormFieldNames("data");
inline.setNoTitleString("' . addslashes(BackendUtility::getNoRecordTitle(TRUE)) . '"); inline.setNoTitleString("' . addslashes(BackendUtility::getNoRecordTitle(TRUE)) . '");
'; ';
...@@ -1369,9 +1344,6 @@ class FormEngine { ...@@ -1369,9 +1344,6 @@ class FormEngine {
TBE_EDITOR.formname = "' . $formname . '"; TBE_EDITOR.formname = "' . $formname . '";
TBE_EDITOR.formnameUENC = "' . rawurlencode($formname) . '"; TBE_EDITOR.formnameUENC = "' . rawurlencode($formname) . '";
TBE_EDITOR.backPath = ""; TBE_EDITOR.backPath = "";
TBE_EDITOR.prependFormFieldNames = "' . $this->prependFormFieldNames . '";
TBE_EDITOR.prependFormFieldNamesUENC = "' . rawurlencode($this->prependFormFieldNames) . '";
TBE_EDITOR.prependFormFieldNamesCnt = ' . substr_count($this->prependFormFieldNames, '[') . ';
TBE_EDITOR.isPalettedoc = null; TBE_EDITOR.isPalettedoc = null;
TBE_EDITOR.doSaveFieldName = "' . ($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '') . '"; TBE_EDITOR.doSaveFieldName = "' . ($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '') . '";
TBE_EDITOR.labels.fieldsChanged = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsChanged')) . '; TBE_EDITOR.labels.fieldsChanged = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsChanged')) . ';
......
...@@ -40,10 +40,9 @@ class InlineRelatedRecordResolver { ...@@ -40,10 +40,9 @@ class InlineRelatedRecordResolver {
* @param array $PA An array with additional configuration options. * @param array $PA An array with additional configuration options.
* @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience) * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
* @param integer $inlineFirstPid Inline first pid * @param integer $inlineFirstPid Inline first pid
* @param string $prependFormFieldNames General prefix of forms
* @return array The records related to the parent item as associative array. * @return array The records related to the parent item as associative array.
*/ */
public function getRelatedRecords($table, $field, $row, $PA, $config, $inlineFirstPid, $prependFormFieldNames) { public function getRelatedRecords($table, $field, $row, $PA, $config, $inlineFirstPid) {
$language = 0; $language = 0;
$elements = $PA['itemFormElValue']; $elements = $PA['itemFormElValue'];
$foreignTable = $config['foreign_table']; $foreignTable = $config['foreign_table'];
...@@ -64,7 +63,7 @@ class InlineRelatedRecordResolver { ...@@ -64,7 +63,7 @@ class InlineRelatedRecordResolver {
// Checks if it is a flexform field // Checks if it is a flexform field
if ($GLOBALS['TCA'][$table]['columns'][$field]['config']['type'] === 'flex') { if ($GLOBALS['TCA'][$table]['columns'][$field]['config']['type'] === 'flex') {
$flexFormParts = FormEngineUtility::extractFlexFormParts($PA['itemFormElName'], $prependFormFieldNames); $flexFormParts = FormEngineUtility::extractFlexFormParts($PA['itemFormElName']);
$flexData = GeneralUtility::xml2array($fieldValue); $flexData = GeneralUtility::xml2array($fieldValue);
/** @var $flexFormTools FlexFormTools */ /** @var $flexFormTools FlexFormTools */
$flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class); $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
......
...@@ -150,15 +150,14 @@ class InlineStackProcessor { ...@@ -150,15 +150,14 @@ class InlineStackProcessor {
/** /**
* Prefix for inline form fields * Prefix for inline form fields
* *
* @param string $prependFormFieldNames General prefix of forms
* @return string * @return string
*/ */
public function getCurrentStructureFormPrefix($prependFormFieldNames) { public function getCurrentStructureFormPrefix() {
$current = $this->getStructureLevel(-1); $current = $this->getStructureLevel(-1);
$inlineFormName = ''; $inlineFormName = '';
// If there are still more inline levels available // If there are still more inline levels available
if ($current !== FALSE) { if ($current !== FALSE) {
$inlineFormName = $prependFormFieldNames . $this->getStructureItemName($current, 'Disposal_AttributeName'); $inlineFormName = 'data' . $this->getStructureItemName($current, 'Disposal_AttributeName');
} }
return $inlineFormName; return $inlineFormName;
} }
......
...@@ -546,17 +546,15 @@ class FormEngineUtility { ...@@ -546,17 +546,15 @@ class FormEngineUtility {
* Helper method used in inline * Helper method used in inline
* *
* @param string $formElementName The form element name * @param string $formElementName The form element name
* @param string $prependFormFieldNames Prepended form field name
* @return array|NULL * @return array|NULL
* @internal * @internal
*/ */
static public function extractFlexFormParts($formElementName, $prependFormFieldNames) { static public function extractFlexFormParts($formElementName) {
$flexFormParts = NULL; $flexFormParts = NULL;
$matches = array(); $matches = array();
$prefix = preg_quote($prependFormFieldNames, '#');
if (preg_match('#^' . $prefix . '(?:\[[^]]+\]){3}(\[data\](?:\[[^]]+\]){4,})$#', $formElementName, $matches)) { if (preg_match('#^data(?:\[[^]]+\]){3}(\[data\](?:\[[^]]+\]){4,})$#', $formElementName, $matches)) {
$flexFormParts = GeneralUtility::trimExplode( $flexFormParts = GeneralUtility::trimExplode(
'][', '][',
trim($matches[1], '[]') trim($matches[1], '[]')
......
...@@ -23,7 +23,6 @@ var inline = { ...@@ -23,7 +23,6 @@ var inline = {
structureSeparator: '-', structureSeparator: '-',
flexFormSeparator: '---', flexFormSeparator: '---',
flexFormSubstitute: ':', flexFormSubstitute: ':',
prependFormFieldNames: 'data',
noTitleString: '[No title]', noTitleString: '[No title]',
lockedAjaxMethod: {}, lockedAjaxMethod: {},
sourcesLoaded: {}, sourcesLoaded: {},
...@@ -38,9 +37,6 @@ var inline = { ...@@ -38,9 +37,6 @@ var inline = {
TYPO3.jQuery.extend(inline.data[key], value); TYPO3.jQuery.extend(inline.data[key], value);
}); });
}, },
setPrependFormFieldNames: function (value) {
this.prependFormFieldNames = value;
},
setNoTitleString: function (value) { setNoTitleString: function (value) {
this.noTitleString = value; this.noTitleString = value;
}, },
...@@ -117,7 +113,7 @@ var inline = { ...@@ -117,7 +113,7 @@ var inline = {
}, },
collapseAllRecords: function (objectId, objectPrefix, callingUid) { collapseAllRecords: function (objectId, objectPrefix, callingUid) {
// get the form field, where all records are stored // get the form field, where all records are stored
var objectName = this.prependFormFieldNames + this.parseObjectId('parts', objectId, 3, 2, true); var objectName = 'data' + this.parseObjectId('parts', objectId, 3, 2, true);
var formObj = document.getElementsByName(objectName); var formObj = document.getElementsByName(objectName);
var collapse = []; var collapse = [];
...@@ -431,9 +427,9 @@ var inline = { ...@@ -431,9 +427,9 @@ var inline = {
return; return;
} }
var formName = this.prependFormFieldNames + this.parseObjectId('parts', objectId, 3, 1, true); var formName = 'data' + this.parseObjectId('parts', objectId, 3, 1, true);
var formObj = document.getElementsByName(formName); var formObj = document.getElementsByName(formName);
var recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + recordUid + '][' + unique.field + ']'); var recordObj = document.getElementsByName('data[' + unique.table + '][' + recordUid + '][' + unique.field + ']');
var values = this.getValuesFromHashMap(unique.used); var values = this.getValuesFromHashMap(unique.used);
if (recordObj.length) { if (recordObj.length) {
if (recordObj[0].hasOwnProperty('options')) { if (recordObj[0].hasOwnProperty('options')) {
...@@ -458,9 +454,9 @@ var inline = { ...@@ -458,9 +454,9 @@ var inline = {
var unique = this.data.unique[objectId]; var unique = this.data.unique[objectId];
if (unique.type == 'select') { if (unique.type == 'select') {
if (!(unique.selector && unique.max == -1)) { if (!(unique.selector && unique.max == -1)) {
var formName = this.prependFormFieldNames + this.parseObjectId('parts', objectId, 3, 1, true); var formName = 'data' + this.parseObjectId('parts', objectId, 3, 1, true);
var formObj = document.getElementsByName(formName); var formObj = document.getElementsByName(formName);
var recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + recordUid + '][' + unique.field + ']'); var recordObj = document.getElementsByName('data[' + unique.table + '][' + recordUid + '][' + unique.field + ']');
var values = this.getValuesFromHashMap(unique.used); var values = this.getValuesFromHashMap(unique.used);
if ($selector.length) { if ($selector.length) {
// remove all items from the new select-item which are already used in other children // remove all items from the new select-item which are already used in other children
...@@ -489,7 +485,7 @@ var inline = { ...@@ -489,7 +485,7 @@ var inline = {
if (formObj.length && selectedValue) { if (formObj.length && selectedValue) {
var records = formObj[0].value.split(','); var records = formObj[0].value.split(',');
for (var i = 0; i < records.length; i++) { for (var i = 0; i < records.length; i++) {
recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + records[i] + '][' + unique.field + ']'); recordObj = document.getElementsByName('data[' + unique.table + '][' + records[i] + '][' + unique.field + ']');
if (recordObj.length && records[i] != recordUid) { if (recordObj.length && records[i] != recordUid) {
var $recordObject = TYPO3.jQuery(recordObj[0]); var $recordObject = TYPO3.jQuery(recordObj[0]);
this.removeSelectOption($recordObject, selectedValue); this.removeSelectOption($recordObject, selectedValue);
...@@ -617,7 +613,7 @@ var inline = { ...@@ -617,7 +613,7 @@ var inline = {
}, },
changeSorting: function (objectId, direction) { changeSorting: function (objectId, direction) {
var objectName = this.prependFormFieldNames + this.parseObjectId('parts', objectId, 3, 2, true); var objectName = 'data' + this.parseObjectId('parts', objectId, 3, 2, true);
var objectPrefix = this.parseObjectId('full', objectId, 0, 1);