TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
Import Class Reference
Inheritance diagram for Import:
ImportExport

Public Member Functions

 init ()
 
 importData ($pid)
 
 checkImportPrerequisites ()
 
 writeRecords_pages ($pid)
 
 writeRecords_pages_order ()
 
 flatInversePageTree_pid ($idH, $a=[], $pid=-1)
 
 writeRecords_records ($pid)
 
 writeRecords_records_order ($mainPid)
 
 addSingle ($table, $uid, $pid)
 
 addToMapId ($substNEWwithIDs)
 
 getNewTCE ()
 
 unlinkTempFiles ()
 
 setRelations ()
 
 setRelations_db ($itemArray, $itemConfig)
 
 import_addFileNameToBeCopied ($fI)
 
 setFlexFormRelations ()
 
 remapListedDBRecords_flexFormCallBack ($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path)
 
 processSoftReferences_flexFormCallBack ($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path)
 
 processSoftReferences_substTokens ($tokenizedContent, $softRefCfgs, $table, $uid)
 
 processSoftReferences_saveFile ($relFileName, $cfg, $table, $uid)
 
 processSoftReferences_saveFile_createRelFile ($origDirPrefix, $fileName, $fileID, $table, $uid)
 
 writeFileVerify ($fileName, $fileID, $bypassMountCheck=false)
 
 checkOrCreateDir ($dirPrefix)
 
 loadFile ($filename, $all=false)
 
 getNextFilePart ($fd, $unserialize=false, $name= '')
 
 loadContent ($filecontent)
 
 getNextContentPart ($filecontent, &$pointer, $unserialize=false, $name= '')
 
 loadInit ()
 
- Public Member Functions inherited from ImportExport
 __construct ()
 
 init ()
 
 displayContentOverview ()
 
 traversePageTree ($pT, &$lines, $preCode= '')
 
 traversePageRecords ($pT, &$lines)
 
 traverseAllRecords ($pT, &$lines)
 
 singleRecordLines ($table, $uid, &$lines, $preCode, $checkImportInPidRecord=false)
 
 addRelations ($rels, &$lines, $preCode, $recurCheck=[], $htmlColorClass= '')
 
 addFiles ($rels, &$lines, $preCode, $htmlColorClass= '', $tokenID= '')
 
 checkDokType ($checkTable, $doktype)
 
 renderControls ($r)
 
 softrefSelector ($cfg)
 
 verifyFolderAccess ($dirPrefix, $noAlternative=false)
 
 flatInversePageTree ($idH, $a=[])
 
 isTableStatic ($table)
 
 inclRelation ($table)
 
 isExcluded ($table, $uid)
 
 includeSoftref ($tokenID)
 
 checkPID ($pid)
 
 dontIgnorePid ($table, $uid)
 
 doesRecordExist ($table, $uid, $fields= '')
 
 getRecordPath ($pid)
 
 renderSelectBox ($prefix, $value, $optValues)
 
 compareRecords ($databaseRecord, $importRecord, $table, $inverseDiff=false)
 
 getRTEoriginalFilename ($string)
 
 getFileProcObj ()
 
 callHook ($name, $params)
 
 setExcludeDisabledRecords ($excludeDisabledRecords=false)
 
 error ($msg)
 
 printErrorLog ()
 

Public Attributes

 $suggestedInsertUids = []
 
 $enableLogging = false
 
 $import_newId = []
 
 $import_newId_pids = []
 
 $import_data = []
 
- Public Attributes inherited from ImportExport
 $showStaticRelations = false
 
 $fileadminFolderName = ''
 
 $mode = ''
 
 $update = false
 
 $doesImport = false
 
 $display_import_pid_record = []
 
 $import_mode = []
 
 $global_ignore_pid = false
 
 $force_all_UIDS = false
 
 $showDiff = false
 
 $allowPHPScripts = false
 
 $softrefInputValues = []
 
 $fileIDMap = []
 
 $relOnlyTables = []
 
 $relStaticTables = []
 
 $excludeMap = []
 
 $softrefCfg = []
 
 $extensionDependencies = []
 
 $import_mapId = []
 
 $errorLog = []
 
 $cache_getRecordPath = []
 
 $checkPID_cache = []
 
 $compress = false
 
 $dat = []
 

Protected Member Functions

 initializeImport ()
 
 writeSysFileStorageRecords ()
 
 isEquivalentObjectStorage (ResourceStorage $storageObject, array $storageRecord)
 
 removeSysFileReferenceRecordsFromImportDataWithRelationToMissingFile ()
 
 isFallbackStorage ($storageId)
 
 fixUidLocalInSysFileReferenceRecords ($oldFileUid, $newFileUid)
 
 fetchStorageRecords ()
 
 writeTemporaryFileFromData ($fileId, $dataKey= 'files_fal')
 
- Protected Member Functions inherited from ImportExport
 isActive ($table, $uid)
 
 excludePageAndRecords ($pageUid, $pageTree)
 
 addGeneralErrorsByTable ($table)
 
 getTemporaryFolderName ()
 
 getBackendUser ()
 
 getLanguageService ()
 

Protected Attributes

 $storageObjects = []
 
 $filesPathForImport = null
 
 $unlinkFiles = []
 
 $alternativeFileName = []
 
 $alternativeFilePath = []
 
 $filePathMap = []
 
- Protected Attributes inherited from ImportExport
 $fileProcObj = null
 
 $remainHeader = []
 
 $iconFactory
 
 $excludeDisabledRecords = false
 

Detailed Description

T3D file Import library (TYPO3 Record Document)

Definition at line 37 of file Import.php.

Member Function Documentation

addSingle (   $table,
  $uid,
  $pid 
)

Adds a single record to the $importData array. Also copies files to tempfolder. However all File/DB-references and flexform field contents are set to blank for now! That is done with setRelations() later

Parameters
string$tableTable name (from import memory)
int$uidRecord UID (from import memory)
int$pidPage id
Returns
void
See also
writeRecords()

Definition at line 828 of file Import.php.

References MathUtility\canBeInterpretedAsInteger(), ImportExport\doesRecordExist(), ImportExport\error(), ImportExport\getBackendUser(), StringUtility\getUniqueId(), and GeneralUtility\makeInstance().

Referenced by Import\writeRecords_pages(), Import\writeRecords_records(), and Import\writeSysFileStorageRecords().

addToMapId (   $substNEWwithIDs)

Registers the substNEWids in memory.

Parameters
array$substNEWwithIDsFrom DataHandler to be merged into internal mapping variable in this object
Returns
void
See also
writeRecords()

Definition at line 940 of file Import.php.

References ImportExport\error().

Referenced by Import\writeRecords_pages(), Import\writeRecords_records(), and Import\writeSysFileStorageRecords().

checkImportPrerequisites ( )

Checks any prerequisites necessary to get fulfilled before import

Returns
array Messages explaining issues which need to get resolved before import

Definition at line 283 of file Import.php.

References ResourceFactory\getInstance(), Import\isEquivalentObjectStorage(), and ExtensionManagementUtility\isLoaded().

checkOrCreateDir (   $dirPrefix)

Returns TRUE if directory exists and if it doesn't it will create directory and return TRUE if that succeeded.

Parameters
string$dirPrefixDirectory to create. Having a trailing slash. Must be in fileadmin/. Relative to PATH_site
Returns
bool TRUE, if directory exists (was created)

Definition at line 1657 of file Import.php.

References ImportExport\error(), GeneralUtility\getFileAbsFileName(), and GeneralUtility\mkdir().

Referenced by Import\processSoftReferences_saveFile_createRelFile().

fetchStorageRecords ( )
protected

Fetched fresh storage records from database because the new imported ones are not in cached data of the StorageRepository

Returns
bool|array

Definition at line 541 of file Import.php.

References GeneralUtility\makeInstance().

fixUidLocalInSysFileReferenceRecords (   $oldFileUid,
  $newFileUid 
)
protected

Normally the importer works like the following: Step 1: import the records with cleared field values of relation fields (see addSingle()) Step 2: update the records with the right relation ids (see setRelations())

In step 2 the saving fields of type "relation to sys_file_reference" checks the related sys_file_reference record (created in step 1) with the FileExtensionFilter for matching file extensions of the related file. To make this work correct, the uid_local of sys_file_reference records has to be not empty AND has to relate to the correct (imported) sys_file record uid!!!

This is fixed here.

Parameters
int$oldFileUid
int$newFileUid
Returns
void

Definition at line 520 of file Import.php.

flatInversePageTree_pid (   $idH,
  $a = [],
  $pid = -1 
)

Recursively flattening the idH array, setting PIDs as values

Parameters
array$idHPage uid hierarchy
array$aAccumulation array of pages (internal, don't set from outside)
int$pidPID value (internal)
Returns
array Array with uid-pid pairs for all pages in the page tree.
See also
ImportExport::flatInversePageTree()

Definition at line 691 of file Import.php.

Referenced by Import\writeRecords_pages_order().

getNextContentPart (   $filecontent,
$pointer,
  $unserialize = false,
  $name = '' 
)

Returns the next content part from the $filecontent

Parameters
string$filecontentFile content string
int$pointerFile pointer (where to read from)
bool$unserializeIf set, the returned content is unserialized into an array, otherwise you get the raw string
string$nameFor error messages this indicates the section of the problem.
Returns
string|NULL Data string

Definition at line 1819 of file Import.php.

References ImportExport\error().

Referenced by Import\loadContent().

getNextFilePart (   $fd,
  $unserialize = false,
  $name = '' 
)

Returns the next content part form the fileresource (t3d), $fd

Parameters
resource$fdFile pointer
bool$unserializeIf set, the returned content is unserialized into an array, otherwise you get the raw string
string$nameFor error messages this indicates the section of the problem.
Returns
string|NULL Data string or NULL in case of an error private
See also
loadFile()

Definition at line 1758 of file Import.php.

References ImportExport\error().

Referenced by Import\loadFile().

import_addFileNameToBeCopied (   $fI)

Writes the file from import array to temp dir and returns the filename of it.

Parameters
array$fIFile information with three keys: "filename" = filename without path, "ID_absFile" = absolute filepath to the file (including the filename), "ID" = md5 hash of "ID_absFile
Returns
string|NULL Absolute filename of the temporary filename of the file. In ->alternativeFileName the original name is set.

Definition at line 1120 of file Import.php.

References ImportExport\error(), GeneralUtility\tempnam(), and GeneralUtility\writeFile().

Referenced by Import\remapListedDBRecords_flexFormCallBack(), and Import\setRelations().

importData (   $pid)

Imports the internal data array to $pid.

Parameters
int$pidPage ID in which to import the content
Returns
void

Definition at line 168 of file Import.php.

References Import\initializeImport(), Import\setFlexFormRelations(), Import\setRelations(), Import\unlinkTempFiles(), Import\writeRecords_pages(), Import\writeRecords_records(), and Import\writeSysFileStorageRecords().

init ( )

Init the object

Returns
void

Definition at line 118 of file Import.php.

initializeImport ( )
protected

Initialize all settings for the import

Returns
void

Definition at line 133 of file Import.php.

Referenced by Import\importData().

isEquivalentObjectStorage ( ResourceStorage  $storageObject,
array  $storageRecord 
)
protected

Determines whether the passed storage object and record (sys_file_storage) can be seen as equivalent during import.

Parameters
ResourceStorage$storageObjectThe storage object which should get compared
array$storageRecordThe storage record which should get compared
Returns
bool Returns TRUE when both object storages can be seen as equivalent

Definition at line 259 of file Import.php.

References ResourceStorage\getConfiguration(), ResourceStorage\getDriverType(), ResourceFactory\getInstance(), ResourceStorage\isOnline(), and ResourceStorage\isWritable().

Referenced by Import\checkImportPrerequisites(), and Import\writeSysFileStorageRecords().

isFallbackStorage (   $storageId)
protected

Checks if the $storageId is the id of the fallback storage

Parameters
int | string$storageId
Returns
bool

Definition at line 499 of file Import.php.

loadContent (   $filecontent)

Loads T3D file content into the $this->dat array (This function can be used to test the output strings from ->compileMemoryToFileContent())

Parameters
string$filecontentFile content
Returns
void

Definition at line 1801 of file Import.php.

References Import\getNextContentPart(), and Import\loadInit().

loadFile (   $filename,
  $all = false 
)

Loads the header section/all of the $filename into memory

Parameters
string$filenameFilename, absolute
bool$allIf set, all information is loaded (header, records and files). Otherwise the default is to read only the header information
Returns
bool TRUE if the operation went well

Definition at line 1694 of file Import.php.

References GeneralUtility\copyDirectory(), ImportExport\error(), Import\getNextFilePart(), ImportExport\getTemporaryFolderName(), GeneralUtility\isAllowedAbsPath(), Import\loadInit(), and GeneralUtility\xml2array().

loadInit ( )

Setting up the object based on the recently loaded ->dat array

Returns
void

Definition at line 1852 of file Import.php.

Referenced by Import\loadContent(), and Import\loadFile().

processSoftReferences_flexFormCallBack (   $pParams,
  $dsConf,
  $dataValue,
  $dataValue_ext1,
  $dataValue_ext2,
  $path 
)

Callback function for traversing the FlexForm structure in relation to remapping softreference relations

Parameters
array$pParamsSet of parameters in numeric array: table, uid, field
array$dsConfTCA config for field (from Data Structure of course)
string$dataValueField value (from FlexForm XML)
string$dataValue_ext1Not used
string$dataValue_ext2Not used
string$pathPath of where the data structure where the element is found
Returns
array Array where the "value" key carries the value.
See also
setFlexFormRelations()

Definition at line 1369 of file Import.php.

References Import\processSoftReferences_substTokens().

processSoftReferences_saveFile (   $relFileName,
  $cfg,
  $table,
  $uid 
)

Process a soft reference file

Parameters
string$relFileNameOld Relative filename
array$cfgsoft reference configuration array
string$tableTable for which the processing occurs
string$uidUID of record from table
Returns
string New relative filename (value to insert instead of the softref token)

Definition at line 1461 of file Import.php.

References ImportExport\$fileProcObj, PathUtility\basename(), PathUtility\dirname(), ImportExport\error(), GeneralUtility\getFileAbsFileName(), ImportExport\getFileProcObj(), ImportExport\getRTEoriginalFilename(), GeneralUtility\isFirstPartOfStr(), Import\processSoftReferences_saveFile_createRelFile(), PathUtility\stripPathSitePrefix(), and Import\writeFileVerify().

Referenced by Import\processSoftReferences_substTokens().

processSoftReferences_saveFile_createRelFile (   $origDirPrefix,
  $fileName,
  $fileID,
  $table,
  $uid 
)

Create file in directory and return the new (unique) filename

Parameters
string$origDirPrefixDirectory prefix, relative, with trailing slash
string$fileNameFilename (without path)
string$fileIDFile ID from import memory
string$tableTable for which the processing occurs
string$uidUID of record from table
Returns
string|NULL New relative filename, if any

Definition at line 1528 of file Import.php.

References ImportExport\$fileProcObj, PathUtility\basename(), Import\checkOrCreateDir(), PathUtility\dirname(), ImportExport\error(), GeneralUtility\getFileAbsFileName(), ImportExport\getFileProcObj(), GeneralUtility\isFirstPartOfStr(), GeneralUtility\mkdir(), GeneralUtility\resolveBackPath(), PathUtility\stripPathSitePrefix(), ImportExport\verifyFolderAccess(), GeneralUtility\writeFile(), and Import\writeFileVerify().

Referenced by Import\processSoftReferences_saveFile().

processSoftReferences_substTokens (   $tokenizedContent,
  $softRefCfgs,
  $table,
  $uid 
)

Substition of softreference tokens

Parameters
string$tokenizedContentContent of field with soft reference tokens in.
array$softRefCfgsSoft reference configurations
string$tableTable for which the processing occurs
string$uidUID of record from table
Returns
string The input content with tokens substituted according to entries in softRefCfgs

Definition at line 1403 of file Import.php.

References MathUtility\canBeInterpretedAsInteger(), BackendUtility\getRecord(), Import\processSoftReferences_saveFile(), and BackendUtility\wsMapId().

Referenced by Import\processSoftReferences_flexFormCallBack().

remapListedDBRecords_flexFormCallBack (   $pParams,
  $dsConf,
  $dataValue,
  $dataValue_ext1,
  $dataValue_ext2,
  $path 
)

Callback function for traversing the FlexForm structure in relation to remapping database relations

Parameters
array$pParamsSet of parameters in numeric array: table, uid, field
array$dsConfTCA config for field (from Data Structure of course)
string$dataValueField value (from FlexForm XML)
string$dataValue_ext1Not used
string$dataValue_ext2Not used
string$pathPath of where the data structure of the element is found
Returns
array Array where the "value" key carries the value.
See also
setFlexFormRelations()

Definition at line 1250 of file Import.php.

References Import\import_addFileNameToBeCopied(), and Import\setRelations_db().

removeSysFileReferenceRecordsFromImportDataWithRelationToMissingFile ( )
protected

Removes all sys_file_reference records from the import data array that are pointing to sys_file records which are missing not in the import data to prevent exceptions on checking the related file started by the Datahandler.

Returns
void

Definition at line 474 of file Import.php.

References ImportExport\error().

setFlexFormRelations ( )

After all DB relations has been set in the end of the import (see setRelations()) then it is time to correct all relations inside of FlexForm fields. The reason for doing this after is that the setting of relations may affect (quite often!) which data structure is used for the flexforms field!

Returns
void
See also
setRelations()

Definition at line 1161 of file Import.php.

References ImportExport\$dat, $GLOBALS, ImportExport\callHook(), ImportExport\error(), Import\getNewTCE(), BackendUtility\getRecord(), GeneralUtility\makeInstance(), BackendUtility\wsMapId(), and GeneralUtility\xml2array().

Referenced by Import\importData().

setRelations ( )

At the end of the import process all file and DB relations should be set properly (that is relations to imported records are all re-created so imported records are correctly related again) Relations in flexform fields are processed in setFlexFormRelations() after this function

Returns
void
See also
setFlexFormRelations()

Definition at line 1009 of file Import.php.

References ImportExport\$dat, $GLOBALS, ImportExport\callHook(), ImportExport\error(), Import\getNewTCE(), Import\import_addFileNameToBeCopied(), Import\setRelations_db(), and BackendUtility\wsMapId().

Referenced by Import\importData().

setRelations_db (   $itemArray,
  $itemConfig 
)

Maps relations for database

Parameters
array$itemArrayArray of item sets (table/uid) from a dbAnalysis object
array$itemConfigArray of TCA config of the field the relation to be set on
Returns
array Array with values [table]_[uid] or [uid] for field of type group / internal_type file_reference. These values have the regular DataHandler-input group/select type which means they will automatically be processed into a uid-list or MM relations.

Definition at line 1076 of file Import.php.

References ImportExport\error(), ResourceFactory\getInstance(), ImportExport\isExcluded(), and ImportExport\isTableStatic().

Referenced by Import\remapListedDBRecords_flexFormCallBack(), and Import\setRelations().

unlinkTempFiles ( )

Cleaning up all the temporary files stored in typo3temp/ folder

Returns
void

Definition at line 981 of file Import.php.

References ImportExport\error(), GeneralUtility\isFirstPartOfStr(), and GeneralUtility\unlink_tempfile().

Referenced by Import\importData().

writeFileVerify (   $fileName,
  $fileID,
  $bypassMountCheck = false 
)

Writes a file from the import memory having $fileID to file name $fileName which must be an absolute path inside PATH_site

Parameters
string$fileNameAbsolute filename inside PATH_site to write to
string$fileIDFile ID from import memory
bool$bypassMountCheckBypasses the checking against filemounts - only for RTE files!
Returns
bool Returns TRUE if it went well. Notice that the content of the file is read again, and md5 from import memory is validated.

Definition at line 1612 of file Import.php.

References ImportExport\$fileProcObj, ImportExport\error(), ImportExport\getBackendUser(), GeneralUtility\getFileAbsFileName(), ImportExport\getFileProcObj(), ResourceFactory\getInstance(), GeneralUtility\split_fileref(), and GeneralUtility\writeFile().

Referenced by Import\processSoftReferences_saveFile(), and Import\processSoftReferences_saveFile_createRelFile().

writeRecords_pages (   $pid)

Writing pagetree/pages to database:

Parameters
int$pidPID in which to import. If the operation is an update operation, the root of the page tree inside will be moved to this PID unless it is the same as the root page from the import
Returns
void
See also
writeRecords_records()

Definition at line 593 of file Import.php.

References Import\$suggestedInsertUids, ImportExport\addGeneralErrorsByTable(), Import\addSingle(), Import\addToMapId(), ImportExport\callHook(), ImportExport\flatInversePageTree(), Import\getNewTCE(), and Import\writeRecords_pages_order().

Referenced by Import\importData().

writeRecords_pages_order ( )

Organize all updated pages in page tree so they are related like in the import file Only used for updates and when $this->dat['header']['pagetree'] is an array.

Returns
void private
See also
writeRecords_pages(), writeRecords_records_order()

Definition at line 649 of file Import.php.

References ImportExport\callHook(), ImportExport\dontIgnorePid(), Import\flatInversePageTree_pid(), and Import\getNewTCE().

Referenced by Import\writeRecords_pages().

writeRecords_records (   $pid)

Write all database records except pages (writtein in writeRecords_pages())

Parameters
int$pidPage id in which to import
Returns
void
See also
writeRecords_pages()

Definition at line 712 of file Import.php.

References $GLOBALS, Import\$suggestedInsertUids, ImportExport\addGeneralErrorsByTable(), Import\addSingle(), Import\addToMapId(), ImportExport\callHook(), ImportExport\error(), Import\getNewTCE(), and Import\writeRecords_records_order().

Referenced by Import\importData().

writeRecords_records_order (   $mainPid)

Organize all updated record to their new positions. Only used for updates

Parameters
int$mainPidMain PID into which we import.
Returns
void private
See also
writeRecords_records(), writeRecords_pages_order()

Definition at line 774 of file Import.php.

References ImportExport\callHook(), MathUtility\canBeInterpretedAsInteger(), ImportExport\dontIgnorePid(), ImportExport\flatInversePageTree(), and Import\getNewTCE().

Referenced by Import\writeRecords_records().

writeSysFileStorageRecords ( )
protected

Imports the sys_file_storage records from internal data array.

Returns
void

Definition at line 196 of file Import.php.

References Import\addSingle(), Import\addToMapId(), ResourceFactory\getInstance(), Import\getNewTCE(), and Import\isEquivalentObjectStorage().

Referenced by Import\importData().

writeTemporaryFileFromData (   $fileId,
  $dataKey = 'files_fal' 
)
protected

Writes the file from import array to temp dir and returns the filename of it.

Parameters
string$fileId
string$dataKey
Returns
string Absolute filename of the temporary filename of the file

Definition at line 563 of file Import.php.

References ImportExport\error(), GeneralUtility\tempnam(), and GeneralUtility\writeFile().

Member Data Documentation

$alternativeFileName = []
protected

Definition at line 97 of file Import.php.

Referenced by Import\getNewTCE().

$alternativeFilePath = []
protected

Definition at line 102 of file Import.php.

Referenced by Import\getNewTCE().

$enableLogging = false

Definition at line 52 of file Import.php.

Referenced by Import\getNewTCE().

$filePathMap = []
protected

Definition at line 107 of file Import.php.

$filesPathForImport = null
protected

Definition at line 87 of file Import.php.

$import_data = []

Definition at line 75 of file Import.php.

$import_newId = []

Definition at line 61 of file Import.php.

$import_newId_pids = []

Definition at line 68 of file Import.php.

$storageObjects = []
protected

Definition at line 82 of file Import.php.

$suggestedInsertUids = []

Definition at line 45 of file Import.php.

Referenced by Import\writeRecords_pages(), and Import\writeRecords_records().

$unlinkFiles = []
protected

Definition at line 92 of file Import.php.