TYPO3 CMS  TYPO3_7-6
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)
 
 setPageTree ($idH)
 
 unsetExcludedSections ($idH)
 
 setRecordTypesIncludeFields (array $recordTypesIncludeFields)
 
 setRecordTypeIncludeFields ($table, array $fields)
 
 export_addRecord ($table, $row, $relationLevel=0)
 
 export_addDBRelations ($relationLevel=0)
 
 export_addDBRelations_registerRelation ($fI, &$addR, $tokenID='')
 
 export_addFilesFromRelations ()
 
 export_addFilesFromSysFilesRecords ()
 
 export_addSysFile (File $file)
 
 export_addFile ($fI, $recordRef='', $fieldname='')
 
 getTemporaryFilesPathForExport ()
 
 flatDBrels ($dbrels)
 
 flatSoftRefs ($dbrels)
 
 compileMemoryToFileContent ($type='')
 
 createXML ()
 
 doOutputCompress ()
 
 addFilePart ($data, $compress=false)
 
- Public Member Functions inherited from TYPO3\CMS\Impexp\ImportExport
 __construct ()
 
 init ()
 
 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='')
 
 checkDokType ($checkTable, $doktype)
 
 renderControls ($r)
 
 softrefSelector ($cfg)
 
 verifyFolderAccess ($dirPrefix, $noAlternative=false)
 
 flatInversePageTree ($idH, $a=[])
 
 isTableStatic ($table)
 
 inclRelation ($table)
 
 isExcluded ($table, $uid)
 
 includeSoftref ($tokenID)
 
 checkPID ($pid)
 
 dontIgnorePid ($table, $uid)
 
 doesRecordExist ($table, $uid, $fields='')
 
 getRecordPath ($pid)
 
 renderSelectBox ($prefix, $value, $optValues)
 
 compareRecords ($databaseRecord, $importRecord, $table, $inverseDiff=false)
 
 getRTEoriginalFilename ($string)
 
 getFileProcObj ()
 
 callHook ($name, $params)
 
 error ($msg)
 
 printErrorLog ()
 

Public Attributes

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

Protected Member Functions

 fixFileIDsInRelations (array $relations)
 
 removeSoftrefsHavingTheSameDatabaseRelation ($relations)
 
 filterRecordFields ($table, array $row)
 
- Protected Member Functions inherited from TYPO3\CMS\Impexp\ImportExport
 addGeneralErrorsByTable ($table)
 
 getTemporaryFolderName ()
 
 getBackendUser ()
 
 getDatabaseConnection ()
 
 getLanguageService ()
 

Protected Attributes

 $recordTypesIncludeFields = []
 
 $defaultRecordIncludeFields = ['uid', 'pid']
 
 $saveFilesOutsideExportFile = false
 
 $temporaryFilesPathForExport = null
 
- Protected Attributes inherited from TYPO3\CMS\Impexp\ImportExport
 $fileProcObj = null
 
 $remainHeader = []
 
 $iconFactory
 

Detailed Description

EXAMPLE for using the impexp-class for exporting stuff:

Create and initialize: $this->export = ::makeInstance(::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", ::getRecord("pages", 38)); $this->export->export_addRecord("pages", ::getRecord("pages", 39)); $this->export->export_addRecord("tt_content", ::getRecord("tt_content", 12)); $this->export->export_addRecord("tt_content", ::getRecord("tt_content", 74)); $this->export->export_addRecord("sys_template", ::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(); T3D file Export library (TYPO3 Record Document)

Definition at line 59 of file Export.php.

Member Function Documentation

◆ addFilePart()

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

Returns a content part for a filename being build.

Parameters
array$dataData to store in part
bool$compressCompress file?
Returns
string Content stream.

Definition at line 1114 of file Export.php.

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

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

◆ compileMemoryToFileContent()

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

This compiles and returns the data content for an exported file

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

Definition at line 981 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()

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

Creates XML string from input array

Returns
string XML content

Definition at line 1005 of file Export.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\array2xml().

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

◆ doOutputCompress()

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 1102 of file Export.php.

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

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

◆ export_addDBRelations()

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

This analyses 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$relationLevelRecursion 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 442 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().

◆ export_addDBRelations_registerRelation()

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

Helper function for export_addDBRelations()

Parameters
array$fIArray with table/id keys to add
array$addRAdd array, passed by reference to be modified
string$tokenIDSoftref Token ID, if applicable.
Returns
void
See also
export_addDBRelations()

Definition at line 540 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$fIFile 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$recordRefIf the file is related to a record, this is the id on the form [table]:[id]. Information purposes only.
string$fieldnameIf the file is related to a record, this is the field name it was related to. Information purposes only.
Returns
void

Definition at line 731 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\Utility\GeneralUtility\formatSize(), TYPO3\CMS\Core\Utility\GeneralUtility\getFileAbsFileName(), TYPO3\CMS\Impexp\ImportExport\getRTEoriginalFilename(), TYPO3\CMS\Impexp\Export\getTemporaryFilesPathForExport(), TYPO3\CMS\Core\Utility\GeneralUtility\getUrl(), TYPO3\CMS\Core\Utility\GeneralUtility\inList(), TYPO3\CMS\Core\Utility\GeneralUtility\isFirstPartOfStr(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), TYPO3\CMS\Core\Utility\GeneralUtility\resolveBackPath(), TYPO3\CMS\Core\Utility\PathUtility\stripPathSitePrefix(), and TYPO3\CMS\Core\Utility\GeneralUtility\upload_copy_move().

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

◆ export_addFilesFromRelations()

TYPO3\CMS\Impexp\Export::export_addFilesFromRelations ( )

◆ export_addFilesFromSysFilesRecords()

TYPO3\CMS\Impexp\Export::export_addFilesFromSysFilesRecords ( )

This adds all files from sys_file records

Returns
void

Definition at line 652 of file Export.php.

References TYPO3\CMS\Impexp\Export\export_addSysFile(), and TYPO3\CMS\Core\Resource\ResourceFactory\getInstance().

◆ export_addRecord()

TYPO3\CMS\Impexp\Export::export_addRecord (   $table,
  $row,
  $relationLevel = 0 
)

◆ export_addSysFile()

◆ filterRecordFields()

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$tableThe record type to be filtered
array$rowThe data to be filtered
Returns
array The filtered record row

Definition at line 952 of file Export.php.

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

◆ fixFileIDsInRelations()

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 363 of file Export.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\isFirstPartOfStr(), and TYPO3\CMS\Core\Utility\PathUtility\stripPathSitePrefix().

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

◆ flatDBrels()

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$dbrels2-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 878 of file Export.php.

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

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

◆ flatSoftRefs()

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

Soft References flattend to 1-dim array.

Parameters
array$dbrels2-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 904 of file Export.php.

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

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

◆ getTemporaryFilesPathForExport()

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 859 of file Export.php.

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

Referenced by TYPO3\CMS\Impexp\Export\export_addFile(), and TYPO3\CMS\Impexp\Export\export_addSysFile().

◆ init()

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

Init the object

Parameters
bool$dontCompressIf set, compression of t3d files is disabled
Returns
void

Definition at line 138 of file Export.php.

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

◆ removeSoftrefsHavingTheSameDatabaseRelation()

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 401 of file Export.php.

References TYPO3\CMS\Core\Resource\ResourceFactory\getInstance().

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

◆ setCharset()

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

Set charset

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

Definition at line 185 of file Export.php.

◆ setHeaderBasics()

TYPO3\CMS\Impexp\Export::setHeaderBasics ( )

◆ setMetaData()

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

Sets meta data

Parameters
string$titleTitle of the export
string$descriptionDescription of the export
string$notesNotes about the contents
string$packager_usernameBackend Username of the packager (the guy making the export)
string$packager_nameReal name of the packager
string$packager_emailEmail of the packager
Returns
void

Definition at line 201 of file Export.php.

References $GLOBALS.

◆ setPageTree()

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$idHHierarchy 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 237 of file Export.php.

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

◆ setRecordTypeIncludeFields()

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

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

Parameters
string$tableThe record type
array$fieldsThe fields to be included
Returns
void

Definition at line 293 of file Export.php.

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$recordTypesIncludeFieldsKeys are [recordname], values are an array of fields to be included in the export
Exceptions
Exceptionif an array value is not type of array
Returns
void

Definition at line 276 of file Export.php.

References TYPO3\CMS\Impexp\Export\setRecordTypeIncludeFields().

◆ 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 222 of file Export.php.

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

◆ unsetExcludedSections()

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

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

Parameters
array$idHPage uid hierarchy
Returns
array Modified input array private
See also
setPageTree()

Definition at line 251 of file Export.php.

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

Member Data Documentation

◆ $defaultRecordIncludeFields

TYPO3\CMS\Impexp\Export::$defaultRecordIncludeFields = ['uid', 'pid']
protected

Definition at line 116 of file Export.php.

◆ $dontCompress

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

◆ $extFileResourceExtensions

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

Definition at line 101 of file Export.php.

◆ $includeExtFileResources

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

Definition at line 94 of file Export.php.

◆ $maxExportSize

TYPO3\CMS\Impexp\Export::$maxExportSize = 10000000

Definition at line 80 of file Export.php.

◆ $maxFileSize

TYPO3\CMS\Impexp\Export::$maxFileSize = 1000000

Definition at line 66 of file Export.php.

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

◆ $maxRecordSize

TYPO3\CMS\Impexp\Export::$maxRecordSize = 1000000

Definition at line 73 of file Export.php.

◆ $recordTypesIncludeFields

TYPO3\CMS\Impexp\Export::$recordTypesIncludeFields = []
protected

Definition at line 109 of file Export.php.

◆ $saveFilesOutsideExportFile

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

Definition at line 121 of file Export.php.

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

◆ $temporaryFilesPathForExport

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

Definition at line 126 of file Export.php.

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