Import

class \TYPO3\CMS\Impexp\Import

Extends
ImportExport
Uses
ResourceInstructionTrait

T3D file Import library (TYPO3 Record Document)

Attributes

#[Autoconfigure]
$public: true
$shared: false

Table of Contents

Constants

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

Properties

$cacheGetRecordPath  : array
Cache for record paths
$connectionPool  : ConnectionPool
$dat  : array
Internal import/export memory
$defaultImportExportFolder  : Folder|null
$defaultStorage  : ResourceStorage|null
Currently registered default storage object
$defaultUploadFolderResolver  : DefaultUploadFolderResolver
$diffUtility  : DiffUtility
$doesImport  : bool
Set by importData() when an import is started.
$enableLogging  : bool
Disable logging when importing
$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.
$fileNameValidator  : FileNameValidator
$fileProcObj  : ExtendedFileUtility|null
File processing object
$flexFormTools  : FlexFormTools
$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.
$importNewId  : array
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
Page id map for page tree (import)
$importSiteConfigurations  : bool
When false, processSiteConfigurations() is skipped. Set to false when the caller (e.g. a distribution installer) handles site configuration import itself.
$isFilesSavedOutsideImportFile  : bool
$mode  : string
Whether "import" or "export" mode of object.
$pageDoktypeRegistry  : PageDoktypeRegistry
$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
$resourceFactory  : ResourceFactory
$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
$siteFinder  : SiteFinder
$siteWriter  : SiteWriter
$softrefCfg  : array
Soft reference token ID modes.
$softrefInputValues  : array
Array of values to substitute in editable soft references.
$storageRepository  : StorageRepository
$storages  : ResourceStorage[]
Array of currently registered storage objects
$storagesAvailableForImport  : ResourceStorage[]
Array of currently registered storage objects available for importing files to
$suggestedInsertUids  : array
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.
$tcaSchemaFactory  : TcaSchemaFactory
$temporaryFolderName  : string|null
$update  : bool
Updates all records that has same UID instead of creating new!

Methods

__construct()  : mixed
checkImportPrerequisites()  : void
Checks all requirements that must be met before import.
disableSiteConfigurationImport()  : void
Disable automatic site configuration import. Call this when the invoking code (e.g. a distribution installer) handles site configuration itself.
getErrorLog()  : array
getImportMapId()  : array
getMetaData()  : 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
getSiteConfigurations()  : array
hasErrors()  : bool
importData()  : void
Imports the memory data into the TYPO3 database.
injectDefaultUploadFolderResolver()  : void
injectDiffUtility()  : void
injectFileNameValidator()  : void
injectIconFactory()  : void
injectPageDoktypeRegistry()  : void
injectResourceFactory()  : void
injectTcaSchemaFactory()  : void
loadFile()  : void
Loads the TYPO3 import file $fileName into memory.
removeDefaultImportExportFolder()  : void
removeTemporaryFolderName()  : void
renderPreview()  : array
Displays a preview of the import or export.
setEnableLogging()  : 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
setImportMode()  : 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
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.
getFileProcObj()  : ExtendedFileUtility
Returns file processing object, initialized only once.
getLanguageService()  : LanguageService
getNextFilePart()  : array|null
Extracts the next content part of the T3D file
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
getReferenceDefaultValue()  : int|float|string
Get the default value for a reference field.
getSysFileMetaDataFromDatabase()  : array|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
processSiteConfigurations()  : void
Write site configurations embedded in the import file.
processSoftReferences()  : void
Processing of soft references
processSoftReferencesSubstTokens()  : string
Substitution of soft reference tokens
remapRelationsOfField()  : array
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 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.
sortPageUidsParentsFirst()  : array<int, int>
Page translations are appended to the exported page tree as top level nodes, so a translation may be listed before the page it belongs to. Order the pages in a way that each page is preceded by its parent page, since the parent needs to have been assigned its new ID before a page can be related to it.
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
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 $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

$enableLogging

Disable logging when importing

protected bool $enableLogging = 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 = []

$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

$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 $importNewId = []

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

$importNewIdPids

Page id map for page tree (import)

protected array $importNewIdPids = []

$importSiteConfigurations

When false, processSiteConfigurations() is skipped. Set to false when the caller (e.g. a distribution installer) handles site configuration import itself.

protected bool $importSiteConfigurations = true

$isFilesSavedOutsideImportFile

protected bool $isFilesSavedOutsideImportFile = false

$mode

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

protected string $mode = 'import'

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

$storagesAvailableForImport

Array of currently registered storage objects available for importing files to

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

$temporaryFolderName

protected string|null $temporaryFolderName = null

$update

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

protected bool $update = false

Methods

disableSiteConfigurationImport()

Disable automatic site configuration import. Call this when the invoking code (e.g. a distribution installer) handles site configuration itself.

public disableSiteConfigurationImport() : void

getErrorLog()

public getErrorLog() : array

Return values

array

getImportMapId()

public getImportMapId() : array

Return values

array

getMetaData()

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

getSiteConfigurations()

public getSiteConfigurations() : array

Return values

array

hasErrors()

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

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

setEnableLogging()

public setEnableLogging(bool $enableLogging) : void

Parameters

$enableLogging : bool

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

setImportMode()

public setImportMode(array $importMode) : void

Parameters

$importMode : array

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

addSingle()

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

protected addSingle(array &$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

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"

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

addToMapId()

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

protected addToMapId(array $importData, array $substNEWwithIDs) : void

Parameters

$importData : array

Data to be modified or inserted in the database during import

$substNEWwithIDs : array

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

callHook()

protected callHook(string $name, array $params) : void

Parameters

$name : string

Name of the hook

$params : array

Array with params

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

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

Parameters

$pageUid : int

Uid of the page to exclude

$page : array

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 $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

getNextFilePart()

Extracts the next content part of the T3D file

protected getNextFilePart(resource $fd, string $name) : array|null

Parameters

$fd : resource

Import file pointer

$name : string

For error messages this indicates the section of the problem.

Return values

array|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|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

getReferenceDefaultValue()

Get the default value for a reference field.

protected getReferenceDefaultValue(array $configuration) : int|float|string

Parameters

$configuration : array

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|null

Parameters

$file : int
$sysLanguageUid : int

Return values

array|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 &$storageRecord) : bool

Parameters

$storageObject : ResourceStorage

The storage object which should get compared

$storageRecord : array

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

processSiteConfigurations()

Write site configurations embedded in the import file.

protected processSiteConfigurations() : void

Skips any site whose identifier already exists. Remaps rootPageId from the export UID to the newly imported UID.

processSoftReferences()

Processing of soft references

protected processSoftReferences() : void

processSoftReferencesSubstTokens()

Substitution of soft reference tokens

protected processSoftReferencesSubstTokens(string $tokenizedContent, array $softrefs, string $table, string $uid) : string

Parameters

$tokenizedContent : string

Content of field with soft reference tokens in.

$softrefs : array

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 $fieldRelations, array $fieldConfig[, string $field = '' ]) : array

Parameters

$fieldRelations : array

Relations with original record UIDs

$fieldConfig : array

TCA configuration of the record field the relations belong to

$field : string = ''

The TCA fieldname of the relation operated on

Return values

array —

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 $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.

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

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.

sortPageUidsParentsFirst()

Page translations are appended to the exported page tree as top level nodes, so a translation may be listed before the page it belongs to. Order the pages in a way that each page is preceded by its parent page, since the parent needs to have been assigned its new ID before a page can be related to it.

protected sortPageUidsParentsFirst(array<int, int> $pageUids) : array<int, int>

Parameters

$pageUids : array<int, int>

Return values

array<int, int>

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

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

writePagesOrder()

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

protected writePagesOrder() : void

Only used for updates.

writeRecords()

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

protected writeRecords() : void

writeRecordsOrder()

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

protected writeRecordsOrder() : void

Only used for updates.

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