Import extends ImportExport

T3D file Import library (TYPO3 Record Document)

Internal

This class is not considered part of the public TYPO3 API.

Table of Contents

Constants

IMPORT_MODE_AS_NEW  = 'as_new'
IMPORT_MODE_EXCLUDE  = 'exclude'
IMPORT_MODE_FORCE_UID  = 'force_uid'
IMPORT_MODE_IGNORE_PID  = 'ignore_pid'
IMPORT_MODE_RESPECT_PID  = 'respect_pid'
SOFTREF_IMPORT_MODE_EDITABLE  = 'editable'
SOFTREF_IMPORT_MODE_EXCLUDE  = 'exclude'

Properties

$cacheGetRecordPath  : array<string|int, mixed>
Cache for record paths
$dat  : array<string|int, mixed>
Internal import/export memory
$decompressionAvailable  : bool
$defaultImportExportFolder  : Folder|null
$defaultStorage  : ResourceStorage|null
Currently registered default storage object
$doesImport  : bool
Set by importData() when an import is started.
$enableLogging  : bool
Disable logging when importing
$errorLog  : array<string|int, mixed>
Error log.
$excludeDisabledRecords  : bool
Flag to control whether all disabled records and their children are excluded (true) or included (false). Defaults to the old behaviour of including everything.
$excludeMap  : array<string|int, mixed>
Exclude map. Keys are table:uid pairs and if set, records are not added to the export.
$extensionDependencies  : array<string|int, mixed>
Listing extension dependencies.
$fileadminFolderName  : string
Name of the "fileadmin" folder where files for export/import should be located
$fileIdMap  : array<string|int, mixed>
Mapping between the fileID from import memory and the final filenames they are written to.
$fileProcObj  : ExtendedFileUtility|null
File processing object
$forceAllUids  : bool
If set, all UID values are forced! (update or import)
$globalIgnorePid  : bool
If set, PID correct is ignored globally
$iconFactory  : IconFactory
$importMapId  : array<string|int, mixed>
After records are written this array is filled with [table][original_uid] = [new_uid]
$importMode  : array<string|int, mixed>
Setting the import mode for specific import records.
$importNewId  : array<string|int, mixed>
Keys are [tablename]:[new NEWxxx ids (or when updating it is uids)] while values are arrays with table/uid of the original record it is based on.
$importNewIdPids  : array<string|int, mixed>
Page id map for page tree (import)
$isFilesSavedOutsideImportFile  : bool
$lang  : LanguageService
$mode  : string
Whether "import" or "export" mode of object.
$permsClause  : string
A WHERE clause for selection records from the pages table based on read-permissions of the current backend user.
$pid  : int
Root page of import or export page tree
$pidRecord  : array<string|int, mixed>|null
Root page record of import or of export page tree
$relStaticTables  : array<string|int, mixed>
Add tables names here which should not be exported with the file.
$remainHeader  : array<string|int, mixed>
$showDiff  : bool
If set, a diff-view column is added to the preview.
$showStaticRelations  : bool
If set, static relations (not exported) will be shown in preview as well
$softrefCfg  : array<string|int, mixed>
Soft reference token ID modes.
$softrefInputValues  : array<string|int, mixed>
Array of values to substitute in editable soft references.
$storageRepository  : StorageRepository
$storages  : array<string|int, ResourceStorage>
Array of currently registered storage objects
$storagesAvailableForImport  : array<string|int, ResourceStorage>
Array of currently registered storage objects available for importing files to
$suggestedInsertUids  : array<string|int, mixed>
Used to register the forced UID values for imported records that we want to create with the same UIDs as in the import file. Admin-only feature.
$temporaryFolderName  : string|null
$update  : bool
Updates all records that has same UID instead of creating new!

Methods

__construct()  : mixed
addFiles()  : void
Add file relations of a record to the preview.
checkImportPrerequisites()  : void
Checks all requirements that must be met before import.
getDat()  : array<string|int, mixed>
getErrorLog()  : array<string|int, mixed>
getExcludeMap()  : array<string|int, mixed>
getExtensionDependencies()  : array<string|int, mixed>
getImportMapId()  : array<string|int, mixed>
getImportMode()  : array<string|int, mixed>
getMetaData()  : array<string|int, mixed>
getMode()  : string
getOrCreateDefaultImportExportFolder()  : Folder|null
Returns a \TYPO3\CMS\Core\Resource\Folder object for saving export files to the server and is also used for uploading import files.
getOrCreateTemporaryFolderName()  : string
getPid()  : int
getRelStaticTables()  : array<string|int, mixed>
getSoftrefCfg()  : array<string|int, mixed>
getSoftrefInputValues()  : array<string|int, mixed>
hasErrors()  : bool
importData()  : void
Imports the memory data into the TYPO3 database.
isDecompressionAvailable()  : bool
isEnableLogging()  : bool
isExcludeDisabledRecords()  : bool
isForceAllUids()  : bool
isGlobalIgnorePid()  : bool
isShowDiff()  : bool
isShowStaticRelations()  : bool
isUpdate()  : bool
loadFile()  : void
Loads the TYPO3 import file $fileName into memory.
processSoftReferencesFlexFormCallBack()  : array<string|int, mixed>
Callback function to traverse the FlexForm structure and remap its soft reference relations.
remapRelationsOfFlexFormCallBack()  : array<string|int, mixed>
Callback function to remap relations in FlexForm data
removeDefaultImportExportFolder()  : void
removeTemporaryFolderName()  : void
renderPreview()  : array<string|int, mixed>
Displays a preview of the import or export.
setEnableLogging()  : void
setErrorLog()  : void
setExcludeDisabledRecords()  : void
Set flag to control whether disabled records and their children are excluded (true) or included (false). Defaults to the old behaviour of including everything.
setExcludeMap()  : void
setExtensionDependencies()  : void
setForceAllUids()  : void
setGlobalIgnorePid()  : void
setImportMapId()  : void
setImportMode()  : void
setMode()  : void
setPid()  : void
setRelStaticTables()  : void
setShowDiff()  : void
setShowStaticRelations()  : void
setSoftrefCfg()  : void
setSoftrefInputValues()  : void
setUpdate()  : void
addError()  : void
Sets error message in the internal error log
addGeneralErrorsByTable()  : void
Log general error message for a given table
addRecord()  : void
Add a record, its relations and soft references, to the preview
addRelations()  : void
Add database relations of a record to the preview
addSingle()  : void
Adds a single record to the $importData array. Also copies files to the temporary folder.
addSoftRefs()  : void
Add soft references of a record to the preview
addToMapId()  : void
Store the mapping between the import file record UIDs and the final record UIDs in the database after import.
callHook()  : void
Call Hook
checkDokType()  : bool
Verifies that a table is allowed on a certain doktype of a page.
checkOrCreateDir()  : bool
Returns TRUE if directory exists and if it doesn't it will create directory and return TRUE if that succeeded.
compareRecords()  : string
Compares two records, the current database record and the one from the import memory.
createDataHandler()  : DataHandler
createDefaultImportExportFolder()  : void
Creates a \TYPO3\CMS\Core\Resource\Folder object for saving export files to the server and is also used for uploading import files.
createTemporaryFolderName()  : string
doRespectPid()  : bool
Checks if the position of an updated record is configured to be corrected.
excludePageAndRecords()  : void
Exclude a page, its sub pages (recursively) and records placed in them from this import/export
fetchStorages()  : void
Fetch all available file storages and index by storage UID
fixUidLocalInSysFileReferenceRecords()  : void
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())
flatInversePageTree()  : void
Recursively flattening the $pageTree array to a one-dimensional array with uid-pid pairs.
getBackendUser()  : BackendUserAuthentication
getDefaultUploadTemporaryFolder()  : Folder|null
Returns a \TYPO3\CMS\Core\Resource\Folder object that could be used for uploading temporary files in user context. The folder _temp_ below the default upload folder of the user is used.
getDiffUtility()  : DiffUtility
getFileadminFolderName()  : string
getFileProcObj()  : ExtendedFileUtility
Returns file processing object, initialized only once.
getLanguageService()  : LanguageService
getNextFilePart()  : array<string|int, mixed>|null
Extracts the next content part of the T3D file
getPidRecord()  : array<string|int, mixed>|null
Return record of root page of import or of export page tree - or null if access denied to that page.
getRecordFromDatabase()  : array<string|int, mixed>|null
Returns given fields of record if it exists.
getRecordPath()  : string
Returns the page title path of a PID value. Results are cached internally
getReferenceDefaultValue()  : int|float|string
Get the default value for a reference field.
getSysFileMetaDataFromDatabase()  : array<string|int, mixed>|null
Selects sys_file_metadata database record.
initializeImport()  : void
Initialize all settings for the import
isEquivalentStorage()  : bool
Determines whether the passed storage object and the storage record (sys_file_storage) can be considered equivalent during the import.
isRecordDisabled()  : bool
Test whether a record is disabled (e.g. hidden)
isRecordExcluded()  : bool
Returns TRUE if the element should be excluded from import and export.
isSoftRefIncluded()  : bool
Returns TRUE if the soft reference should be included in export.
isTableStatic()  : bool
Returns TRUE if the input table name is to be regarded as a static relation (that is, not exported etc).
loadInit()  : void
Setting up the object based on the recently loaded ->dat array
processSoftReferences()  : void
Processing of soft references
processSoftReferencesSaveFile()  : string
Process a soft reference file
processSoftReferencesSaveFileCreateRelFile()  : string|null
Create file in directory and return the new (unique) filename
processSoftReferencesSubstTokens()  : string
Substitution of soft reference tokens
remapRelationsOfField()  : array<string|int, mixed>
Maps the original record UIDs of the relations to the actual UIDs of the imported records and returns relations as strings of type [table]_[uid] - or file:[uid] or [public url] for field of type "group" and internal_type "file_reference". These strings have the regular DataHandler input group/select type format which means they will automatically be processed into a list of UIDs or MM relations.
removeSysFileReferenceRecordsWithRelationToMissingFile()  : void
Removes all sys_file_reference records from the import data array that are pointing to sys_file records which are missing in the import data to prevent exceptions on checking the related file started by the DataHandler.
renderControls()  : string
Render input controls for import or export
renderImportModeSelector()  : string
Render select box with import options for the record.
renderIndent()  : string
renderRecordExcludeCheckbox()  : string
Render check box for exclusion of a record from export.
renderSelectBox()  : string
Renders a select box from option values.
renderSoftRefExportSelector()  : string
Render select box with export options for soft references.
renderSoftRefImportTextField()  : string
Render text field when importing a soft reference.
resolveStoragePath()  : string|null
Checks if the input path relative to the public web path can be found in the file mounts of the backend user.
setFlexFormRelations()  : void
After all database relations have 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 FlexForm field!
setRelations()  : void
At the end of the import process all file and database relations should be set properly.
traverseAllRecords()  : void
Go through ALL records (if the pages are displayed first, those will not be among these!)
traversePageRecords()  : void
Go through remaining pages (not in tree)
traversePageTree()  : void
Go through page tree for display
writeFileVerify()  : bool
Writes a file from the import memory having $fileID to file name $fileName which must be an absolute path inside public web path
writePages()  : void
Writing page tree / pages to database: 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.
writePagesOrder()  : void
Organize all updated pages in page tree so they are related like in the import file.
writeRecords()  : void
Write all database records except pages (written in writePages())
writeRecordsOrder()  : void
Organize all updated records so they are related like in the import file.
writeSysFileRecords()  : void
Imports the sys_file records and the binary files data from internal data array.
writeSysFileStorageRecords()  : void
Imports the sys_file_storage records from memory data.

Constants

IMPORT_MODE_AS_NEW

public mixed IMPORT_MODE_AS_NEW = 'as_new'

IMPORT_MODE_EXCLUDE

public mixed IMPORT_MODE_EXCLUDE = 'exclude'

IMPORT_MODE_FORCE_UID

public mixed IMPORT_MODE_FORCE_UID = 'force_uid'

IMPORT_MODE_IGNORE_PID

public mixed IMPORT_MODE_IGNORE_PID = 'ignore_pid'

IMPORT_MODE_RESPECT_PID

public mixed IMPORT_MODE_RESPECT_PID = 'respect_pid'

SOFTREF_IMPORT_MODE_EDITABLE

public mixed SOFTREF_IMPORT_MODE_EDITABLE = 'editable'

SOFTREF_IMPORT_MODE_EXCLUDE

public mixed SOFTREF_IMPORT_MODE_EXCLUDE = 'exclude'

Properties

$cacheGetRecordPath

Cache for record paths

protected array<string|int, mixed> $cacheGetRecordPath = []

$dat

Internal import/export memory

protected array<string|int, mixed> $dat = []

$decompressionAvailable

protected bool $decompressionAvailable = false

$defaultImportExportFolder

protected Folder|null $defaultImportExportFolder = null

$doesImport

Set by importData() when an import is started.

protected bool $doesImport = false

$enableLogging

Disable logging when importing

protected bool $enableLogging = false

$errorLog

Error log.

protected array<string|int, mixed> $errorLog = []

$excludeDisabledRecords

Flag to control whether all disabled records and their children are excluded (true) or included (false). Defaults to the old behaviour of including everything.

protected bool $excludeDisabledRecords = false

$excludeMap

Exclude map. Keys are table:uid pairs and if set, records are not added to the export.

protected array<string|int, mixed> $excludeMap = []

$extensionDependencies

Listing extension dependencies.

protected array<string|int, mixed> $extensionDependencies = []

$fileadminFolderName

Name of the "fileadmin" folder where files for export/import should be located

protected string $fileadminFolderName = ''

$fileIdMap

Mapping between the fileID from import memory and the final filenames they are written to.

protected array<string|int, mixed> $fileIdMap = []

$forceAllUids

If set, all UID values are forced! (update or import)

protected bool $forceAllUids = false

$globalIgnorePid

If set, PID correct is ignored globally

protected bool $globalIgnorePid = false

$importMapId

After records are written this array is filled with [table][original_uid] = [new_uid]

protected array<string|int, mixed> $importMapId = []

$importMode

Setting the import mode for specific import records.

protected array<string|int, mixed> $importMode = []

Available options are: force_uid, as_new, exclude, ignore_pid, respect_pid

$importNewId

Keys are [tablename]:[new NEWxxx ids (or when updating it is uids)] while values are arrays with table/uid of the original record it is based on.

protected array<string|int, mixed> $importNewId = []

With the array keys the new ids can be looked up inside DataHandler

$importNewIdPids

Page id map for page tree (import)

protected array<string|int, mixed> $importNewIdPids = []

$isFilesSavedOutsideImportFile

protected bool $isFilesSavedOutsideImportFile = false

$mode

Whether "import" or "export" mode of object.

protected string $mode = 'import'

$permsClause

A WHERE clause for selection records from the pages table based on read-permissions of the current backend user.

protected string $permsClause

$pid

Root page of import or export page tree

protected int $pid = -1

$pidRecord

Root page record of import or of export page tree

protected array<string|int, mixed>|null $pidRecord = null

$relStaticTables

Add tables names here which should not be exported with the file.

protected array<string|int, mixed> $relStaticTables = []

(Where relations should be mapped to same UIDs in target system).

$remainHeader

protected array<string|int, mixed> $remainHeader = []

$showDiff

If set, a diff-view column is added to the preview.

protected bool $showDiff = false

$showStaticRelations

If set, static relations (not exported) will be shown in preview as well

protected bool $showStaticRelations = false

$softrefCfg

Soft reference token ID modes.

protected array<string|int, mixed> $softrefCfg = []

$softrefInputValues

Array of values to substitute in editable soft references.

protected array<string|int, mixed> $softrefInputValues = []

$storagesAvailableForImport

Array of currently registered storage objects available for importing files to

protected array<string|int, ResourceStorage> $storagesAvailableForImport = []

$suggestedInsertUids

Used to register the forced UID values for imported records that we want to create with the same UIDs as in the import file. Admin-only feature.

protected array<string|int, mixed> $suggestedInsertUids = []

$temporaryFolderName

protected string|null $temporaryFolderName = null

$update

Updates all records that has same UID instead of creating new!

protected bool $update = false

Methods

addFiles()

Add file relations of a record to the preview.

public addFiles(array<string|int, mixed> $relations, array<string|int, mixed> &$lines, int $indent[, string $tokenID = '' ]) : void

Public access for testing purpose only.

Parameters
$relations : array<string|int, mixed>

Array of file IDs

$lines : array<string|int, mixed>

Output lines array

$indent : int

Indentation level

$tokenID : string = ''

Token ID if this is a soft reference (in which case it only makes sense with a single element in the $relations array!)

Tags
see
addRecord()

getDat()

public getDat() : array<string|int, mixed>
Return values
array<string|int, mixed>

getErrorLog()

public getErrorLog() : array<string|int, mixed>
Return values
array<string|int, mixed>

getExcludeMap()

public getExcludeMap() : array<string|int, mixed>
Return values
array<string|int, mixed>

getExtensionDependencies()

public getExtensionDependencies() : array<string|int, mixed>
Return values
array<string|int, mixed>

getImportMapId()

public getImportMapId() : array<string|int, mixed>
Return values
array<string|int, mixed>

getImportMode()

public getImportMode() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMetaData()

public getMetaData() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMode()

public getMode() : string
Return values
string

getOrCreateDefaultImportExportFolder()

Returns a \TYPO3\CMS\Core\Resource\Folder object for saving export files to the server and is also used for uploading import files.

public getOrCreateDefaultImportExportFolder() : Folder|null
Return values
Folder|null

getOrCreateTemporaryFolderName()

public getOrCreateTemporaryFolderName() : string
Return values
string

getPid()

public getPid() : int
Return values
int

getRelStaticTables()

public getRelStaticTables() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSoftrefCfg()

public getSoftrefCfg() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSoftrefInputValues()

public getSoftrefInputValues() : array<string|int, mixed>
Return values
array<string|int, mixed>

hasErrors()

public hasErrors() : bool
Return values
bool

isDecompressionAvailable()

public isDecompressionAvailable() : bool
Return values
bool

isEnableLogging()

public isEnableLogging() : bool
Return values
bool

isExcludeDisabledRecords()

public isExcludeDisabledRecords() : bool
Return values
bool

isForceAllUids()

public isForceAllUids() : bool
Return values
bool

isGlobalIgnorePid()

public isGlobalIgnorePid() : bool
Return values
bool

isShowDiff()

public isShowDiff() : bool
Return values
bool

isShowStaticRelations()

public isShowStaticRelations() : bool
Return values
bool

isUpdate()

public isUpdate() : bool
Return values
bool

loadFile()

Loads the TYPO3 import file $fileName into memory.

public loadFile(string $fileName) : void
Parameters
$fileName : string

File path, has to be within the TYPO3's base folder

Tags
throws
LoadingFileFailedException

processSoftReferencesFlexFormCallBack()

Callback function to traverse the FlexForm structure and remap its soft reference relations.

public processSoftReferencesFlexFormCallBack(array<string|int, mixed> $pParams, array<string|int, mixed> $dsConf, string $dataValue, string $dataValue_ext1, string $path) : array<string|int, mixed>
Parameters
$pParams : array<string|int, mixed>

Set of parameters in numeric array: table, uid, field, soft references

$dsConf : array<string|int, mixed>

TCA config for field (from Data Structure of course)

$dataValue : string

Field value (from FlexForm XML)

$dataValue_ext1 : string

Not used

$path : string

Path of where the data structure where the element is found

Tags
see
setFlexFormRelations()
Return values
array<string|int, mixed>

Array where the "value" key carries the value.

remapRelationsOfFlexFormCallBack()

Callback function to remap relations in FlexForm data

public remapRelationsOfFlexFormCallBack(array<string|int, mixed> $pParams, array<string|int, mixed> $dsConf, string $dataValue, string $dataValue_ext1, string $path) : array<string|int, mixed>
Parameters
$pParams : array<string|int, mixed>

Set of parameters passed through by calling method setFlexFormRelations()

$dsConf : array<string|int, mixed>

TCA config for field (from Data Structure of course)

$dataValue : string

Field value (from FlexForm XML)

$dataValue_ext1 : string

Not used

$path : string

Path of where the data structure of the element is found

Tags
see
setFlexFormRelations()
Return values
array<string|int, mixed>

Array where the "value" key carries the mapped relation string.

removeDefaultImportExportFolder()

public removeDefaultImportExportFolder() : void

removeTemporaryFolderName()

public removeTemporaryFolderName() : void

renderPreview()

Displays a preview of the import or export.

public renderPreview() : array<string|int, mixed>
Return values
array<string|int, mixed>

The preview data

setEnableLogging()

public setEnableLogging(bool $enableLogging) : void
Parameters
$enableLogging : bool

setErrorLog()

public setErrorLog(array<string|int, mixed> $errorLog) : void
Parameters
$errorLog : array<string|int, mixed>

setExcludeDisabledRecords()

Set flag to control whether disabled records and their children are excluded (true) or included (false). Defaults to the old behaviour of including everything.

public setExcludeDisabledRecords(bool $excludeDisabledRecords) : void
Parameters
$excludeDisabledRecords : bool

Set to true if if all disabled records should be excluded, false otherwise

setExcludeMap()

public setExcludeMap(array<string|int, mixed> $excludeMap) : void
Parameters
$excludeMap : array<string|int, mixed>

setExtensionDependencies()

public setExtensionDependencies(array<string|int, mixed> $extensionDependencies) : void
Parameters
$extensionDependencies : array<string|int, mixed>

setForceAllUids()

public setForceAllUids(bool $forceAllUids) : void
Parameters
$forceAllUids : bool

setGlobalIgnorePid()

public setGlobalIgnorePid(bool $globalIgnorePid) : void
Parameters
$globalIgnorePid : bool

setImportMapId()

public setImportMapId(array<string|int, mixed> $importMapId) : void
Parameters
$importMapId : array<string|int, mixed>

setImportMode()

public setImportMode(array<string|int, mixed> $importMode) : void
Parameters
$importMode : array<string|int, mixed>

setMode()

public setMode(string $mode) : void
Parameters
$mode : string

setPid()

public setPid(int $pid) : void
Parameters
$pid : int

setRelStaticTables()

public setRelStaticTables(array<string|int, mixed> $relStaticTables) : void
Parameters
$relStaticTables : array<string|int, mixed>

setShowDiff()

public setShowDiff(bool $showDiff) : void
Parameters
$showDiff : bool

setShowStaticRelations()

public setShowStaticRelations(bool $showStaticRelations) : void
Parameters
$showStaticRelations : bool

setSoftrefCfg()

public setSoftrefCfg(array<string|int, mixed> $softrefCfg) : void
Parameters
$softrefCfg : array<string|int, mixed>

setSoftrefInputValues()

public setSoftrefInputValues(array<string|int, mixed> $softrefInputValues) : void
Parameters
$softrefInputValues : array<string|int, mixed>

setUpdate()

public setUpdate(bool $update) : void
Parameters
$update : bool

addError()

Sets error message in the internal error log

protected addError(string $message) : void
Parameters
$message : string

Error message

addGeneralErrorsByTable()

Log general error message for a given table

protected addGeneralErrorsByTable(string $table) : void
Parameters
$table : string

database table name

addRecord()

Add a record, its relations and soft references, to the preview

protected addRecord(string $table, int $uid, array<string|int, mixed> &$lines, int $indent[, bool $checkImportInPidRecord = false ]) : void
Parameters
$table : string

Table name

$uid : int

Record uid

$lines : array<string|int, mixed>

Output lines array

$indent : int

Indentation level

$checkImportInPidRecord : bool = false

If you want import validation, you can set this so it checks if the import can take place on the specified page.

addRelations()

Add database relations of a record to the preview

protected addRelations(array<string|int, mixed> $relations, array<string|int, mixed> &$lines, int $indent[, array<string|int, mixed> $recursionCheck = [] ]) : void
Parameters
$relations : array<string|int, mixed>

Array of relations

$lines : array<string|int, mixed>

Output lines array

$indent : int

Indentation level

$recursionCheck : array<string|int, mixed> = []

Recursion check stack

Tags
see
addRecord()

addSingle()

Adds a single record to the $importData array. Also copies files to the temporary folder.

protected addSingle(array<string|int, mixed> &$importData, string $table, int $uid, int|string $pid) : void

However all file and database references and flexform fields are set to blank for now! That is processed with setRelations() later.

Parameters
$importData : array<string|int, mixed>

Data to be modified or inserted in the database during import

$table : string

Table name

$uid : int

Record UID

$pid : int|string

Page id or NEW-id, e.g. "NEW5fb3c2641281c885267727"

Tags
see
setRelations()

addSoftRefs()

Add soft references of a record to the preview

protected addSoftRefs(array<string|int, mixed> $softrefs, array<string|int, mixed> &$lines, int $indent) : void
Parameters
$softrefs : array<string|int, mixed>

Soft references

$lines : array<string|int, mixed>

Output lines array

$indent : int

Indentation level

Tags
see
addRecord()

addToMapId()

Store the mapping between the import file record UIDs and the final record UIDs in the database after import.

protected addToMapId(array<string|int, mixed> $importData, array<string|int, mixed> $substNEWwithIDs) : void
Parameters
$importData : array<string|int, mixed>

Data to be modified or inserted in the database during import

$substNEWwithIDs : array<string|int, mixed>

A map between the "NEW..." string IDs and the eventual record UID in database

Tags
see
writeRecords()

callHook()

Call Hook

protected callHook(string $name, array<string|int, mixed> $params) : void
Parameters
$name : string

Name of the hook

$params : array<string|int, mixed>

Array with params

checkDokType()

Verifies that a table is allowed on a certain doktype of a page.

protected checkDokType(string $table, int $dokType) : bool
Parameters
$table : string

Table name to check

$dokType : int

Page doktype

Return values
bool

TRUE if OK

checkOrCreateDir()

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

protected checkOrCreateDir(string $dirPrefix) : bool
Parameters
$dirPrefix : string

Directory to create. Having a trailing slash. Must be in fileadmin/. Relative to public web path

Return values
bool

TRUE, if directory exists (was created)

compareRecords()

Compares two records, the current database record and the one from the import memory.

protected compareRecords(array<string|int, mixed> $databaseRecord, array<string|int, mixed> $importRecord, string $table[, bool $inverse = false ]) : string

Will return HTML code to show any differences between them!

Parameters
$databaseRecord : array<string|int, mixed>

Database record, all fields (old values)

$importRecord : array<string|int, mixed>

Import memory record for the same table/uid, all fields (new values)

$table : string

The table name of the record

$inverse : bool = false

Inverse the diff view (switch red/green, needed for pre-update difference view)

Return values
string

HTML

createDefaultImportExportFolder()

Creates a \TYPO3\CMS\Core\Resource\Folder object for saving export files to the server and is also used for uploading import files.

protected createDefaultImportExportFolder() : void

createTemporaryFolderName()

protected createTemporaryFolderName() : string
Return values
string

doRespectPid()

Checks if the position of an updated record is configured to be corrected.

protected doRespectPid(string $table, int $uid) : bool

This can be disabled globally and changed individually for elements.

Parameters
$table : string

Table name

$uid : int

Record UID

Return values
bool

TRUE if the position of the record should be updated to match the one in the import structure

excludePageAndRecords()

Exclude a page, its sub pages (recursively) and records placed in them from this import/export

protected excludePageAndRecords(int $pageUid, array<string|int, mixed> $page) : void
Parameters
$pageUid : int

Uid of the page to exclude

$page : array<string|int, mixed>

Page array with uid/subrow (from ->dat[header][pagetree])

fetchStorages()

Fetch all available file storages and index by storage UID

protected fetchStorages() : void

Note: It also creates a default storage record if the database table sys_file_storage is empty, e.g. during tests.

fixUidLocalInSysFileReferenceRecords()

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())

protected fixUidLocalInSysFileReferenceRecords(int $oldFileUid, int $newFileUid) : void

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
$oldFileUid : int
$newFileUid : int

flatInversePageTree()

Recursively flattening the $pageTree array to a one-dimensional array with uid-pid pairs.

protected flatInversePageTree(array<string|int, mixed> $pageTree, array<string|int, mixed> &$list[, int $pid = -1 ]) : void
Parameters
$pageTree : array<string|int, mixed>

Page tree array

$list : array<string|int, mixed>

List with uid-pid pairs

$pid : int = -1

PID value (internal, don't set from outside)

getDefaultUploadTemporaryFolder()

Returns a \TYPO3\CMS\Core\Resource\Folder object that could be used for uploading temporary files in user context. The folder _temp_ below the default upload folder of the user is used.

protected getDefaultUploadTemporaryFolder() : Folder|null
Return values
Folder|null

getFileadminFolderName()

protected getFileadminFolderName() : string
Return values
string

getNextFilePart()

Extracts the next content part of the T3D file

protected getNextFilePart(resource $fd, string $name) : array<string|int, mixed>|null
Parameters
$fd : resource

Import file pointer

$name : string

For error messages this indicates the section of the problem.

Tags
see
loadFile()
Return values
array<string|int, mixed>|null

Data array or NULL in case of an error

getPidRecord()

Return record of root page of import or of export page tree - or null if access denied to that page.

protected getPidRecord() : array<string|int, mixed>|null

If the page is the root of the page tree, add some basic but missing information.

Return values
array<string|int, mixed>|null

getRecordFromDatabase()

Returns given fields of record if it exists.

protected getRecordFromDatabase(string $table, int $uid[, string $fields = 'uid,pid' ]) : array<string|int, mixed>|null
Parameters
$table : string

Table name

$uid : int

UID of record

$fields : string = 'uid,pid'

Field list to select. Default is "uid,pid"

Return values
array<string|int, mixed>|null

Result of \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord() which means the record if found, otherwise NULL

getRecordPath()

Returns the page title path of a PID value. Results are cached internally

protected getRecordPath(int $pid) : string
Parameters
$pid : int

Record PID to check

Return values
string

The path for the input PID

getReferenceDefaultValue()

Get the default value for a reference field.

protected getReferenceDefaultValue(array<string|int, mixed> $configuration) : int|float|string
Parameters
$configuration : array<string|int, mixed>

The TCA configuration of the accordant field

Return values
int|float|string

getSysFileMetaDataFromDatabase()

Selects sys_file_metadata database record.

protected getSysFileMetaDataFromDatabase(int $file, int $sysLanguageUid) : array<string|int, mixed>|null
Parameters
$file : int
$sysLanguageUid : int
Return values
array<string|int, mixed>|null

initializeImport()

Initialize all settings for the import

protected initializeImport() : void

isEquivalentStorage()

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

protected isEquivalentStorage(ResourceStorage $storageObject, array<string|int, mixed> &$storageRecord) : bool
Parameters
$storageObject : ResourceStorage

The storage object which should get compared

$storageRecord : array<string|int, mixed>

The storage record which should get compared

Return values
bool

Returns TRUE if both storage representations can be considered equal

isRecordDisabled()

Test whether a record is disabled (e.g. hidden)

protected isRecordDisabled(string $table, int $uid) : bool
Parameters
$table : string

Name of the records' database table

$uid : int

Database uid of the record

Return values
bool

true if the record is disabled, false otherwise

isRecordExcluded()

Returns TRUE if the element should be excluded from import and export.

protected isRecordExcluded(string $table, int $uid) : bool
Parameters
$table : string

Table name

$uid : int

Record UID

Return values
bool

TRUE, if the record should be excluded

isSoftRefIncluded()

Returns TRUE if the soft reference should be included in export.

protected isSoftRefIncluded(string $tokenID) : bool
Parameters
$tokenID : string

Token ID for soft reference

Return values
bool

TRUE, if soft reference should be included

isTableStatic()

Returns TRUE if the input table name is to be regarded as a static relation (that is, not exported etc).

protected isTableStatic(string $table) : bool
Parameters
$table : string

Table name

Return values
bool

TRUE, if table is marked static

loadInit()

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

protected loadInit() : void

processSoftReferences()

Processing of soft references

protected processSoftReferences() : void

processSoftReferencesSaveFile()

Process a soft reference file

protected processSoftReferencesSaveFile(string $relFileName, array<string|int, mixed> $softref, string $table, string $uid) : string
Parameters
$relFileName : string

Old Relative filename

$softref : array<string|int, mixed>

Soft reference

$table : string

Table for which the processing occurs

$uid : string

UID of record from table

Return values
string

New relative filename (value to insert instead of the softref token)

processSoftReferencesSaveFileCreateRelFile()

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

protected processSoftReferencesSaveFileCreateRelFile(string $origDirPrefix, string $fileName, string $fileID, string $table, string $uid) : string|null
Parameters
$origDirPrefix : string

Directory prefix, relative, with trailing slash

$fileName : string

Filename (without path)

$fileID : string

File ID from import memory

$table : string

Table for which the processing occurs

$uid : string

UID of record from table

Return values
string|null

New relative filename, if any

processSoftReferencesSubstTokens()

Substitution of soft reference tokens

protected processSoftReferencesSubstTokens(string $tokenizedContent, array<string|int, mixed> $softrefs, string $table, string $uid) : string
Parameters
$tokenizedContent : string

Content of field with soft reference tokens in.

$softrefs : array<string|int, mixed>

Soft references

$table : string

Table of record for which the processing occurs

$uid : string

UID of record from table

Return values
string

The input content with tokens substituted according to entries in $softrefs

remapRelationsOfField()

Maps the original record UIDs of the relations to the actual UIDs of the imported records and returns relations as strings of type [table]_[uid] - or file:[uid] or [public url] for field of type "group" and internal_type "file_reference". These strings have the regular DataHandler input group/select type format which means they will automatically be processed into a list of UIDs or MM relations.

protected remapRelationsOfField(array<string|int, mixed> $fieldRelations, array<string|int, mixed> $fieldConfig[, string $field = '' ]) : array<string|int, mixed>
Parameters
$fieldRelations : array<string|int, mixed>

Relations with original record UIDs

$fieldConfig : array<string|int, mixed>

TCA configuration of the record field the relations belong to

$field : string = ''

The TCA fieldname of the relation operated on

Return values
array<string|int, mixed>

Array of relation strings with actual record UIDs

removeSysFileReferenceRecordsWithRelationToMissingFile()

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

protected removeSysFileReferenceRecordsWithRelationToMissingFile() : void

renderControls()

Render input controls for import or export

protected renderControls(array<string|int, mixed> $line) : string
Parameters
$line : array<string|int, mixed>

Output line array

Return values
string

HTML

renderImportModeSelector()

Render select box with import options for the record.

protected renderImportModeSelector(string $table, int $uid, bool $doesRecordExist) : string
Parameters
$table : string

Table name

$uid : int

Record UID

$doesRecordExist : bool

Is there already a record with this UID in the database?

Return values
string

HTML

renderIndent()

protected renderIndent(int $indent) : string
Parameters
$indent : int
Return values
string

renderRecordExcludeCheckbox()

Render check box for exclusion of a record from export.

protected renderRecordExcludeCheckbox(string $recordRef) : string
Parameters
$recordRef : string

The record ID of the form [table]:[id].

Return values
string

HTML

renderSelectBox()

Renders a select box from option values.

protected renderSelectBox(string $name, string $value, array<string|int, mixed> $options) : string
Parameters
$name : string

Form element name

$value : string

Current value

$options : array<string|int, mixed>

Options to display (key/value pairs)

Return values
string

HTML

renderSoftRefExportSelector()

Render select box with export options for soft references.

protected renderSoftRefExportSelector(array<string|int, mixed> $softref) : string

An export box is shown only if a substitution scheme is found for the soft reference.

Parameters
$softref : array<string|int, mixed>

Soft reference

Return values
string

HTML

renderSoftRefImportTextField()

Render text field when importing a soft reference.

protected renderSoftRefImportTextField(array<string|int, mixed> $softref) : string
Parameters
$softref : array<string|int, mixed>

Soft reference

Return values
string

HTML

resolveStoragePath()

Checks if the input path relative to the public web path can be found in the file mounts of the backend user.

protected resolveStoragePath(string $dirPrefix[, bool $checkAlternatives = true ]) : string|null

If not, it checks all file mounts of the user for the relative path and returns it if found.

Parameters
$dirPrefix : string

Path relative to public web path.

$checkAlternatives : bool = true

If set to false, do not look for an alternative path.

Tags
throws
Exception
Return values
string|null

If a path is available, it will be returned, otherwise NULL.

setFlexFormRelations()

After all database relations have 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 FlexForm field!

protected setFlexFormRelations() : void
Tags
see
setRelations()

setRelations()

At the end of the import process all file and database relations should be set properly.

protected setRelations() : void

This means that the relations to imported records are all recreated so that the imported records are correctly related again. Relations in flexform fields are processed in setFlexFormRelations() after this function.

Tags
see
setFlexFormRelations()

traverseAllRecords()

Go through ALL records (if the pages are displayed first, those will not be among these!)

protected traverseAllRecords(array<string|int, mixed> $pageTree, array<string|int, mixed> &$lines) : void
Parameters
$pageTree : array<string|int, mixed>

Page tree array with uid/subrow (from ->dat[header][pagetree])

$lines : array<string|int, mixed>

Output lines array

traversePageRecords()

Go through remaining pages (not in tree)

protected traversePageRecords(array<int, array<string|int, mixed>> $pageTree, array<string|int, mixed> &$lines) : void
Parameters
$pageTree : array<int, array<string|int, mixed>>

Page tree array with uid/subrow (from ->dat[header][pagetree])

$lines : array<string|int, mixed>

Output lines array

traversePageTree()

Go through page tree for display

protected traversePageTree(array<int, array<string|int, mixed>> $pageTree, array<string|int, mixed> &$lines[, int $indent = 0 ]) : void
Parameters
$pageTree : array<int, array<string|int, mixed>>

Page tree array with uid/subrow (from ->dat[header][pagetree])

$lines : array<string|int, mixed>

Output lines array

$indent : int = 0

Indentation level

writeFileVerify()

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

protected writeFileVerify(string $fileName, string $fileID) : bool
Parameters
$fileName : string

Absolute filename inside public web path to write to

$fileID : string

File ID from import memory

Return values
bool

Returns TRUE if it went well. Notice that the content of the file is read again, and md5 from import memory is validated.

writePages()

Writing page tree / pages to database: 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.

protected writePages() : void
Tags
see
writeRecords()

writePagesOrder()

Organize all updated pages in page tree so they are related like in the import file.

protected writePagesOrder() : void

Only used for updates.

Tags
see
writePages()
see
writeRecordsOrder()

writeRecords()

Write all database records except pages (written in writePages())

protected writeRecords() : void
Tags
see
writePages()

writeRecordsOrder()

Organize all updated records so they are related like in the import file.

protected writeRecordsOrder() : void

Only used for updates.

Tags
see
writeRecords()
see
writePagesOrder()

writeSysFileRecords()

Imports the sys_file records and the binary files data from internal data array.

protected writeSysFileRecords() : void

writeSysFileStorageRecords()

Imports the sys_file_storage records from memory data.

protected writeSysFileStorageRecords() : void

        
On this page

Search results