ImportExport

abstract class \TYPO3\CMS\Impexp\ImportExport

T3D file Import / Export library (TYPO3 Record Document)

Table of Contents

Properties

$cacheGetRecordPath  : array
Cache for record paths
$dat  : array
Internal import/export memory
$defaultImportExportFolder  : Folder|null
$doesImport  : bool
Set by importData() when an import is started.
$errorLog  : array
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
Exclude map. Keys are table:uid pairs and if set, records are not added to the export.
$extensionDependencies  : array
Listing extension dependencies.
$fileIdMap  : array
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
After records are written this array is filled with [table][original_uid] = [new_uid]
$importMode  : array
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|null
Root page record of import or of export page tree
$relStaticTables  : array
Add tables names here which should not be exported with the file.
$remainHeader  : array
$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
Soft reference token ID modes.
$softrefInputValues  : array
Array of values to substitute in editable soft references.
$tcaSchemaFactory  : TcaSchemaFactory
$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
getErrorLog()  : array
getExcludeMap()  : array
getExtensionDependencies()  : array
getImportMapId()  : array
getImportMode()  : array
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
getSoftrefCfg()  : array
getSoftrefInputValues()  : array
hasErrors()  : bool
isExcludeDisabledRecords()  : bool
isForceAllUids()  : bool
isGlobalIgnorePid()  : bool
isShowDiff()  : bool
isShowStaticRelations()  : bool
isUpdate()  : bool
removeDefaultImportExportFolder()  : void
removeTemporaryFolderName()  : void
renderPreview()  : array
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|null
Return record of root page of import or of export page tree - or null if access denied to that page.
getRecordFromDatabase()  : array|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 $cacheGetRecordPath = []

$dat

Internal import/export memory

protected array $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 $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 $excludeMap = []

$extensionDependencies

Listing extension dependencies.

protected array $extensionDependencies = []

$fileIdMap

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

protected array $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 $importMapId = []

$importMode

Setting the import mode for specific import records.

protected array $importMode = []

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

$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|null $pidRecord = null

$relStaticTables

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

protected array $relStaticTables = []

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

$remainHeader

protected array $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 $softrefCfg = []

$softrefInputValues

Array of values to substitute in editable soft references.

protected array $softrefInputValues = []

$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 $relations, array &$lines, int $indent[, string $tokenID = '' ]) : void

Public access for testing purpose only.

Parameters

$relations : array

Array of file IDs

$lines : array

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

Return values

array

getErrorLog()

public getErrorLog() : array

Return values

array

getExcludeMap()

public getExcludeMap() : array

Return values

array

getExtensionDependencies()

public getExtensionDependencies() : array

Return values

array

getImportMapId()

public getImportMapId() : array

Return values

array

getImportMode()

public getImportMode() : array

Return values

array

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

Return values

array

getSoftrefCfg()

public getSoftrefCfg() : array

Return values

array

getSoftrefInputValues()

public getSoftrefInputValues() : array

Return values

array

hasErrors()

public hasErrors() : 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

removeDefaultImportExportFolder()

public removeDefaultImportExportFolder() : void

removeTemporaryFolderName()

public removeTemporaryFolderName() : void

renderPreview()

Displays a preview of the import or export.

public renderPreview() : array

Return values

array —

The preview data

setErrorLog()

public setErrorLog(array $errorLog) : void

Parameters

$errorLog : array

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 $excludeMap) : void

Parameters

$excludeMap : array

setExtensionDependencies()

public setExtensionDependencies(array $extensionDependencies) : void

Parameters

$extensionDependencies : array

setForceAllUids()

public setForceAllUids(bool $forceAllUids) : void

Parameters

$forceAllUids : bool

setGlobalIgnorePid()

public setGlobalIgnorePid(bool $globalIgnorePid) : void

Parameters

$globalIgnorePid : bool

setImportMapId()

public setImportMapId(array $importMapId) : void

Parameters

$importMapId : array

setImportMode()

public setImportMode(array $importMode) : void

Parameters

$importMode : array

setMode()

public setMode(string $mode) : void

Parameters

$mode : string

setPid()

public setPid(int $pid) : void

Parameters

$pid : int

setRelStaticTables()

public setRelStaticTables(array $relStaticTables) : void

Parameters

$relStaticTables : array

setShowDiff()

public setShowDiff(bool $showDiff) : void

Parameters

$showDiff : bool

setShowStaticRelations()

public setShowStaticRelations(bool $showStaticRelations) : void

Parameters

$showStaticRelations : bool

setSoftrefCfg()

public setSoftrefCfg(array $softrefCfg) : void

Parameters

$softrefCfg : array

setSoftrefInputValues()

public setSoftrefInputValues(array $softrefInputValues) : void

Parameters

$softrefInputValues : array

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 &$lines, int $indent[, bool $checkImportInPidRecord = false ]) : void

Parameters

$table : string

Table name

$uid : int

Record uid

$lines : array

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 $relations, array &$lines, int $indent[, array $recursionCheck = [] ]) : void

Parameters

$relations : array

Array of relations

$lines : array

Output lines array

$indent : int

Indentation level

$recursionCheck : array = []

Recursion check stack

Tags

see
addRecord()

addSoftRefs()

Add soft references of a record to the preview

protected addSoftRefs(array $softrefs, array &$lines, int $indent) : void

Parameters

$softrefs : array

Soft references

$lines : array

Output lines array

$indent : int

Indentation level

Tags

see
addRecord()

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 $databaseRecord, array $importRecord, string $table[, bool $inverse = false ]) : string

Will return HTML code to show any differences between them!

Parameters

$databaseRecord : array

Database record, all fields (old values)

$importRecord : array

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

excludePageAndRecords()

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

protected excludePageAndRecords(int $pageUid, array $page) : void

Parameters

$pageUid : int

Uid of the page to exclude

$page : array

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 $pageTree, array &$list[, int $pid = -1 ]) : void

Parameters

$pageTree : array

Page tree array

$list : array

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

getPidRecord()

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

protected getPidRecord() : array|null

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

Return values

array|null

getRecordFromDatabase()

Returns given fields of record if it exists.

protected getRecordFromDatabase(string $table, int $uid[, string $fields = 'uid,pid' ]) : array|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|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 $line) : string

Parameters

$line : array

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 $options) : string

Parameters

$name : string

Form element name

$value : string

Current value

$options : array

Options to display (key/value pairs)

Return values

string —

HTML

renderSoftRefExportSelector()

Render select box with export options for soft references.

protected renderSoftRefExportSelector(array $softref) : string

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

Parameters

$softref : array

Soft reference

Return values

string —

HTML

renderSoftRefImportTextField()

Render text field when importing a soft reference.

protected renderSoftRefImportTextField(array $softref) : string

Parameters

$softref : array

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.

traverseAllRecords()

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

protected traverseAllRecords(array $pageTree, array &$lines) : void

Parameters

$pageTree : array

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

$lines : array

Output lines array

traversePageRecords()

Go through remaining pages (not in tree)

protected traversePageRecords(array<int, array> $pageTree, array &$lines) : void

Parameters

$pageTree : array<int, array>

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

$lines : array

Output lines array

traversePageTree()

Go through page tree for display

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

Parameters

$pageTree : array<int, array>

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

$lines : array

Output lines array

$indent : int = 0

Indentation level

On this page