TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
Export Class Reference
Inheritance diagram for Export:
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 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)
 
 setExcludeDisabledRecords ($excludeDisabledRecords=false)
 
 error ($msg)
 
 printErrorLog ()
 

Public Attributes

 $maxFileSize = 1000000
 
 $maxRecordSize = 1000000
 
 $maxExportSize = 10000000
 
 $dontCompress = false
 
 $includeExtFileResources = false
 
 $extFileResourceExtensions = 'html,htm,css'
 
- Public Attributes inherited from 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 ImportExport
 isActive ($table, $uid)
 
 excludePageAndRecords ($pageUid, $pageTree)
 
 addGeneralErrorsByTable ($table)
 
 getTemporaryFolderName ()
 
 getBackendUser ()
 
 getLanguageService ()
 

Protected Attributes

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

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 (   $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 1117 of file Export.php.

References ImportExport\$compress.

Referenced by Export\compileMemoryToFileContent().

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

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

createXML ( )

Creates XML string from input array

Returns
string XML content

Definition at line 1008 of file Export.php.

References GeneralUtility\array2xml().

Referenced by Export\compileMemoryToFileContent().

doOutputCompress ( )

Returns TRUE if the output should be compressed.

Returns
bool TRUE if compression is possible AND requested.

Definition at line 1105 of file Export.php.

References Export\$dontCompress.

Referenced by Export\compileMemoryToFileContent().

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

References ImportExport\error(), Export\export_addDBRelations_registerRelation(), Export\export_addRecord(), BackendUtility\getRecord(), and ImportExport\includeSoftref().

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

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

Referenced by Export\export_addDBRelations().

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

References $GLOBALS, PathUtility\basename(), PathUtility\dirname(), ImportExport\error(), GeneralUtility\formatSize(), GeneralUtility\getFileAbsFileName(), ImportExport\getRTEoriginalFilename(), Export\getTemporaryFilesPathForExport(), GeneralUtility\inList(), GeneralUtility\isFirstPartOfStr(), GeneralUtility\makeInstance(), GeneralUtility\resolveBackPath(), PathUtility\stripPathSitePrefix(), and GeneralUtility\upload_copy_move().

Referenced by Export\export_addFilesFromRelations().

export_addFilesFromRelations ( )

This adds all files in relations. Call this method AFTER adding all records including relations.

Returns
void
See also
export_addDBRelations()

Definition at line 565 of file Export.php.

References PathUtility\basename(), ImportExport\error(), Export\export_addFile(), GeneralUtility\getFileAbsFileName(), and ImportExport\includeSoftref().

export_addFilesFromSysFilesRecords ( )

This adds all files from sys_file records

Returns
void

Definition at line 656 of file Export.php.

References Export\export_addSysFile(), and ResourceFactory\getInstance().

export_addRecord (   $table,
  $row,
  $relationLevel = 0 
)

Adds the record $row from $table. No checking for relations done here. Pure data.

Parameters
string$tableTable name
array$rowRecord row.
int$relationLevel(Internal) if the record is added as a relation, this is set to the "level" it was on.
Returns
void

Definition at line 308 of file Export.php.

References ImportExport\checkPID(), ImportExport\error(), Export\filterRecordFields(), Export\fixFileIDsInRelations(), Export\flatDBrels(), Export\flatSoftRefs(), GeneralUtility\formatSize(), BackendUtility\getRecordTitle(), ImportExport\isActive(), GeneralUtility\makeInstance(), Export\removeSoftrefsHavingTheSameDatabaseRelation(), and BackendUtility\workspaceOL().

Referenced by Export\export_addDBRelations().

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

Referenced by Export\export_addRecord().

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

References GeneralUtility\isFirstPartOfStr(), and PathUtility\stripPathSitePrefix().

Referenced by Export\export_addRecord().

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

References ImportExport\$dat.

Referenced by Export\export_addRecord().

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

References ImportExport\$dat.

Referenced by Export\export_addRecord().

getTemporaryFilesPathForExport ( )

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

Returns
string
Exceptions
RuntimeException
See also
setSaveFilesOutsideExportFile()

Definition at line 862 of file Export.php.

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

Referenced by Export\export_addFile(), and Export\export_addSysFile().

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 Export\$dontCompress.

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

References ResourceFactory\getInstance().

Referenced by Export\export_addRecord().

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

setHeaderBasics ( )

Set header basics

Returns
void

Definition at line 154 of file Export.php.

References ImportExport\$excludeMap, ImportExport\$extensionDependencies, ImportExport\$relStaticTables, and ImportExport\$softrefCfg.

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

References $GLOBALS.

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

References ImportExport\flatInversePageTree(), and Export\unsetExcludedSections().

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

References $fields.

Referenced by Export\setRecordTypesIncludeFields().

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

References $fields, and Export\setRecordTypeIncludeFields().

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

References Export\$saveFilesOutsideExportFile.

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

Referenced by Export\setPageTree().

Member Data Documentation

$defaultRecordIncludeFields = ['uid', 'pid']
protected

Definition at line 116 of file Export.php.

$dontCompress = false

Definition at line 87 of file Export.php.

Referenced by Export\doOutputCompress(), and Export\init().

$extFileResourceExtensions = 'html,htm,css'

Definition at line 101 of file Export.php.

$includeExtFileResources = false

Definition at line 94 of file Export.php.

$maxExportSize = 10000000

Definition at line 80 of file Export.php.

$maxFileSize = 1000000

Definition at line 66 of file Export.php.

Referenced by Export\export_addSysFile().

$maxRecordSize = 1000000

Definition at line 73 of file Export.php.

$recordTypesIncludeFields = []
protected

Definition at line 109 of file Export.php.

$saveFilesOutsideExportFile = false
protected

Definition at line 121 of file Export.php.

Referenced by Export\setSaveFilesOutsideExportFile().

$temporaryFilesPathForExport = null
protected

Definition at line 126 of file Export.php.

Referenced by Export\getTemporaryFilesPathForExport().