00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00203
00204
00205
00206 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
00207 require_once (PATH_t3lib.'class.t3lib_parsehtml_proc.php');
00208 require_once (PATH_t3lib.'class.t3lib_stdgraphic.php');
00209 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
00210 require_once (PATH_t3lib.'class.t3lib_refindex.php');
00211 require_once (PATH_t3lib.'class.t3lib_flexformtools.php');
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00237 class t3lib_TCEmain {
00238
00239
00240
00241
00242
00243
00244 var $storeLogMessages = TRUE;
00245 var $enableLogging = TRUE;
00246 var $reverseOrder = FALSE;
00247 var $checkSimilar = TRUE;
00248 var $stripslashes_values = TRUE;
00249 var $checkStoredRecords = TRUE;
00250 var $checkStoredRecords_loose = TRUE;
00251 var $deleteTree = FALSE;
00252 var $neverHideAtCopy = FALSE;
00253 var $dontProcessTransformations = FALSE;
00254 var $bypassWorkspaceRestrictions = FALSE;
00255 var $bypassFileHandling = FALSE;
00256 var $bypassAccessCheckForRecords = FALSE;
00257
00258 var $copyWhichTables = '*';
00259 var $generalComment = '';
00260
00261 var $copyTree = 0;
00262
00263 var $defaultValues = array();
00264 var $overrideValues = array();
00265 var $alternativeFileName = array();
00266 var $data_disableFields=array();
00267 var $suggestedInsertUids=array();
00268
00269 var $callBackObj;
00270
00271
00272
00273
00274
00275
00276
00277 var $autoVersionIdMap = Array();
00278 var $substNEWwithIDs = Array();
00279 var $substNEWwithIDs_table = Array();
00280 var $newRelatedIDs = Array();
00281 var $copyMappingArray_merged = Array();
00282 var $copiedFileMap = Array();
00283 var $errorLog = Array();
00284
00285
00286
00287
00288
00289
00290
00291
00292 var $BE_USER;
00293 var $userid;
00294 var $username;
00295 var $admin;
00296
00297 var $defaultPermissions = array(
00298 'user' => 'show,edit,delete,new,editcontent',
00299 'group' => 'show,edit,new,editcontent',
00300 'everybody' => ''
00301 );
00302
00303 var $exclude_array;
00304 var $datamap = Array();
00305 var $cmdmap = Array();
00306
00307
00308 var $pMap = Array(
00309 'show' => 1,
00310 'edit' => 2,
00311 'delete' => 4,
00312 'new' => 8,
00313 'editcontent' => 16
00314 );
00315 var $sortIntervals = 256;
00316
00317
00318 var $recUpdateAccessCache = Array();
00319 var $recInsertAccessCache = Array();
00320 var $isRecordInWebMount_Cache=array();
00321 var $isInWebMount_Cache=array();
00322 var $cachedTSconfig = array();
00323 var $pageCache = Array();
00324 var $checkWorkspaceCache = Array();
00325
00326
00327 var $dbAnalysisStore=array();
00328 var $removeFilesStore=array();
00329 var $uploadedFileArray = array();
00330 var $registerDBList=array();
00331 var $copyMappingArray = Array();
00332 var $remapStack = array();
00333 var $updateRefIndexStack = array();
00334 var $callFromImpExp = false;
00335
00336
00337 var $fileFunc;
00338 var $checkValue_currentRecord=array();
00339 var $autoVersioningUpdate = FALSE;
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00362 function start($data,$cmd,$altUserObject='') {
00363
00364
00365 $this->BE_USER = is_object($altUserObject) ? $altUserObject : $GLOBALS['BE_USER'];
00366 $this->userid = $this->BE_USER->user['uid'];
00367 $this->username = $this->BE_USER->user['username'];
00368 $this->admin = $this->BE_USER->user['admin'];
00369
00370 if ($GLOBALS['BE_USER']->uc['recursiveDelete']) {
00371 $this->deleteTree = 1;
00372 }
00373
00374
00375 $defaultPermissions = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPermissions'];
00376 if (isset($defaultPermissions['user'])) {$this->defaultPermissions['user'] = $defaultPermissions['user'];}
00377 if (isset($defaultPermissions['group'])) {$this->defaultPermissions['group'] = $defaultPermissions['group'];}
00378 if (isset($defaultPermissions['everybody'])) {$this->defaultPermissions['everybody'] = $defaultPermissions['everybody'];}
00379
00380
00381 $this->exclude_array = $this->admin ? array() : $this->getExcludeListArray();
00382
00383
00384 if (is_array($data)) {
00385 reset($data);
00386 $this->datamap = $data;
00387 }
00388 if (is_array($cmd)) {
00389 reset($cmd);
00390 $this->cmdmap = $cmd;
00391 }
00392 }
00393
00401 function setMirror($mirror) {
00402 if (is_array($mirror)) {
00403 reset($mirror);
00404 while(list($table,$uid_array)=each($mirror)) {
00405 if (isset($this->datamap[$table])) {
00406 reset($uid_array);
00407 while (list($id,$uidList) = each($uid_array)) {
00408 if (isset($this->datamap[$table][$id])) {
00409 $theIdsInArray = t3lib_div::trimExplode(',',$uidList,1);
00410 while(list(,$copyToUid)=each($theIdsInArray)) {
00411 $this->datamap[$table][$copyToUid] = $this->datamap[$table][$id];
00412 }
00413 }
00414 }
00415 }
00416 }
00417 }
00418 }
00419
00426 function setDefaultsFromUserTS($userTS) {
00427 global $TCA;
00428 if (is_array($userTS)) {
00429 foreach($userTS as $k => $v) {
00430 $k = substr($k,0,-1);
00431 if ($k && is_array($v) && isset($TCA[$k])) {
00432 if (is_array($this->defaultValues[$k])) {
00433 $this->defaultValues[$k] = array_merge($this->defaultValues[$k],$v);
00434 } else {
00435 $this->defaultValues[$k] = $v;
00436 }
00437 }
00438 }
00439 }
00440 }
00441
00449 function process_uploads($postFiles) {
00450
00451 if (is_array($postFiles)) {
00452
00453
00454 if ($this->BE_USER->workspace!==0 && $this->BE_USER->workspaceRec['freeze']) {
00455 $this->newlog('All editing in this workspace has been frozen!',1);
00456 return FALSE;
00457 }
00458
00459 reset($postFiles);
00460 $subA = current($postFiles);
00461 if (is_array($subA)) {
00462 if (is_array($subA['name']) && is_array($subA['type']) && is_array($subA['tmp_name']) && is_array($subA['size'])) {
00463
00464 $this->uploadedFileArray=array();
00465
00466
00467 foreach($subA as $key => $values) {
00468 $this->process_uploads_traverseArray($this->uploadedFileArray,$values,$key);
00469 }
00470 } else {
00471 $this->uploadedFileArray=$subA;
00472 }
00473 }
00474 }
00475 }
00476
00487 function process_uploads_traverseArray(&$outputArr,$inputArr,$keyToSet) {
00488 if (is_array($inputArr)) {
00489 foreach($inputArr as $key => $value) {
00490 $this->process_uploads_traverseArray($outputArr[$key],$inputArr[$key],$keyToSet);
00491 }
00492 } else {
00493 $outputArr[$keyToSet]=$inputArr;
00494 }
00495 }
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00523 function process_datamap() {
00524 global $TCA, $TYPO3_CONF_VARS;
00525
00526
00527 if ($this->BE_USER->workspace!==0 && $this->BE_USER->workspaceRec['freeze']) {
00528 $this->newlog('All editing in this workspace has been frozen!',1);
00529 return FALSE;
00530 }
00531
00532
00533 $hookObjectsArr = array();
00534 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'])) {
00535 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'] as $classRef) {
00536 $hookObjectsArr[] = &t3lib_div::getUserObj($classRef);
00537 }
00538 }
00539
00540
00541 $orderOfTables = Array();
00542 if (isset($this->datamap['pages'])) {
00543 $orderOfTables[]='pages';
00544 }
00545 reset($this->datamap);
00546 while (list($table,) = each($this->datamap)) {
00547 if ($table!='pages') {
00548 $orderOfTables[]=$table;
00549 }
00550 }
00551
00552
00553 foreach($orderOfTables as $table) {
00554
00555
00556
00557
00558
00559
00560 $modifyAccessList = $this->checkModifyAccessList($table);
00561 if (!$modifyAccessList) {
00562 $id = 0;
00563 $this->log($table,$id,2,0,1,"Attempt to modify table '%s' without permission",1,array($table));
00564 }
00565 if (isset($TCA[$table]) && !$this->tableReadOnly($table) && is_array($this->datamap[$table]) && $modifyAccessList) {
00566 if ($this->reverseOrder) {
00567 $this->datamap[$table] = array_reverse($this->datamap[$table], 1);
00568 }
00569
00570
00571
00572
00573 foreach($this->datamap[$table] as $id => $incomingFieldArray) {
00574 if (is_array($incomingFieldArray)) {
00575
00576
00577 foreach($hookObjectsArr as $hookObj) {
00578 if (method_exists($hookObj, 'processDatamap_preProcessFieldArray')) {
00579 $hookObj->processDatamap_preProcessFieldArray($incomingFieldArray, $table, $id, $this);
00580 }
00581 }
00582
00583
00584
00585
00586 $createNewVersion = FALSE;
00587 $recordAccess = FALSE;
00588 $old_pid_value = '';
00589 $resetRejected = FALSE;
00590 $this->autoVersioningUpdate = FALSE;
00591
00592 if (!t3lib_div::testInt($id)) {
00593 $fieldArray = $this->newFieldArray($table);
00594 if (isset($incomingFieldArray['pid'])) {
00595
00596 $pid_value = $incomingFieldArray['pid'];
00597
00598
00599 $OK = 1;
00600 if (strstr($pid_value,'NEW')) {
00601 if (substr($pid_value,0,1)=='-') {$negFlag=-1;$pid_value=substr($pid_value,1);} else {$negFlag=1;}
00602 if (isset($this->substNEWwithIDs[$pid_value])) {
00603 $old_pid_value = $pid_value;
00604 $pid_value=intval($negFlag*$this->substNEWwithIDs[$pid_value]);
00605 } else {$OK = 0;}
00606 } elseif ($pid_value>=0 && $this->BE_USER->workspace!==0 && $TCA[$table]['ctrl']['versioning_followPages']) {
00607 if ($WSdestPage = t3lib_BEfunc::getWorkspaceVersionOfRecord($this->BE_USER->workspace, 'pages', $pid_value, 'uid,t3ver_swapmode')) {
00608 if ($WSdestPage['t3ver_swapmode']==0) {
00609 $pid_value = $WSdestPage['uid'];
00610 }
00611 }
00612 }
00613 $pid_value = intval($pid_value);
00614
00615
00616 if ($OK) {
00617 $sortRow = $TCA[$table]['ctrl']['sortby'];
00618 if ($pid_value>=0) {
00619 if ($sortRow) {
00620 $fieldArray[$sortRow] = $this->getSortNumber($table,0,$pid_value);
00621 }
00622 $fieldArray['pid'] = $pid_value;
00623 } else {
00624 if ($sortRow) {
00625 $tempArray=$this->getSortNumber($table,0,$pid_value);
00626 $fieldArray['pid'] = $tempArray['pid'];
00627 $fieldArray[$sortRow] = $tempArray['sortNumber'];
00628 } else {
00629 $tempdata = $this->recordInfo($table,abs($pid_value),'pid');
00630 $fieldArray['pid']=$tempdata['pid'];
00631 }
00632 }
00633 }
00634 }
00635 $theRealPid = $fieldArray['pid'];
00636
00637
00638 if ($theRealPid>=0) {
00639 $recordAccess = $this->checkRecordInsertAccess($table,$theRealPid);
00640 if ($recordAccess) {
00641 $this->addDefaultPermittedLanguageIfNotSet($table,$incomingFieldArray);
00642 $recordAccess = $this->BE_USER->recordEditAccessInternals($table,$incomingFieldArray,TRUE);
00643 if (!$recordAccess) {
00644 $this->newlog("recordEditAccessInternals() check failed. [".$this->BE_USER->errorMsg."]",1);
00645 } elseif(!$this->bypassWorkspaceRestrictions) {
00646
00647 if ($res = $this->BE_USER->workspaceAllowLiveRecordsInPID($theRealPid,$table)) {
00648 if ($res<0) {
00649 $recordAccess = FALSE;
00650 $this->newlog('Stage for versioning root point and users access level did not allow for editing',1);
00651 }
00652 } else {
00653 if ($TCA[$table]['ctrl']['versioningWS']) {
00654 $createNewVersion = TRUE;
00655 } else {
00656 $recordAccess = FALSE;
00657 $this->newlog('Record could not be created in this workspace in this branch',1);
00658 }
00659 }
00660 }
00661 }
00662 } else {
00663 debug('Internal ERROR: pid should not be less than zero!');
00664 }
00665 $status = 'new';
00666 } else {
00667 $fieldArray = array();
00668 $recordAccess = $this->checkRecordUpdateAccess($table,$id);
00669 if (!$recordAccess) {
00670 $propArr = $this->getRecordProperties($table,$id);
00671 $this->log($table,$id,2,0,1,"Attempt to modify record '%s' (%s) without permission. Or non-existing page.",2,array($propArr['header'],$table.':'.$id),$propArr['event_pid']);
00672 } else {
00673 $recordAccess = $this->BE_USER->recordEditAccessInternals($table,$id);
00674 if (!$recordAccess) {
00675 $propArr = $this->getRecordProperties($table,$id);
00676 $this->newlog("recordEditAccessInternals() check failed. [".$this->BE_USER->errorMsg."]",1);
00677 } else {
00678 $tempdata = $this->recordInfo($table,$id,'pid'.($TCA[$table]['ctrl']['versioningWS']?',t3ver_wsid,t3ver_stage':''));
00679 $theRealPid = $tempdata['pid'];
00680
00681
00682 if ($TCA[$table]['ctrl']['versioningWS'] && $tempdata['t3ver_stage']<0) {
00683 $resetRejected = TRUE;
00684 }
00685
00686
00687 if (!$this->bypassWorkspaceRestrictions && $errorCode = $this->BE_USER->workspaceCannotEditRecord($table,$tempdata)) {
00688 $recordAccess = FALSE;
00689
00690
00691 if ($this->BE_USER->workspaceAllowAutoCreation($table,$id,$theRealPid)) {
00692 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00693 $tce->stripslashes_values = 0;
00694
00695
00696 $cmd = array();
00697 $cmd[$table][$id]['version'] = array(
00698 'action' => 'new',
00699 'treeLevels' => -1,
00700 'label' => 'Auto-created for WS #'.$this->BE_USER->workspace
00701 );
00702 $tce->start(array(),$cmd);
00703 $tce->process_cmdmap();
00704 $this->errorLog = array_merge($this->errorLog,$tce->errorLog);
00705
00706 if ($tce->copyMappingArray[$table][$id]) {
00707 $this->uploadedFileArray[$table][$tce->copyMappingArray[$table][$id]] = $this->uploadedFileArray[$table][$id];
00708 $id = $this->autoVersionIdMap[$table][$id] = $tce->copyMappingArray[$table][$id];
00709 $recordAccess = TRUE;
00710 $this->autoVersioningUpdate = TRUE;
00711 } else $this->newlog("Could not be edited in offline workspace in the branch where found (failure state: '".$errorCode."'). Auto-creation of version failed!",1);
00712 } else $this->newlog("Could not be edited in offline workspace in the branch where found (failure state: '".$errorCode."'). Auto-creation of version not allowed in workspace!",1);
00713 }
00714 }
00715 }
00716 $status = 'update';
00717 }
00718
00719
00720 if ($recordAccess) {
00721
00722 list($tscPID) = t3lib_BEfunc::getTSCpid($table,$id,$old_pid_value ? $old_pid_value : $fieldArray['pid']);
00723 $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
00724 if ($status=='new' && $table=='pages' && is_array($TSConfig['permissions.'])) {
00725 $fieldArray = $this->setTSconfigPermissions($fieldArray,$TSConfig['permissions.']);
00726 }
00727 if ($createNewVersion) {
00728 $newVersion_placeholderFieldArray = $fieldArray;
00729 }
00730
00731
00732 $fieldArray = $this->fillInFieldArray($table,$id,$fieldArray,$incomingFieldArray,$theRealPid,$status,$tscPID);
00733
00734
00735
00736
00737 $fieldArray = $this->overrideFieldArray($table,$fieldArray);
00738 if ($createNewVersion) {
00739 $newVersion_placeholderFieldArray = $this->overrideFieldArray($table,$newVersion_placeholderFieldArray);
00740 }
00741
00742
00743 if ($status=='new') {
00744 if ($TCA[$table]['ctrl']['crdate']) {
00745 $fieldArray[$TCA[$table]['ctrl']['crdate']]=time();
00746 if ($createNewVersion) $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['crdate']]=time();
00747 }
00748 if ($TCA[$table]['ctrl']['cruser_id']) {
00749 $fieldArray[$TCA[$table]['ctrl']['cruser_id']]=$this->userid;
00750 if ($createNewVersion) $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['cruser_id']]=$this->userid;
00751 }
00752 } elseif ($this->checkSimilar) {
00753 $fieldArray = $this->compareFieldArrayWithCurrentAndUnset($table,$id,$fieldArray);
00754 }
00755 if ($TCA[$table]['ctrl']['tstamp'] && count($fieldArray)) {
00756 $fieldArray[$TCA[$table]['ctrl']['tstamp']]=time();
00757 if ($createNewVersion) $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['tstamp']]=time();
00758 }
00759 if ($resetRejected) {
00760 $fieldArray['t3ver_stage'] = 0;
00761 }
00762
00763
00764 foreach($hookObjectsArr as $hookObj) {
00765 if (method_exists($hookObj, 'processDatamap_postProcessFieldArray')) {
00766 $hookObj->processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $this);
00767 }
00768 }
00769
00770
00771
00772 if (is_array($fieldArray)) {
00773 if ($status=='new') {
00774 if ($createNewVersion) {
00775 $versioningType = $table==='pages' ? $this->BE_USER->workspaceVersioningTypeGetClosest(t3lib_div::intInRange($TYPO3_CONF_VARS['BE']['newPagesVersioningType'],-1,1)) : -1;
00776 if ($this->BE_USER->workspaceVersioningTypeAccess($versioningType)) {
00777 $newVersion_placeholderFieldArray['t3ver_label'] = 'INITIAL PLACEHOLDER';
00778 $newVersion_placeholderFieldArray['t3ver_state'] = 1;
00779 $newVersion_placeholderFieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
00780 $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['label']] = '[PLACEHOLDER, WS#'.$this->BE_USER->workspace.']';
00781 $this->insertDB($table,$id,$newVersion_placeholderFieldArray,FALSE);
00782
00783
00784 $fieldArray['pid'] = -1;
00785 $fieldArray['t3ver_oid'] = $this->substNEWwithIDs[$id];
00786 $fieldArray['t3ver_id'] = 1;
00787 $fieldArray['t3ver_state'] = -1;
00788 $fieldArray['t3ver_label'] = 'First draft version';
00789 $fieldArray['t3ver_wsid'] = $this->BE_USER->workspace;
00790 if ($table==='pages') {
00791 $fieldArray['t3ver_swapmode'] = $versioningType;
00792 }
00793 $phShadowId = $this->insertDB($table,$id,$fieldArray,TRUE,0,TRUE);
00794 if ($phShadowId) {
00795 $this->placeholderShadowing($table,$phShadowId);
00796 }
00797 } else $this->newlog('Versioning type "'.$versioningType.'" was not allowed, so could not create new record.',1);
00798 } else {
00799 $this->insertDB($table,$id,$fieldArray,FALSE,$incomingFieldArray['uid']);
00800 }
00801 } else {
00802 $this->updateDB($table,$id,$fieldArray);
00803 $this->placeholderShadowing($table,$id);
00804 }
00805 }
00806
00807
00808
00809
00810
00811
00812
00813 foreach($hookObjectsArr as $hookObj) {
00814 if (method_exists($hookObj, 'processDatamap_afterDatabaseOperations')) {
00815 $hookObj->processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $this);
00816 }
00817 }
00818 }
00819 }
00820 }
00821 }
00822 }
00823
00824
00825
00826
00827 if(is_array($this->remapStack)) {
00828 foreach($this->remapStack as $remapAction) {
00829
00830 if (!is_array($remapAction['pos'])) continue;
00831
00832
00833 $field = $remapAction['field'];
00834 $id = $remapAction['args'][$remapAction['pos']['id']];
00835 $table = $remapAction['args'][$remapAction['pos']['table']];
00836 $valueArray = $remapAction['args'][$remapAction['pos']['valueArray']];
00837 $tcaFieldConf = $remapAction['args'][$remapAction['pos']['tcaFieldConf']];
00838
00839
00840 if(strpos($id, 'NEW') !== false) {
00841 $id = $this->substNEWwithIDs[$id];
00842 $remapAction['args'][$remapAction['pos']['id']] = $id;
00843 }
00844
00845
00846 if(is_array($valueArray)) {
00847 foreach($valueArray as $key => $value) {
00848 if(strpos($value, 'NEW') !== false) {
00849
00850 $valueArray[$key] = $this->substNEWwithIDs[$value];
00851
00852 $this->newRelatedIDs[$table][] = $valueArray[$key];
00853 }
00854 }
00855 $remapAction['args'][$remapAction['pos']['valueArray']] = $valueArray;
00856 }
00857
00858
00859 $remapAction['args'][$remapAction['pos']['valueArray']] = call_user_func_array(
00860 array($this, $remapAction['func']),
00861 $remapAction['args']
00862 );
00863
00864
00865 $newVal = $this->checkValue_checkMax($tcaFieldConf, $remapAction['args'][$remapAction['pos']['valueArray']]);
00866 $this->updateDB($table,$id,array($field => implode(',', $newVal)));
00867 }
00868 }
00869
00870 $this->dbAnalysisStoreExec();
00871 $this->removeRegisteredFiles();
00872 }
00873
00881 function placeholderShadowing($table,$id) {
00882 global $TCA;
00883
00884 t3lib_div::loadTCA($table);
00885 if ($liveRec = t3lib_BEfunc::getLiveVersionOfRecord($table,$id,'*')) {
00886 if ((int)$liveRec['t3ver_state']===1) {
00887 $justStoredRecord = t3lib_BEfunc::getRecord($table,$id);
00888 $newRecord = array();
00889
00890 $shadowCols = $TCA[$table]['ctrl']['shadowColumnsForNewPlaceholders'];
00891 $shadowCols.= ','.$TCA[$table]['ctrl']['languageField'];
00892 $shadowCols.= ','.$TCA[$table]['ctrl']['transOrigPointerField'];
00893 $shadowCols.= ','.$TCA[$table]['ctrl']['type'];
00894 $shadowCols.= ','.$TCA[$table]['ctrl']['label'];
00895
00896 $shadowColumns = array_unique(t3lib_div::trimExplode(',', $shadowCols,1));
00897 foreach($shadowColumns as $fieldName) {
00898 if (strcmp($justStoredRecord[$fieldName],$liveRec[$fieldName]) && isset($TCA[$table]['columns'][$fieldName]) && $fieldName!=='uid' && $fieldName!=='pid') {
00899 $newRecord[$fieldName] = $justStoredRecord[$fieldName];
00900 }
00901 }
00902
00903 if (count($newRecord)) {
00904 $this->newlog('Shadowing done on fields '.implode(',',array_keys($newRecord)).' in Placeholder record '.$table.':'.$liveRec['uid'].' (offline version UID='.$id.')');
00905 $this->updateDB($table,$liveRec['uid'],$newRecord);
00906 }
00907 }
00908 }
00909 }
00910
00924 function fillInFieldArray($table,$id,$fieldArray,$incomingFieldArray,$realPid,$status,$tscPID) {
00925 global $TCA;
00926
00927
00928 t3lib_div::loadTCA($table);
00929 $originalLanguageRecord = NULL;
00930 $originalLanguage_diffStorage = NULL;
00931 $diffStorageFlag = FALSE;
00932
00933
00934 if (strstr($id,'NEW')) {
00935 $currentRecord = $checkValueRecord = $fieldArray;
00936
00937
00938
00939 if (is_array($incomingFieldArray) && is_array($checkValueRecord)) {
00940 $checkValueRecord = t3lib_div::array_merge_recursive_overrule($checkValueRecord, $incomingFieldArray);
00941 }
00942 } else {
00943 $currentRecord = $checkValueRecord = $this->recordInfo($table,$id,'*');
00944
00945 t3lib_BEfunc::fixVersioningPid($table,$currentRecord);
00946
00947
00948 if (is_array($currentRecord)
00949 && $TCA[$table]['ctrl']['transOrigDiffSourceField']
00950 && $TCA[$table]['ctrl']['languageField']
00951 && $currentRecord[$TCA[$table]['ctrl']['languageField']] > 0
00952 && $TCA[$table]['ctrl']['transOrigPointerField']
00953 && intval($currentRecord[$TCA[$table]['ctrl']['transOrigPointerField']]) > 0) {
00954
00955 $lookUpTable = $TCA[$table]['ctrl']['transOrigPointerTable'] ? $TCA[$table]['ctrl']['transOrigPointerTable'] : $table;
00956 $originalLanguageRecord = $this->recordInfo($lookUpTable,$currentRecord[$TCA[$table]['ctrl']['transOrigPointerField']],'*');
00957 t3lib_BEfunc::workspaceOL($lookUpTable,$originalLanguageRecord);
00958 $originalLanguage_diffStorage = unserialize($currentRecord[$TCA[$table]['ctrl']['transOrigDiffSourceField']]);
00959 }
00960 }
00961 $this->checkValue_currentRecord = $checkValueRecord;
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972 foreach($incomingFieldArray as $field => $fieldValue) {
00973 if (!in_array($table.'-'.$field, $this->exclude_array) && !$this->data_disableFields[$table][$id][$field]) {
00974
00975
00976 $languageDeny = $TCA[$table]['ctrl']['languageField'] && !strcmp($TCA[$table]['ctrl']['languageField'], $field) && !$this->BE_USER->checkLanguageAccess($fieldValue);
00977
00978 if (!$languageDeny) {
00979
00980 if ($this->stripslashes_values) {
00981 if (is_array($fieldValue)) {
00982 t3lib_div::stripSlashesOnArray($fieldValue);
00983 } else $fieldValue = stripslashes($fieldValue);
00984 }
00985
00986 switch ($field) {
00987 case 'uid':
00988 case 'pid':
00989
00990 break;
00991 case 'perms_userid':
00992 case 'perms_groupid':
00993 case 'perms_user':
00994 case 'perms_group':
00995 case 'perms_everybody':
00996
00997 if ($table=='pages' && ($this->admin || $status=='new' || $this->pageInfo($id,'perms_userid')==$this->userid) ) {
00998 $value=intval($fieldValue);
00999 switch($field) {
01000 case 'perms_userid':
01001 $fieldArray[$field]=$value;
01002 break;
01003 case 'perms_groupid':
01004 $fieldArray[$field]=$value;
01005 break;
01006 default:
01007 if ($value>=0 && $value<pow(2,5)) {
01008 $fieldArray[$field]=$value;
01009 }
01010 break;
01011 }
01012 }
01013 break;
01014 case 't3ver_oid':
01015 case 't3ver_id':
01016 case 't3ver_wsid':
01017 case 't3ver_state':
01018 case 't3ver_swapmode':
01019 case 't3ver_count':
01020 case 't3ver_stage':
01021 case 't3ver_tstamp':
01022
01023 break;
01024 default:
01025 if (isset($TCA[$table]['columns'][$field])) {
01026
01027 $res = $this->checkValue($table,$field,$fieldValue,$id,$status,$realPid,$tscPID);
01028 if (isset($res['value'])) {
01029 $fieldArray[$field]=$res['value'];
01030
01031
01032 if ($TCA[$table]['ctrl']['transOrigDiffSourceField']) {
01033 $originalLanguage_diffStorage[$field] = $originalLanguageRecord[$field];
01034 $diffStorageFlag = TRUE;
01035 }
01036 }
01037 } elseif ($TCA[$table]['ctrl']['origUid']===$field) {
01038 $fieldArray[$field] = $fieldValue;
01039 }
01040 break;
01041 }
01042 }
01043 }
01044 }
01045
01046
01047 if ($diffStorageFlag && !isset($fieldArray[$TCA[$table]['ctrl']['transOrigDiffSourceField']])) {
01048 $fieldArray[$TCA[$table]['ctrl']['transOrigDiffSourceField']] = serialize($originalLanguage_diffStorage);
01049 }
01050
01051
01052 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$currentRecord);
01053 $theTypeString = t3lib_BEfunc::getTCAtypeValue($table,$currentRecord);
01054 if (is_array($types_fieldConfig)) {
01055 reset($types_fieldConfig);
01056 while(list(,$vconf) = each($types_fieldConfig)) {
01057
01058 $eFile = t3lib_parsehtml_proc::evalWriteFile($vconf['spec']['static_write'],array_merge($currentRecord,$fieldArray));
01059
01060
01061 if (!$this->dontProcessTransformations) {
01062 if (isset($fieldArray[$vconf['field']])) {
01063
01064 switch((string)$incomingFieldArray['_TRANSFORM_'.$vconf['field']]) {
01065 case 'RTE':
01066 $RTEsetup = $this->BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID));
01067 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$vconf['field'],$theTypeString);
01068
01069
01070 $RTErelPath = is_array($eFile) ? dirname($eFile['relEditFile']) : '';
01071
01072
01073 $RTEobj = &t3lib_BEfunc::RTEgetObj();
01074 if (is_object($RTEobj)) {
01075 $fieldArray[$vconf['field']] = $RTEobj->transformContent('db',$fieldArray[$vconf['field']],$table,$vconf['field'],$currentRecord,$vconf['spec'],$thisConfig,$RTErelPath,$currentRecord['pid']);
01076 } else {
01077 debug('NO RTE OBJECT FOUND!');
01078 }
01079 break;
01080 }
01081 }
01082 }
01083
01084
01085 if (is_array($eFile)) {
01086 $mixedRec = array_merge($currentRecord,$fieldArray);
01087 $SW_fileContent = t3lib_div::getUrl($eFile['editFile']);
01088 $parseHTML = t3lib_div::makeInstance('t3lib_parsehtml_proc');
01089 $parseHTML->init('','');
01090
01091 $eFileMarker = $eFile['markerField']&&trim($mixedRec[$eFile['markerField']]) ? trim($mixedRec[$eFile['markerField']]) : '###TYPO3_STATICFILE_EDIT###';
01092 $insertContent = str_replace($eFileMarker,'',$mixedRec[$eFile['contentField']]);
01093
01094 $SW_fileNewContent = $parseHTML->substituteSubpart($SW_fileContent, $eFileMarker, chr(10).$insertContent.chr(10), 1, 1);
01095 t3lib_div::writeFile($eFile['editFile'],$SW_fileNewContent);
01096
01097
01098 if (!strstr($id,'NEW') && $eFile['statusField']) {
01099 $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
01100 $table,
01101 'uid='.intval($id),
01102 array(
01103 $eFile['statusField'] => $eFile['relEditFile'].' updated '.date('d-m-Y H:i:s').', bytes '.strlen($mixedRec[$eFile['contentField']])
01104 )
01105 );
01106 }
01107 } elseif ($eFile && is_string($eFile)) {
01108 $this->log($table,$id,2,0,1,"Write-file error: '%s'",13,array($eFile),$realPid);
01109 }
<