Index: t3lib/class.t3lib_tceforms_inline.php =================================================================== --- t3lib/class.t3lib_tceforms_inline.php (revision 6751) +++ t3lib/class.t3lib_tceforms_inline.php (working copy) @@ -390,17 +390,33 @@ // Put the current level also to the dynNestedStack of TCEforms: $this->fObj->pushToDynNestedStack('inline', $objectId); - $header = $this->renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord); if (!$isVirtualRecord) { - $combination = $this->renderCombinationTable($rec, $appendFormFieldNames, $config); - $fields = $this->renderMainFields($foreign_table, $rec); - $fields = $this->wrapFormsSection($fields); // Get configuration: $collapseAll = (isset($config['appearance']['collapseAll']) && $config['appearance']['collapseAll']); + $ajaxLoad = (isset($config['appearance']['ajaxLoad']) && !$config['appearance']['ajaxLoad']) ? false : true; if ($isNewRecord) { // show this record expanded or collapsed $isExpanded = (!$collapseAll ? 1 : 0); + } else { + $isExpanded = ($config['renderFieldsOnly'] || (!$collapseAll && $this->getExpandedCollapsedState($foreign_table, $rec['uid']))); + } + // Render full content ONLY IF this is a AJAX-request, a new record, the record is not collapsed or AJAX-loading is explicitly turned off + if ($isNewRecord || $isExpanded || !$ajaxLoad) { + $combination = $this->renderCombinationTable($rec, $appendFormFieldNames, $config); + $fields = $this->renderMainFields($foreign_table, $rec); + $fields = $this->wrapFormsSection($fields); + // Replace returnUrl in Wizard-Code, if this is an AJAX call + $ajaxArguments = t3lib_div::_GP('ajax'); + if (isset($ajaxArguments[2]) && trim($ajaxArguments[2]) != '') { + $fields = str_replace('P[returnUrl]=%2Ftypo3%2Fajax.php', 'P[returnUrl]=' . rawurlencode($ajaxArguments[2]), $fields); + } + } else { + $combination = ''; + // This string is the marker for the JS-function to check if the full content has already been loaded + $fields = ''; + } + if ($isNewRecord) { // get the top parent table $top = $this->getStructureLevel(0); $ucFieldName = 'uc[inlineView]['.$top['table'].']['.$top['uid'].']'.$appendFormFieldNames; @@ -408,8 +424,6 @@ $fields .= ''; $fields .= ''; } else { - // show this record expanded or collapsed - $isExpanded = (!$collapseAll && $this->getExpandedCollapsedState($foreign_table, $rec['uid'])); // set additional field for processing for saving $fields .= ''; } @@ -421,13 +435,15 @@ } // set the record container with data for output - $out = '
' . $header . '
'; - $out .= '
' . $fields.$combination . '
'; - // wrap the header, fields and combination part of a child record with a div container - $classMSIE = ($this->fObj->clientInfo['BROWSER']=='msie' && $this->fObj->clientInfo['VERSION'] < 8 ? 'MSIE' : ''); - $class = 'inlineDiv' . $classMSIE . ($isNewRecord ? ' inlineIsNewRecord' : ''); - $out = '
' . $out . '
'; - + $out = '
' . $fields.$combination . '
'; + if (!$config['renderFieldsOnly']) { + $header = $this->renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord); + $out = '
' . $header . '
' . $out; + // wrap the header, fields and combination part of a child record with a div container + $classMSIE = ($this->fObj->clientInfo['BROWSER']=='msie' && $this->fObj->clientInfo['VERSION'] < 8 ? 'MSIE' : ''); + $class = 'inlineDiv' . $classMSIE . ($isNewRecord ? ' inlineIsNewRecord' : ''); + $out = '
' . $out . '
'; + } // Remove the current level also from the dynNestedStack of TCEforms: $this->fObj->popFromDynNestedStack(); @@ -474,7 +490,8 @@ // Init: $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid']; $expandSingle = $config['appearance']['expandSingle'] ? 1 : 0; - $onClick = "return inline.expandCollapseRecord('" . htmlspecialchars($objectId) . "', $expandSingle)"; + // we need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter) + $onClick = "return inline.expandCollapseRecord('" . htmlspecialchars($objectId) . "', $expandSingle, '" . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "')"; // Pre-Processing: $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec); @@ -969,6 +986,7 @@ switch ($ajaxMethod) { case 'createNewRecord': case 'synchronizeLocalizeRecords': + case 'getRecordDetails': $this->isAjaxCall = true; // Construct runtime environment for Inline Relational Record Editing: $this->processAjaxRequestConstruct($ajaxArguments); @@ -1204,8 +1222,69 @@ // Return the JSON array: return $jsonArray; } + + /** + * Handle AJAX calls to dynamically load the form fields of a given record. + * (basically a copy of "createNewRecord") + * Normally this method is never called from inside TYPO3. Always from outside by AJAX. + * + * @param string $domObjectId: The calling object in hierarchy, that requested a new record. + * @return array An array to be used for JSON + */ + function getRecordDetails($domObjectId) { + // the current table - for this table we should add/import records + $current = $this->inlineStructure['unstable']; + // the parent table - this table embeds the current table + $parent = $this->getStructureLevel(-1); + // get TCA 'config' of the parent table + if (!$this->checkConfiguration($parent['config'])) { + return $this->getErrorMessageForAJAX('Wrong configuration in table ' . $parent['table']); + } + $config = $parent['config']; + // set flag in config so that only the fields are rendered + $config['renderFieldsOnly'] = true; + $collapseAll = (isset($config['appearance']['collapseAll']) && $config['appearance']['collapseAll']); + $expandSingle = (isset($config['appearance']['expandSingle']) && $config['appearance']['expandSingle']); + // Put the current level also to the dynNestedStack of TCEforms: + $this->fObj->pushToDynNestedStack('inline', $this->inlineNames['object']); + + $record = $this->getRecord($this->inlineFirstPid, $current['table'], $current['uid']); + + // the HTML-object-id's prefix of the dynamically created record + $objectPrefix = $this->inlineNames['object'] . self::Structure_Separator . $current['table']; + $objectId = $objectPrefix . self::Structure_Separator . $record['uid']; + + $item = $this->renderForeignRecord($parent['uid'], $record, $config); + if($item === false) { + return $this->getErrorMessageForAJAX('Access denied'); + } + + // Encode TCEforms AJAX response with utf-8: + $item = $GLOBALS['LANG']->csConvObj->utf8_encode($item, $GLOBALS['LANG']->charSet); + + $jsonArray = array( + 'data' => $item, + 'scriptCall' => array( + "inline.domAddRecordDetails('".$domObjectId.'_fields'."','$objectPrefix',json.data);", + ) + ); + + $this->getCommonScriptCalls($jsonArray, $config); + // Collapse all other records if requested: + if (!$collapseAll && $expandSingle) { + $jsonArray['scriptCall'][] = "inline.collapseAllRecords('$objectId', '$objectPrefix', '".$record['uid']."');"; + } + + // Remove the current level also from the dynNestedStack of TCEforms: + $this->fObj->popFromDynNestedStack(); + + // Return the JSON array: + return $jsonArray; + } + + /** * Handle AJAX calls to localize all records of a parent, localize a single record or to synchronize with the original language parent. * Index: t3lib/config_default.php =================================================================== --- t3lib/config_default.php (revision 6751) +++ t3lib/config_default.php (working copy) @@ -262,6 +262,7 @@ 'SC_alt_file_navframe::expandCollapse' => 'typo3/alt_file_navframe.php:SC_alt_file_navframe->ajaxExpandCollapse', 'TYPO3_tcefile::process' => 'typo3/classes/class.typo3_tcefile.php:TYPO3_tcefile->processAjaxRequest', 't3lib_TCEforms_inline::createNewRecord' => 't3lib/class.t3lib_tceforms_inline.php:t3lib_TCEforms_inline->processAjaxRequest', + 't3lib_TCEforms_inline::getRecordDetails' => 't3lib/class.t3lib_tceforms_inline.php:t3lib_TCEforms_inline->processAjaxRequest', 't3lib_TCEforms_inline::synchronizeLocalizeRecords' => 't3lib/class.t3lib_tceforms_inline.php:t3lib_TCEforms_inline->processAjaxRequest', 't3lib_TCEforms_inline::setExpandedCollapsedState' => 't3lib/class.t3lib_tceforms_inline.php:t3lib_TCEforms_inline->processAjaxRequest', 't3lib_TCEforms_suggest::searchRecord' => 't3lib/tceforms/class.t3lib_tceforms_suggest.php:t3lib_TCEforms_suggest->processAjaxRequest', Index: t3lib/jsfunc.inline.js =================================================================== --- t3lib/jsfunc.inline.js (revision 6751) +++ t3lib/jsfunc.inline.js (working copy) @@ -45,10 +45,14 @@ setPrependFormFieldNames: function(value) { this.prependFormFieldNames = value; }, setNoTitleString: function(value) { this.noTitleString = value; }, - expandCollapseRecord: function(objectId, expandSingle) { + expandCollapseRecord: function(objectId, expandSingle, returnURL) { var currentUid = this.parseObjectId('none', objectId, 1); var objectPrefix = this.parseObjectId('full', objectId, 0, 1); + // if content is not loaded yet, get it now from server + if ($(objectId+'_fields') && $(objectId+'_fields').innerHTML.substr(0,16) == '') + return this.getRecordDetails(returnURL, objectId); + var currentState = ''; var collapse = new Array(); var expand = new Array(); @@ -104,6 +108,11 @@ ucFormObj[0].value = value; } }, + + getRecordDetails: function(returnURL, objectId) { + inline.makeAjaxCall('getRecordDetails', [inline.getNumberOfRTE(), objectId, returnURL], true); + return false; + }, createNewRecord: function(objectId, recordUid) { if (this.isBelowMax(objectId)) { @@ -351,6 +360,12 @@ new Insertion.After(insertObject, htmlData); } }, + + domAddRecordDetails: function(insertObject, objectPrefix, htmlData) { + if (!$(insertObject) || $(insertObject).innerHTML.substr(0,16) != '') + return; + $(insertObject).replace(htmlData); + }, // Get script and link elements from head tag: getDomHeadChildren: function(head) {