ImportExport
T3D file Import / Export library (TYPO3 Record Document)
This class is not considered part of the public TYPO3 API.
Table of Contents
Properties
- $cacheGetRecordPath : array<string|int, mixed>
- Cache for record paths
- $dat : array<string|int, mixed>
- Internal import/export memory
- $defaultImportExportFolder : Folder|null
- $doesImport : bool
- Set by importData() when an import is started.
- $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.
- $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.
- $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.
- $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.
- 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>
- 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
- isExcludeDisabledRecords() : bool
- isForceAllUids() : bool
- isGlobalIgnorePid() : bool
- isShowDiff() : bool
- isShowStaticRelations() : bool
- isUpdate() : bool
- removeDefaultImportExportFolder() : void
- removeTemporaryFolderName() : void
- renderPreview() : array<string|int, mixed>
- Displays a preview of the import or export.
- 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
- addSoftRefs() : void
- Add soft references of a record to the preview
- checkDokType() : bool
- Verifies that a table is allowed on a certain doktype of a page.
- compareRecords() : string
- Compares two records, the current database record and the one from the import memory.
- 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
- excludePageAndRecords() : void
- Exclude a page, its sub pages (recursively) and records placed in them from this import/export
- 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
- getFileProcObj() : ExtendedFileUtility
- Returns file processing object, initialized only once.
- getLanguageService() : LanguageService
- 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
- 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).
- 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.
- 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
Properties
$cacheGetRecordPath
Cache for record paths
protected
array<string|int, mixed>
$cacheGetRecordPath
= []
$dat
Internal import/export memory
protected
array<string|int, mixed>
$dat
= []
$defaultImportExportFolder
protected
Folder|null
$defaultImportExportFolder
= null
$doesImport
Set by importData() when an import is started.
protected
bool
$doesImport
= 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
= []
$fileIdMap
Mapping between the fileID from import memory and the final filenames they are written to.
protected
array<string|int, mixed>
$fileIdMap
= []
$fileProcObj
File processing object
protected
ExtendedFileUtility|null
$fileProcObj
= null
$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
$iconFactory
protected
IconFactory
$iconFactory
$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
$lang
protected
LanguageService
$lang
$mode
Whether "import" or "export" mode of object.
protected
string
$mode
= ''
$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
= []
$temporaryFolderName
protected
string|null
$temporaryFolderName
= null
$update
Updates all records that has same UID instead of creating new!
protected
bool
$update
= false
Methods
__construct()
public
__construct() : mixed
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
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>getMode()
public
getMode() : string
Return values
stringgetOrCreateDefaultImportExportFolder()
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|nullgetOrCreateTemporaryFolderName()
public
getOrCreateTemporaryFolderName() : string
Return values
stringgetPid()
public
getPid() : int
Return values
intgetRelStaticTables()
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
boolisExcludeDisabledRecords()
public
isExcludeDisabledRecords() : bool
Return values
boolisForceAllUids()
public
isForceAllUids() : bool
Return values
boolisGlobalIgnorePid()
public
isGlobalIgnorePid() : bool
Return values
boolisShowDiff()
public
isShowDiff() : bool
Return values
boolisShowStaticRelations()
public
isShowStaticRelations() : bool
Return values
boolisUpdate()
public
isUpdate() : bool
Return values
boolremoveDefaultImportExportFolder()
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
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
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
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
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
stringexcludePageAndRecords()
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])
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)
getBackendUser()
protected
getBackendUser() : BackendUserAuthentication
Return values
BackendUserAuthenticationgetDefaultUploadTemporaryFolder()
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|nullgetDiffUtility()
protected
getDiffUtility() : DiffUtility
Return values
DiffUtilitygetFileProcObj()
Returns file processing object, initialized only once.
protected
getFileProcObj() : ExtendedFileUtility
Return values
ExtendedFileUtility —File processor object
getLanguageService()
protected
getLanguageService() : LanguageService
Return values
LanguageServicegetPidRecord()
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>|nullgetRecordFromDatabase()
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
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
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
stringrenderRecordExcludeCheckbox()
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
Return values
string|null —If a path is available, it will be returned, otherwise NULL.
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