Index: cm1/index.php =================================================================== --- cm1/index.php (revision 27884) +++ cm1/index.php (working copy) @@ -518,6 +518,10 @@ $cmd = 'saveScreen'; } elseif (t3lib_div::_GP('_loadScreen')) { $cmd = 'loadScreen'; + } elseif (t3lib_div::_GP('_save')) { + $cmd = 'saveUpdatedDSandTO'; + } elseif (t3lib_div::_GP('_saveExit')) { + $cmd = 'saveUpdatedDSandTOandExit'; } // Init settings: @@ -531,35 +535,38 @@ } // Session data + $this->sessionKey = $this->MCONF['name'] . '_mappingInfo:' . $this->_load_ds_xml_to; if ($cmd=='clear') { // Reset session data: - $sesDat = array(); - $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'].'_mappingInfo',$sesDat); + $sesDat = array('displayFile' => $this->displayFile, 'TO' => $this->_load_ds_xml_to, 'DS' => $this->displayUid); + $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); } else { // Get session data: - $sesDat = $GLOBALS['BE_USER']->getSessionData($this->MCONF['name'].'_mappingInfo'); + $sesDat = $GLOBALS['BE_USER']->getSessionData($this->sessionKey); } + if ($this->_load_ds_xml_to) { + $toREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj', $this->_load_ds_xml_to); + $dsREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_datastructure',$toREC['datastructure']); + } // Loading DS from either XML or a Template Object (containing reference to DS) if ($cmd=='load_ds_xml' && ($this->_load_ds_xml_content || $this->_load_ds_xml_to)) { $to_uid = $this->_load_ds_xml_to; if ($to_uid) { - $toREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$to_uid); $tM = unserialize($toREC['templatemapping']); - $sesDat=array(); + $sesDat = array('displayFile' => $this->displayFile, 'TO' => $this->_load_ds_xml_to, 'DS' => $this->displayUid); $sesDat['currentMappingInfo'] = $tM['MappingInfo']; $sesDat['currentMappingInfo_head'] = $tM['MappingInfo_head']; - $dsREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_datastructure',$toREC['datastructure']); - $ds = t3lib_div::xml2array($dsREC['dataprot']); $sesDat['dataStruct'] = $sesDat['autoDS'] = $ds; // Just set $ds, not only its ROOT! Otherwise will be lost. - $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'].'_mappingInfo',$sesDat); + $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); } else { $ds = t3lib_div::xml2array($this->_load_ds_xml_content); - $sesDat=array(); + $sesDat = array('displayFile' => $this->displayFile, 'TO' => $this->_load_ds_xml_to, 'DS' => $this->displayUid); $sesDat['dataStruct'] = $sesDat['autoDS'] = $ds; - $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'].'_mappingInfo',$sesDat); + $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); } } + // Setting Data Structure to value from session data - unless it does not exist in which case a default structure is created. $dataStruct = is_array($sesDat['autoDS']) ? $sesDat['autoDS'] : array( 'meta' => array( @@ -587,7 +594,7 @@ if (is_array($inputData)) { $sesDat['currentMappingInfo'] = $currentMappingInfo = $this->array_merge_recursive_overrule($currentMappingInfo,$inputData); $sesDat['dataStruct'] = $dataStruct; - $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'].'_mappingInfo',$sesDat); + $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); } break; // Saving incoming Data Structure settings to session data: @@ -595,7 +602,7 @@ $inDS = t3lib_div::_GP('autoDS',1); if (is_array($inDS)) { $sesDat['dataStruct'] = $sesDat['autoDS'] = $dataStruct = $this->array_merge_recursive_overrule($dataStruct,$inDS); - $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'].'_mappingInfo',$sesDat); + $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); } break; // If DS element is requested for deletion, remove it and update session data: @@ -603,12 +610,12 @@ $ref = explode('][',substr($this->DS_element_DELETE,1,-1)); $this->unsetArrayPath($dataStruct,$ref); $sesDat['dataStruct'] = $sesDat['autoDS'] = $dataStruct; - $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'].'_mappingInfo',$sesDat); + $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); break; } // Creating $templatemapping array with cached mapping content: - if (t3lib_div::inList('showXMLDS,saveDSandTO,updateDSandTO',$cmd)) { + if (t3lib_div::inList('showXMLDS,saveDSandTO,updateDSandTO,saveUpdatedDSandTO,saveUpdatedDSandTOandExit', $cmd)) { // Template mapping prepared: $templatemapping=array(); @@ -726,14 +733,18 @@ // Clear cached header info because saveDSandTO always resets headers $sesDat['currentMappingInfo_head'] = ''; - $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'].'_mappingInfo',$sesDat); + $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); break; // Updating DS and TO records: case 'updateDSandTO': + case 'saveUpdatedDSandTO': + case 'saveUpdatedDSandTOandExit': - // Looking up the records by their uids: - $toREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$this->_saveDSandTO_TOuid); - $dsREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_datastructure',$toREC['datastructure']); + if ($cmd == 'updateDSandTO') { + // Looking up the records by their uids: + $toREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$this->_saveDSandTO_TOuid); + $dsREC = t3lib_BEfunc::getRecordWSOL('tx_templavoila_datastructure',$toREC['datastructure']); + } // If they are found, continue: if ($toREC['uid'] && $dsREC['uid']) { @@ -772,9 +783,13 @@ $msg[] = ''.sprintf($GLOBALS['LANG']->getLL('msgDSTOUpdated'), $dsREC['uid'], $toREC['uid']); - // Clear cached header info because updateDSandTO always resets headers - $sesDat['currentMappingInfo_head'] = ''; - $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'].'_mappingInfo',$sesDat); + if ($cmd == 'updateDSandTO') { + // Clear cached header info because updateDSandTO always resets headers + $sesDat['currentMappingInfo_head'] = ''; + $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); + } elseif ($cmd == 'saveUpdatedDSandTOandExit') { + header ('Location:' . t3lib_div::locationHeaderUrl($this->returnUrl)); + } } break; } @@ -782,13 +797,26 @@ // Header: $tRows = array(); - $relFilePath = substr($this->displayFile,strlen(PATH_site)); - $onCl = 'return top.openUrlInWindow(\''.t3lib_div::getIndpEnv('TYPO3_SITE_URL').$relFilePath.'\',\'FileView\');'; + $relFilePath = substr($this->displayFile, strlen(PATH_site)); + $onCl = 'return top.openUrlInWindow(\'' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $relFilePath . '\',\'FileView\');'; $tRows[]='