More workspace stuff for beta.
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / class.tx_impexp.php
index 5ddfe17..abcceea 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  *  202: class tx_impexp
  *
  *              SECTION: Initialize
- *  264:     function init($dontCompress=0,$mode='')
+ *  265:     function init($dontCompress=0,$mode='')
  *
  *              SECTION: Export / Init + Meta Data
- *  295:     function setHeaderBasics()
- *  319:     function setCharset($charset)
- *  334:     function setMetaData($title,$description,$notes,$packager_username,$packager_name,$packager_email)
- *  354:     function addThumbnail($imgFilepath)
+ *  296:     function setHeaderBasics()
+ *  320:     function setCharset($charset)
+ *  335:     function setMetaData($title,$description,$notes,$packager_username,$packager_name,$packager_email)
+ *  355:     function addThumbnail($imgFilepath)
  *
  *              SECTION: Export / Init Page tree
- *  392:     function setPageTree($idH)
- *  405:     function unsetExcludedSections($idH)
- *  427:     function flatInversePageTree($idH,$a=array())
- *  450:     function flatInversePageTree_pid($idH,$a=array(),$pid=-1)
+ *  393:     function setPageTree($idH)
+ *  406:     function unsetExcludedSections($idH)
+ *  428:     function flatInversePageTree($idH,$a=array())
+ *  451:     function flatInversePageTree_pid($idH,$a=array(),$pid=-1)
  *
  *              SECTION: Export
- *  489:     function export_addRecord($table,$row,$relationLevel=0)
- *  539:     function export_addDBRelations($relationLevel=0)
- *  643:     function export_addDBRelations_registerRelation($fI, &$addR, $tokenID='')
- *  667:     function export_addFilesFromRelations()
- *  768:     function export_addFile($fI, $recordRef='', $fieldname='')
- *  896:     function getRelations($table,$row)
- * 1003:     function getRelations_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $structurePath)
- * 1052:     function getRelations_procFiles($value, $conf, $uid)
- * 1102:     function getRelations_procDB($value, $conf, $uid)
- * 1123:     function flatDBrels($dbrels)
- * 1149:     function flatSoftRefs($dbrels)
- * 1197:     function destPathFromUploadFolder($folder)
+ *  490:     function export_addRecord($table,$row,$relationLevel=0)
+ *  540:     function export_addDBRelations($relationLevel=0)
+ *  644:     function export_addDBRelations_registerRelation($fI, &$addR, $tokenID='')
+ *  668:     function export_addFilesFromRelations()
+ *  769:     function export_addFile($fI, $recordRef='', $fieldname='')
+ *  897:     function getRelations($table,$row)
+ * 1004:     function getRelations_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $structurePath)
+ * 1053:     function getRelations_procFiles($value, $conf, $uid)
+ * 1103:     function getRelations_procDB($value, $conf, $uid)
+ * 1124:     function flatDBrels($dbrels)
+ * 1150:     function flatSoftRefs($dbrels)
+ * 1198:     function destPathFromUploadFolder($folder)
  *
  *              SECTION: File Output
- * 1222:     function compileMemoryToFileContent($type='')
- * 1248:     function createXML()
- * 1340:     function doOutputCompress()
- * 1351:     function addFilePart($data, $compress=FALSE)
+ * 1223:     function compileMemoryToFileContent($type='')
+ * 1249:     function createXML()
+ * 1341:     function doOutputCompress()
+ * 1352:     function addFilePart($data, $compress=FALSE)
  *
  *              SECTION: Import
- * 1384:     function importData($pid)
- * 1425:     function writeRecords_pages($pid)
- * 1480:     function writeRecords_pages_order($pid)
- * 1518:     function writeRecords_records($pid)
- * 1568:     function writeRecords_records_order($mainPid)
- * 1617:     function addSingle($table,$uid,$pid)
- * 1691:     function addToMapId($substNEWwithIDs)
- * 1711:     function getNewTCE()
- * 1725:     function unlinkTempFiles()
+ * 1385:     function importData($pid)
+ * 1426:     function writeRecords_pages($pid)
+ * 1481:     function writeRecords_pages_order($pid)
+ * 1519:     function writeRecords_records($pid)
+ * 1569:     function writeRecords_records_order($mainPid)
+ * 1618:     function addSingle($table,$uid,$pid)
+ * 1692:     function addToMapId($substNEWwithIDs)
+ * 1712:     function getNewTCE()
+ * 1726:     function unlinkTempFiles()
  *
  *              SECTION: Import / Relations setting
- * 1763:     function setRelations()
- * 1817:     function setRelations_db($itemArray)
- * 1844:     function import_addFileNameToBeCopied($fI)
- * 1867:     function setFlexFormRelations()
- * 1950:     function remapListedDBRecords_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path)
+ * 1764:     function setRelations()
+ * 1818:     function setRelations_db($itemArray)
+ * 1845:     function import_addFileNameToBeCopied($fI)
+ * 1868:     function setFlexFormRelations()
+ * 1951:     function remapListedDBRecords_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path)
  *
  *              SECTION: Import / Soft References
- * 1992:     function processSoftReferences()
- * 2083:     function processSoftReferences_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path)
- * 2122:     function processSoftReferences_substTokens($tokenizedContent, $softRefCfgs, $table, $uid)
- * 2186:     function processSoftReferences_saveFile($relFileName, $cfg, $table, $uid)
- * 2247:     function processSoftReferences_saveFile_createRelFile($origDirPrefix, $fileName, $fileID, $table, $uid)
- * 2336:     function writeFileVerify($fileName, $fileID, $bypassMountCheck=FALSE)
- * 2363:     function checkOrCreateDir($dirPrefix)
- * 2396:     function verifyFolderAccess($dirPrefix, $noAlternative=FALSE)
+ * 1993:     function processSoftReferences()
+ * 2084:     function processSoftReferences_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path)
+ * 2123:     function processSoftReferences_substTokens($tokenizedContent, $softRefCfgs, $table, $uid)
+ * 2187:     function processSoftReferences_saveFile($relFileName, $cfg, $table, $uid)
+ * 2248:     function processSoftReferences_saveFile_createRelFile($origDirPrefix, $fileName, $fileID, $table, $uid)
+ * 2337:     function writeFileVerify($fileName, $fileID, $bypassMountCheck=FALSE)
+ * 2364:     function checkOrCreateDir($dirPrefix)
+ * 2397:     function verifyFolderAccess($dirPrefix, $noAlternative=FALSE)
  *
  *              SECTION: File Input
- * 2446:     function loadFile($filename,$all=0)
- * 2489:     function getNextFilePart($fd,$unserialize=0,$name='')
- * 2516:     function loadContent($filecontent)
- * 2534:     function getNextContentPart($filecontent,&$pointer,$unserialize=0,$name='')
- * 2559:     function loadInit()
- * 2575:     function fixCharsets()
+ * 2447:     function loadFile($filename,$all=0)
+ * 2490:     function getNextFilePart($fd,$unserialize=0,$name='')
+ * 2517:     function loadContent($filecontent)
+ * 2535:     function getNextContentPart($filecontent,&$pointer,$unserialize=0,$name='')
+ * 2560:     function loadInit()
+ * 2576:     function fixCharsets()
  *
  *              SECTION: Visual rendering of import/export memory, $this->dat
- * 2630:     function displayContentOverview()
- * 2738:     function traversePageTree($pT,&$lines,$preCode='')
- * 2773:     function traversePageRecords($pT,&$lines)
- * 2800:     function traverseAllRecords($pT,&$lines)
- * 2822:     function singleRecordLines($table,$uid,&$lines,$preCode,$checkImportInPidRecord=0)
- * 2979:     function addRelations($rels,&$lines,$preCode,$recurCheck=array(),$htmlColorClass='')
- * 3044:     function addFiles($rels,&$lines,$preCode,$htmlColorClass='',$tokenID='')
- * 3162:     function checkDokType($checkTable,$doktype)
- * 3178:     function renderControls($r)
- * 3206:     function softrefSelector($cfg)
+ * 2631:     function displayContentOverview()
+ * 2739:     function traversePageTree($pT,&$lines,$preCode='')
+ * 2774:     function traversePageRecords($pT,&$lines)
+ * 2801:     function traverseAllRecords($pT,&$lines)
+ * 2823:     function singleRecordLines($table,$uid,&$lines,$preCode,$checkImportInPidRecord=0)
+ * 2980:     function addRelations($rels,&$lines,$preCode,$recurCheck=array(),$htmlColorClass='')
+ * 3045:     function addFiles($rels,&$lines,$preCode,$htmlColorClass='',$tokenID='')
+ * 3163:     function checkDokType($checkTable,$doktype)
+ * 3179:     function renderControls($r)
+ * 3207:     function softrefSelector($cfg)
  *
  *              SECTION: Helper functions of kinds
- * 3282:     function isTableStatic($table)
- * 3296:     function inclRelation($table)
- * 3311:     function isExcluded($table,$uid)
- * 3323:     function includeSoftref($tokenID)
- * 3333:     function isReferenceField($conf)
- * 3343:     function checkPID($pid)
- * 3360:     function dontIgnorePid($table, $uid)
- * 3373:     function doesRecordExist($table,$uid,$fields='')
- * 3383:     function getRecordPath($pid)
- * 3400:     function renderSelectBox($prefix,$value,$optValues)
- * 3424:     function compareRecords($databaseRecord, $importRecord, $table, $inverseDiff=FALSE)
- * 3491:     function getRTEoriginalFilename($string)
- * 3508:     function &getFileProcObj()
+ * 3283:     function isTableStatic($table)
+ * 3297:     function inclRelation($table)
+ * 3312:     function isExcluded($table,$uid)
+ * 3324:     function includeSoftref($tokenID)
+ * 3334:     function isReferenceField($conf)
+ * 3344:     function checkPID($pid)
+ * 3361:     function dontIgnorePid($table, $uid)
+ * 3374:     function doesRecordExist($table,$uid,$fields='')
+ * 3384:     function getRecordPath($pid)
+ * 3401:     function renderSelectBox($prefix,$value,$optValues)
+ * 3425:     function compareRecords($databaseRecord, $importRecord, $table, $inverseDiff=FALSE)
+ * 3492:     function getRTEoriginalFilename($string)
+ * 3509:     function &getFileProcObj()
  *
  *              SECTION: Error handling
- * 3541:     function error($msg)
- * 3550:     function printErrorLog()
+ * 3542:     function error($msg)
+ * 3551:     function printErrorLog()
  *
  * TOTAL FUNCTIONS: 78
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -488,6 +488,9 @@ class tx_impexp {
         * @return      void
         */
        function export_addRecord($table,$row,$relationLevel=0) {
+
+               t3lib_BEfunc::workspaceOL($table,$row);
+
                if (strcmp($table,'') && is_array($row) && $row['uid']>0 && !$this->excludeMap[$table.':'.$row['uid']]) {
                        if ($this->checkPID($table==='pages' ? $row['uid'] : $row['pid']))      {
                                if (!isset($this->dat['records'][$table.':'.$row['uid']]))      {
@@ -1774,7 +1777,8 @@ class tx_impexp {
 
                                // If the record has been written and received a new id, then proceed:
                        if (is_array($this->import_mapId[$table]) && isset($this->import_mapId[$table][$uid]))  {
-                               $thisNewUid = $this->import_mapId[$table][$uid];
+                               $thisNewUid = t3lib_BEfunc::wsMapId($table,$this->import_mapId[$table][$uid]);
+
                                if (is_array($this->dat['records'][$table.':'.$uid]['rels']))   {
                                        reset($this->dat['records'][$table.':'.$uid]['rels']);
 
@@ -1878,7 +1882,8 @@ class tx_impexp {
 
                                // If the record has been written and received a new id, then proceed:
                        if (is_array($this->import_mapId[$table]) && isset($this->import_mapId[$table][$uid]))  {
-                               $thisNewUid = $this->import_mapId[$table][$uid];
+                               $thisNewUid = t3lib_BEfunc::wsMapId($table,$this->import_mapId[$table][$uid]);
+
                                if (is_array($this->dat['records'][$table.':'.$uid]['rels']))   {
                                        reset($this->dat['records'][$table.':'.$uid]['rels']);
                                        t3lib_div::loadTCA($table);
@@ -2016,7 +2021,7 @@ class tx_impexp {
                                                }
 
                                                        // The new id:
-                                               $thisNewUid = $this->import_mapId[$table][$uid];
+                                               $thisNewUid = t3lib_BEfunc::wsMapId($table,$this->import_mapId[$table][$uid]);
 
                                                        // Now, if there are any fields that require substitution to be done, lets go for that:
                                                foreach($fieldsIndex as $field => $softRefCfgs) {
@@ -2148,7 +2153,7 @@ class tx_impexp {
                                                                        // Trying to map database element if found in the mapID array:
                                                                list($tempTable,$tempUid) = explode(':',$cfg['subst']['recordRef']);
                                                                if (isset($this->import_mapId[$tempTable][$tempUid]))   {
-                                                                       $insertValue = $this->import_mapId[$tempTable][$tempUid];
+                                                                       $insertValue = t3lib_BEfunc::wsMapId($tempTable,$this->import_mapId[$tempTable][$tempUid]);
 
                                                                                // Look if reference is to a page and the original token value was NOT an integer - then we assume is was an alias and try to look up the new one!
                                                                        if ($tempTable==='pages' && !t3lib_div::testInt($cfg['subst']['tokenValue']))   {
@@ -2886,6 +2891,7 @@ class tx_impexp {
                                        if ($newUid = $this->import_mapId[$table][$uid])        {
                                                $diffInverse = FALSE;
                                                $recInf = $this->doesRecordExist($table, $newUid, '*');
+                                               t3lib_BEfunc::workspaceOL($table,$recInf);
                                        }
                                        if (is_array($recInf))  {
                                                $pInfo['showDiffContent'] = $this->compareRecords($recInf, $this->dat['records'][$table.':'.$uid]['data'], $table, $diffInverse);
@@ -3526,7 +3532,6 @@ class tx_impexp {
 
 
 
-
        /*****************************
         *
         * Error handling