‪TYPO3CMS  9.5
TYPO3\CMS\Impexp\Export Class Reference
Inheritance diagram for TYPO3\CMS\Impexp\Export:
TYPO3\CMS\Impexp\ImportExport

Public Member Functions

 init ($dontCompress=false)
 
 setHeaderBasics ()
 
 setCharset ($charset)
 
 setMetaData ($title, $description, $notes, $packager_username, $packager_name, $packager_email)
 
 setSaveFilesOutsideExportFile ($saveFilesOutsideExportFile)
 
array setPageTree ($idH)
 
array unsetExcludedSections ($idH)
 
 setRecordTypesIncludeFields (array $recordTypesIncludeFields)
 
 setRecordTypeIncludeFields ($table, array $fields)
 
 export_addRecord ($table, $row, $relationLevel=0)
 
array export_addDBRelations ($relationLevel=0)
 
 export_addDBRelations_registerRelation ($fI, &$addR, $tokenID='')
 
 export_addFilesFromRelations ()
 
 export_addFilesFromSysFilesRecords ()
 
 export_addSysFile (File $file)
 
 export_addFile ($fI, $recordRef='', $fieldname='')
 
string getTemporaryFilesPathForExport ()
 
array flatDBrels ($dbrels)
 
array flatSoftRefs ($dbrels)
 
string compileMemoryToFileContent ($type='')
 
string createXML ()
 
bool doOutputCompress ()
 
string addFilePart ($data, $compress=false)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Impexp\ImportExport
 __construct ()
 
 init ()
 
array displayContentOverview ()
 
 traversePageTree ($pT, &$lines, $preCode='')
 
 traversePageRecords ($pT, &$lines)
 
 traverseAllRecords ($pT, &$lines)
 
 singleRecordLines ($table, $uid, &$lines, $preCode, $checkImportInPidRecord=false)
 
 addRelations ($rels, &$lines, $preCode, $recurCheck=[], $htmlColorClass='')
 
 addFiles ($rels, &$lines, $preCode, $htmlColorClass='', $tokenID='')
 
bool checkDokType ($checkTable, $doktype)
 
string renderControls ($r)
 
string softrefSelector ($cfg)
 
string bool verifyFolderAccess ($dirPrefix, $noAlternative=false)
 
array flatInversePageTree ($idH, $a=[])
 
bool isTableStatic ($table)
 
bool inclRelation ($table)
 
bool isExcluded ($table, $uid)
 
bool includeSoftref ($tokenID)
 
bool checkPID ($pid)
 
bool dontIgnorePid ($table, $uid)
 
array doesRecordExist ($table, $uid, $fields='')
 
string getRecordPath ($pid)
 
string renderSelectBox ($prefix, $value, $optValues)
 
string compareRecords ($databaseRecord, $importRecord, $table, $inverseDiff=false)
 
string null getRTEoriginalFilename ($string)
 
ExtendedFileUtility getFileProcObj ()
 
 callHook ($name, $params)
 
TYPO3 CMS Impexp ImportExport setExcludeDisabledRecords ($excludeDisabledRecords=false)
 
 error ($msg)
 
string printErrorLog ()
 

Public Attributes

int $maxFileSize = 1000000
 
int $maxRecordSize = 1000000
 
int $maxExportSize = 10000000
 
bool $dontCompress = false
 
bool $includeExtFileResources = false
 
string $extFileResourceExtensions = 'html,htm,css'
 
- ‪Public Attributes inherited from ‪TYPO3\CMS\Impexp\ImportExport
bool $showStaticRelations = false
 
string $fileadminFolderName = ''
 
string $mode = ''
 
bool $update = false
 
bool $doesImport = false
 
array $display_import_pid_record = array( )
 
array $import_mode = array( )
 
bool $global_ignore_pid = false
 
bool $force_all_UIDS = false
 
bool $showDiff = false
 
bool $allowPHPScripts = false
 
array $softrefInputValues = array( )
 
array $fileIDMap = array( )
 
array $relOnlyTables = array( )
 
array $relStaticTables = array( )
 
array $excludeMap = array( )
 
array $softrefCfg = array( )
 
array $extensionDependencies = array( )
 
array $import_mapId = array( )
 
array $errorLog = array( )
 
array $cache_getRecordPath = array( )
 
array $checkPID_cache = array( )
 
bool $compress = false
 
array $dat = array( )
 

Protected Member Functions

array fixFileIDsInRelations (array $relations)
 
array removeSoftrefsHavingTheSameDatabaseRelation ($relations)
 
array filterRecordFields ($table, array $row)
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Impexp\ImportExport
bool isActive ($table, $uid)
 
 excludePageAndRecords ($pageUid, $pageTree)
 
 addGeneralErrorsByTable ($table)
 
string getTemporaryFolderName ()
 
BackendUserAuthentication getBackendUser ()
 
LanguageService getLanguageService ()
 

Protected Attributes

array $recordTypesIncludeFields = array( )
 
array $defaultRecordIncludeFields = array( 'uid', 'pid' )
 
bool $saveFilesOutsideExportFile = false
 
string null $temporaryFilesPathForExport
 
- ‪Protected Attributes inherited from ‪TYPO3\CMS\Impexp\ImportExport
ExtendedFileUtility $fileProcObj
 
array $remainHeader = array( )
 
IconFactory $iconFactory
 
bool $excludeDisabledRecords = false
 

Detailed Description

EXAMPLE for using the impexp-class for exporting stuff:

Create and initialize: $this->export = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Impexp\ImportExport::class); $this->export->init(); Set which tables relations we will allow: $this->export->relOnlyTables[]="tt_news"; // exclusively includes. See comment in the class

Adding records: $this->export->export_addRecord("pages", $this->pageinfo); $this->export->export_addRecord("pages", \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord("pages", 38)); $this->export->export_addRecord("pages", \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord("pages", 39)); $this->export->export_addRecord("tt_content", \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord("tt_content", 12)); $this->export->export_addRecord("tt_content", \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord("tt_content", 74)); $this->export->export_addRecord("sys_template", \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord("sys_template", 20));

Adding all the relations (recursively in 5 levels so relations has THEIR relations registered as well) for($a=0;$a<5;$a++) { $addR = $this->export->export_addDBRelations($a); if (empty($addR)) break; }

Finally load all the files. $this->export->export_addFilesFromRelations(); // MUST be after the DBrelations are set so that file from ALL added records are included!

Write export $out = $this->export->compileMemoryToFileContent();

this is not part of TYPO3's Core API. T3D file Export library (TYPO3 Record Document)

Definition at line 61 of file Export.php.

Member Function Documentation

◆ addFilePart()

string TYPO3\CMS\Impexp\Export::addFilePart (   $data,
  $compress = false 
)

Returns a content part for a filename being build.

Parameters
array$data‪Data to store in part
bool$compress‪Compress file?
Returns
‪string Content stream.

Definition at line 1076 of file Export.php.

References TYPO3\CMS\Impexp\ImportExport\$compress.

Referenced by TYPO3\CMS\Impexp\Export\compileMemoryToFileContent().

◆ compileMemoryToFileContent()

string TYPO3\CMS\Impexp\Export::compileMemoryToFileContent (   $type = '')

This compiles and returns the data content for an exported file

Parameters
string$type‪Type of output; "xml" gives xml, otherwise serialized array, possibly compressed.
Returns
‪string The output file stream

Definition at line 943 of file Export.php.

References TYPO3\CMS\Impexp\ImportExport\$compress, TYPO3\CMS\Impexp\Export\addFilePart(), TYPO3\CMS\Impexp\Export\createXML(), and TYPO3\CMS\Impexp\Export\doOutputCompress().

◆ createXML()

string TYPO3\CMS\Impexp\Export::createXML ( )

Creates XML string from input array

Returns
‪string XML content

Definition at line 967 of file Export.php.

Referenced by TYPO3\CMS\Impexp\Export\compileMemoryToFileContent().

◆ doOutputCompress()

bool TYPO3\CMS\Impexp\Export::doOutputCompress ( )

Returns TRUE if the output should be compressed.

Returns
‪bool TRUE if compression is possible AND requested.

Definition at line 1064 of file Export.php.

References TYPO3\CMS\Impexp\Export\$dontCompress.

Referenced by TYPO3\CMS\Impexp\Export\compileMemoryToFileContent().

◆ export_addDBRelations()

array TYPO3\CMS\Impexp\Export::export_addDBRelations (   $relationLevel = 0)

This analyzes the existing added records, finds all database relations to records and adds these records to the export file. This function can be called repeatedly until it returns an empty array. In principle it should not allow to infinite recursivity, but you better set a limit... Call this BEFORE the ext_addFilesFromRelations (so files from added relations are also included of course)

Parameters
int$relationLevel‪Recursion level
Returns
‪array overview of relations found and added: Keys [table]:[uid], values array with table and id
See also
export_addFilesFromRelations()

Definition at line 422 of file Export.php.

References TYPO3\CMS\Impexp\ImportExport\error(), TYPO3\CMS\Impexp\Export\export_addDBRelations_registerRelation(), TYPO3\CMS\Impexp\Export\export_addRecord(), TYPO3\CMS\Backend\Utility\BackendUtility\getRecord(), and TYPO3\CMS\Impexp\ImportExport\includeSoftref().

Referenced by TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemTest\compileExportGroupFileAndFileReferenceItem(), and TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\compileExportPagesAndRelatedTtContentWithImages().

◆ export_addDBRelations_registerRelation()

TYPO3\CMS\Impexp\Export::export_addDBRelations_registerRelation (   $fI,
$addR,
  $tokenID = '' 
)

Helper function for export_addDBRelations()

Parameters
array$fI‪Array with table/id keys to add
array$addR‪Add array, passed by reference to be modified
string$tokenID‪Softref Token ID, if applicable.
See also
export_addDBRelations()

Definition at line 526 of file Export.php.

References $GLOBALS, TYPO3\CMS\Impexp\ImportExport\inclRelation(), TYPO3\CMS\Impexp\ImportExport\includeSoftref(), TYPO3\CMS\Impexp\ImportExport\isExcluded(), and TYPO3\CMS\Impexp\ImportExport\isTableStatic().

Referenced by TYPO3\CMS\Impexp\Export\export_addDBRelations().

◆ export_addFile()

TYPO3\CMS\Impexp\Export::export_addFile (   $fI,
  $recordRef = '',
  $fieldname = '' 
)

Adds a files content to the export memory

Parameters
array$fI‪File information with three keys: "filename" = filename without path, "ID_absFile" = absolute filepath to the file (including the filename), "ID" = md5 hash of "ID_absFile". "relFileName" is optional for files attached to records, but mandatory for soft referenced files (since the relFileName determines where such a file should be stored!)
string$recordRef‪If the file is related to a record, this is the id on the form [table]:[id]. Information purposes only.
string$fieldname‪If the file is related to a record, this is the field name it was related to. Information purposes only.

Definition at line 700 of file Export.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\PathUtility\basename(), TYPO3\CMS\Core\Utility\PathUtility\dirname(), TYPO3\CMS\Impexp\ImportExport\error(), TYPO3\CMS\Core\Core\Environment\getPublicPath(), TYPO3\CMS\Impexp\ImportExport\getRTEoriginalFilename(), TYPO3\CMS\Impexp\Export\getTemporaryFilesPathForExport(), and TYPO3\CMS\Core\Utility\PathUtility\stripPathSitePrefix().

Referenced by TYPO3\CMS\Impexp\Export\export_addFilesFromRelations().

◆ export_addFilesFromRelations()

◆ export_addFilesFromSysFilesRecords()

◆ export_addRecord()

◆ export_addSysFile()

◆ filterRecordFields()

array TYPO3\CMS\Impexp\Export::filterRecordFields (   $table,
array  $row 
)
protected

If include fields for a specific record type are set, the data are filtered out with fields are not included in the fields.

Parameters
string$table‪The record type to be filtered
array$row‪The data to be filtered
Returns
‪array The filtered record row

Definition at line 914 of file Export.php.

Referenced by TYPO3\CMS\Impexp\Export\export_addRecord().

◆ fixFileIDsInRelations()

array TYPO3\CMS\Impexp\Export::fixFileIDsInRelations ( array  $relations)
protected

This changes the file reference ID from a hash based on the absolute file path (coming from ReferenceIndex) to a hash based on the relative file path.

Parameters
array$relations
Returns
‪array

Definition at line 343 of file Export.php.

References TYPO3\CMS\Core\Core\Environment\getPublicPath(), and TYPO3\CMS\Core\Utility\PathUtility\stripPathSitePrefix().

Referenced by TYPO3\CMS\Impexp\Export\export_addRecord().

◆ flatDBrels()

array TYPO3\CMS\Impexp\Export::flatDBrels (   $dbrels)

DB relations flattend to 1-dim array. The list will be unique, no table/uid combination will appear twice.

Parameters
array$dbrels‪2-dim Array of database relations organized by table key
Returns
‪array 1-dim array where entries are table:uid and keys are array with table/id

Definition at line 840 of file Export.php.

References TYPO3\CMS\Impexp\ImportExport\$dat.

Referenced by TYPO3\CMS\Impexp\Export\export_addRecord().

◆ flatSoftRefs()

array TYPO3\CMS\Impexp\Export::flatSoftRefs (   $dbrels)

Soft References flattend to 1-dim array.

Parameters
array$dbrels‪2-dim Array of database relations organized by table key
Returns
‪array 1-dim array where entries are arrays with properties of the soft link found and keys are a unique combination of field, spKey, structure path if applicable and token ID

Definition at line 866 of file Export.php.

References TYPO3\CMS\Impexp\ImportExport\$dat, and TYPO3\CMS\Core\Core\Environment\getPublicPath().

Referenced by TYPO3\CMS\Impexp\Export\export_addRecord().

◆ getTemporaryFilesPathForExport()

string TYPO3\CMS\Impexp\Export::getTemporaryFilesPathForExport ( )

If saveFilesOutsideExportFile is enabled, this function returns the path where the files referenced in the export are copied to.

Returns
‪string
Exceptions

Definition at line 821 of file Export.php.

References TYPO3\CMS\Impexp\Export\$temporaryFilesPathForExport, and TYPO3\CMS\Impexp\ImportExport\getTemporaryFolderName().

Referenced by TYPO3\CMS\Impexp\Export\export_addFile().

◆ init()

TYPO3\CMS\Impexp\Export::init (   $dontCompress = false)

Init the object

Parameters
bool$dontCompress‪If set, compression of t3d files is disabled

Definition at line 126 of file Export.php.

References TYPO3\CMS\Impexp\Export\$dontCompress.

◆ removeSoftrefsHavingTheSameDatabaseRelation()

array TYPO3\CMS\Impexp\Export::removeSoftrefsHavingTheSameDatabaseRelation (   $relations)
protected

Relations could contain db relations to sys_file records. Some configuration combinations of TCA and SoftReferenceIndex create also softref relation entries for the identical file. This results in double included files, one in array "files" and one in array "file_fal". This function checks the relations for this double inclusions and removes the redundant softref relation.

Parameters
array$relations
Returns
‪array

Definition at line 381 of file Export.php.

References TYPO3\CMS\Core\Resource\ResourceFactory\getInstance(), and TYPO3\CMS\Core\Resource\ResourceFactory\retrieveFileOrFolderObject().

Referenced by TYPO3\CMS\Impexp\Export\export_addRecord().

◆ setCharset()

TYPO3\CMS\Impexp\Export::setCharset (   $charset)

Set charset

Parameters
string$charset‪Charset for the content in the export. During import the character set will be converted if the target system uses another charset.

Definition at line 171 of file Export.php.

◆ setHeaderBasics()

◆ setMetaData()

TYPO3\CMS\Impexp\Export::setMetaData (   $title,
  $description,
  $notes,
  $packager_username,
  $packager_name,
  $packager_email 
)

Sets meta data

Parameters
string$title‪Title of the export
string$description‪Description of the export
string$notes‪Notes about the contents
string$packager_usernameBackend Username of the packager (the guy making the export)
string$packager_name‪Real name of the packager
string$packager_email‪Email of the packager

Definition at line 186 of file Export.php.

References $GLOBALS.

◆ setPageTree()

array TYPO3\CMS\Impexp\Export::setPageTree (   $idH)

Sets the page-tree array in the export header and returns the array in a flattened version

Parameters
array$idH‪Hierarchy of ids, the page tree: array([uid] => array("uid" => [uid], "subrow" => array(.....)), [uid] => ....)
Returns
‪array The hierarchical page tree converted to a one-dimensional list of pages

Definition at line 222 of file Export.php.

References TYPO3\CMS\Impexp\ImportExport\flatInversePageTree(), and TYPO3\CMS\Impexp\Export\unsetExcludedSections().

Referenced by TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase\setPageTree().

◆ setRecordTypeIncludeFields()

TYPO3\CMS\Impexp\Export::setRecordTypeIncludeFields (   $table,
array  $fields 
)

Sets the fields of a record type to be included in the export

Parameters
string$table‪The record type
array$fields‪The fields to be included

Definition at line 276 of file Export.php.

References $fields.

Referenced by TYPO3\CMS\Impexp\Export\setRecordTypesIncludeFields().

◆ setRecordTypesIncludeFields()

TYPO3\CMS\Impexp\Export::setRecordTypesIncludeFields ( array  $recordTypesIncludeFields)

Sets the fields of record types to be included in the export

Parameters
array$recordTypesIncludeFields‪Keys are [recordname], values are an array of fields to be included in the export
Exceptions
Exception‪if an array value is not type of array

Definition at line 260 of file Export.php.

References $fields, TYPO3\CMS\Impexp\Export\$recordTypesIncludeFields, and TYPO3\CMS\Impexp\Export\setRecordTypeIncludeFields().

Referenced by TYPO3\CMS\Impexp\Tests\Functional\Export\GroupFileAndFileReferenceItemTest\compileExportGroupFileAndFileReferenceItem(), and TYPO3\CMS\Impexp\Tests\Functional\Export\PagesAndTtContentWithImagesTest\compileExportPagesAndRelatedTtContentWithImages().

◆ setSaveFilesOutsideExportFile()

TYPO3\CMS\Impexp\Export::setSaveFilesOutsideExportFile (   $saveFilesOutsideExportFile)

Option to enable having the files not included in the export file. The files are saved to a temporary folder instead.

Parameters
bool$saveFilesOutsideExportFile
See also
getTemporaryFilesPathForExport()

Definition at line 207 of file Export.php.

References TYPO3\CMS\Impexp\Export\$saveFilesOutsideExportFile.

◆ unsetExcludedSections()

array TYPO3\CMS\Impexp\Export::unsetExcludedSections (   $idH)

Removes entries in the page tree which are found in ->excludeMap[]

Parameters
array$idH‪Page uid hierarchy
Returns
‪array Modified input array
See also
setPageTree()

Definition at line 236 of file Export.php.

Referenced by TYPO3\CMS\Impexp\Export\setPageTree().

Member Data Documentation

◆ $defaultRecordIncludeFields

array TYPO3\CMS\Impexp\Export::$defaultRecordIncludeFields = array( 'uid', 'pid' )
protected

Default array of fields to be included in the export

Definition at line 107 of file Export.php.

◆ $dontCompress

bool TYPO3\CMS\Impexp\Export::$dontCompress = false

Set by user: If set, compression in t3d files is disabled

Definition at line 82 of file Export.php.

Referenced by TYPO3\CMS\Impexp\Export\doOutputCompress(), and TYPO3\CMS\Impexp\Export\init().

◆ $extFileResourceExtensions

string TYPO3\CMS\Impexp\Export::$extFileResourceExtensions = 'html,htm,css'

Files with external media (HTML/css style references inside)

Definition at line 94 of file Export.php.

◆ $includeExtFileResources

bool TYPO3\CMS\Impexp\Export::$includeExtFileResources = false

If set, HTML file resources are included.

Definition at line 88 of file Export.php.

◆ $maxExportSize

int TYPO3\CMS\Impexp\Export::$maxExportSize = 10000000
Deprecated:
‪since TYPO3 v9, will be removed in TYPO3 v10.0. In v10, just remove property, it is not used any longer.

Definition at line 76 of file Export.php.

◆ $maxFileSize

int TYPO3\CMS\Impexp\Export::$maxFileSize = 1000000
Deprecated:
‪since TYPO3 v9, will be removed in TYPO3 v10.0. In v10, just remove property, it is not used any longer.

Definition at line 66 of file Export.php.

◆ $maxRecordSize

int TYPO3\CMS\Impexp\Export::$maxRecordSize = 1000000
Deprecated:
‪since TYPO3 v9, will be removed in TYPO3 v10.0. In v10, just remove property, it is not used any longer.

Definition at line 71 of file Export.php.

◆ $recordTypesIncludeFields

array TYPO3\CMS\Impexp\Export::$recordTypesIncludeFields = array( )
protected

Keys are [recordname], values are an array of fields to be included in the export

Definition at line 101 of file Export.php.

Referenced by TYPO3\CMS\Impexp\Tests\Functional\Export\IrreTutorialRecordsTest\exportIrreRecords(), and TYPO3\CMS\Impexp\Export\setRecordTypesIncludeFields().

◆ $saveFilesOutsideExportFile

bool TYPO3\CMS\Impexp\Export::$saveFilesOutsideExportFile = false
protected

Definition at line 111 of file Export.php.

Referenced by TYPO3\CMS\Impexp\Export\setSaveFilesOutsideExportFile().

◆ $temporaryFilesPathForExport

string null TYPO3\CMS\Impexp\Export::$temporaryFilesPathForExport
protected

Definition at line 115 of file Export.php.

Referenced by TYPO3\CMS\Impexp\Export\getTemporaryFilesPathForExport().