예제 #1
0
 /**
  * Do processing of data, submitting it to TCEmain.
  *
  * @return void
  */
 public function processData()
 {
     $beUser = $this->getBackendUser();
     // GPvars specifically for processing:
     $control = GeneralUtility::_GP('control');
     $this->data = GeneralUtility::_GP('data');
     $this->cmd = GeneralUtility::_GP('cmd');
     $this->mirror = GeneralUtility::_GP('mirror');
     $this->cacheCmd = GeneralUtility::_GP('cacheCmd');
     $this->redirect = GeneralUtility::_GP('redirect');
     $this->returnNewPageId = GeneralUtility::_GP('returnNewPageId');
     $this->vC = GeneralUtility::_GP('vC');
     // See tce_db.php for relevate options here:
     // Only options related to $this->data submission are included here.
     /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
     $tce = GeneralUtility::makeInstance(DataHandler::class);
     $tce->stripslashes_values = false;
     if (!empty($control)) {
         $tce->setControl($control);
     }
     if (isset($_POST['_translation_savedok_x'])) {
         $tce->updateModeL10NdiffData = 'FORCE_FFUPD';
     }
     if (isset($_POST['_translation_savedokclear_x'])) {
         $tce->updateModeL10NdiffData = 'FORCE_FFUPD';
         $tce->updateModeL10NdiffDataClear = true;
     }
     // Setting default values specific for the user:
     $TCAdefaultOverride = $beUser->getTSConfigProp('TCAdefaults');
     if (is_array($TCAdefaultOverride)) {
         $tce->setDefaultsFromUserTS($TCAdefaultOverride);
     }
     // Setting internal vars:
     if ($beUser->uc['neverHideAtCopy']) {
         $tce->neverHideAtCopy = 1;
     }
     // Loading TCEmain with data:
     $tce->start($this->data, $this->cmd);
     if (is_array($this->mirror)) {
         $tce->setMirror($this->mirror);
     }
     // Checking referer / executing
     $refInfo = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER'));
     $httpHost = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
     if ($httpHost != $refInfo['host'] && $this->vC != $beUser->veriCode() && !$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) {
         $tce->log('', 0, 0, 0, 1, 'Referer host \'%s\' and server host \'%s\' did not match and veriCode was not valid either!', 1, array($refInfo['host'], $httpHost));
         debug('Error: Referer host did not match with server host.');
     } else {
         // Perform the saving operation with TCEmain:
         $tce->process_uploads($_FILES);
         $tce->process_datamap();
         $tce->process_cmdmap();
         // If pages are being edited, we set an instruction about updating the page tree after this operation.
         if ($tce->pagetreeNeedsRefresh && (isset($this->data['pages']) || $beUser->workspace != 0 && !empty($this->data))) {
             BackendUtility::setUpdateSignal('updatePageTree');
         }
         // If there was saved any new items, load them:
         if (!empty($tce->substNEWwithIDs_table)) {
             // save the expanded/collapsed states for new inline records, if any
             FormEngineUtility::updateInlineView($this->uc, $tce);
             $newEditConf = array();
             foreach ($this->editconf as $tableName => $tableCmds) {
                 $keys = array_keys($tce->substNEWwithIDs_table, $tableName);
                 if (!empty($keys)) {
                     foreach ($keys as $key) {
                         $editId = $tce->substNEWwithIDs[$key];
                         // Check if the $editId isn't a child record of an IRRE action
                         if (!(is_array($tce->newRelatedIDs[$tableName]) && in_array($editId, $tce->newRelatedIDs[$tableName]))) {
                             // Translate new id to the workspace version:
                             if ($versionRec = BackendUtility::getWorkspaceVersionOfRecord($beUser->workspace, $tableName, $editId, 'uid')) {
                                 $editId = $versionRec['uid'];
                             }
                             $newEditConf[$tableName][$editId] = 'edit';
                         }
                         // Traverse all new records and forge the content of ->editconf so we can continue to EDIT
                         // these records!
                         if ($tableName == 'pages' && $this->retUrl != BackendUtility::getModuleUrl('dummy') && $this->returnNewPageId) {
                             $this->retUrl .= '&id=' . $tce->substNEWwithIDs[$key];
                         }
                     }
                 } else {
                     $newEditConf[$tableName] = $tableCmds;
                 }
             }
             // Resetting editconf if newEditConf has values:
             if (!empty($newEditConf)) {
                 $this->editconf = $newEditConf;
             }
             // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
             $this->R_URL_getvars['edit'] = $this->editconf;
             // Unsetting default values since we don't need them anymore.
             unset($this->R_URL_getvars['defVals']);
             // Re-compile the store* values since editconf changed...
             $this->compileStoreDat();
         }
         // See if any records was auto-created as new versions?
         if (!empty($tce->autoVersionIdMap)) {
             $this->fixWSversioningInEditConf($tce->autoVersionIdMap);
         }
         // If a document is saved and a new one is created right after.
         if (isset($_POST['_savedoknew']) && is_array($this->editconf)) {
             // Finding the current table:
             reset($this->editconf);
             $nTable = key($this->editconf);
             // Finding the first id, getting the records pid+uid
             reset($this->editconf[$nTable]);
             $nUid = key($this->editconf[$nTable]);
             $nRec = BackendUtility::getRecord($nTable, $nUid, 'pid,uid');
             // Setting a blank editconf array for a new record:
             $this->editconf = array();
             if ($this->getNewIconMode($nTable) == 'top') {
                 $this->editconf[$nTable][$nRec['pid']] = 'new';
             } else {
                 $this->editconf[$nTable][-$nRec['uid']] = 'new';
             }
             // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed.
             $this->R_URL_getvars['edit'] = $this->editconf;
             // Re-compile the store* values since editconf changed...
             $this->compileStoreDat();
         }
         // If a preview is requested
         if (isset($_POST['_savedokview'])) {
             // Get the first table and id of the data array from DataHandler
             $table = reset(array_keys($this->data));
             $id = reset(array_keys($this->data[$table]));
             if (!MathUtility::canBeInterpretedAsInteger($id)) {
                 $id = $tce->substNEWwithIDs[$id];
             }
             // Store this information for later use
             $this->previewData['table'] = $table;
             $this->previewData['id'] = $id;
         }
         $tce->printLogErrorMessages(isset($_POST['_saveandclosedok']) || isset($_POST['_translation_savedok_x']) ? $this->retUrl : $this->R_URL_parts['path'] . '?' . GeneralUtility::implodeArrayForUrl('', $this->R_URL_getvars));
     }
     //  || count($tce->substNEWwithIDs)... If any new items has been save, the document is CLOSED
     // because if not, we just get that element re-listed as new. And we don't want that!
     if (isset($_POST['_saveandclosedok']) || isset($_POST['_translation_savedok_x']) || $this->closeDoc < 0) {
         $this->closeDocument(abs($this->closeDoc));
     }
 }