TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Impexp\ImportExport Class Reference
Inheritance diagram for TYPO3\CMS\Impexp\ImportExport:
TYPO3\CMS\Impexp\Export TYPO3\CMS\Impexp\Import

Public Member Functions

 __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

 $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

 addGeneralErrorsByTable ($table)
 
 getTemporaryFolderName ()
 
 getBackendUser ()
 
 getDatabaseConnection ()
 
 getLanguageService ()
 

Protected Attributes

 $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 Import/Export library (TYPO3 Record Document)

Definition at line 63 of file ImportExport.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Impexp\ImportExport::__construct ( )

The constructor

Definition at line 257 of file ImportExport.php.

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

Member Function Documentation

◆ addFiles()

TYPO3\CMS\Impexp\ImportExport::addFiles (   $rels,
$lines,
  $preCode,
  $htmlColorClass = '',
  $tokenID = '' 
)

Add file relation entries for a record's rels-array

Parameters
array$relsArray of file IDs
array$linesOutput lines array (is passed by reference and modified)
string$preCodePre-HTML code
string$htmlColorClassAlternative HTML color class to use.
string$tokenIDToken ID if this is a softreference (in which case it only makes sense with a single element in the $rels array!)
Returns
void private
See also
singleRecordLines()

Definition at line 680 of file ImportExport.php.

◆ addGeneralErrorsByTable()

TYPO3\CMS\Impexp\ImportExport::addGeneralErrorsByTable (   $table)
protected

Log general error message for a given table

Parameters
string$tabledatabase table name
Returns
void

Definition at line 426 of file ImportExport.php.

References TYPO3\CMS\Impexp\ImportExport\error().

Referenced by TYPO3\CMS\Impexp\Import\checkImportPrerequisites(), TYPO3\CMS\Impexp\ImportExport\traverseAllRecords(), TYPO3\CMS\Impexp\Import\writeRecords_pages(), and TYPO3\CMS\Impexp\Import\writeRecords_records().

◆ addRelations()

TYPO3\CMS\Impexp\ImportExport::addRelations (   $rels,
$lines,
  $preCode,
  $recurCheck = [],
  $htmlColorClass = '' 
)

Add DB relations entries for a record's rels-array

Parameters
array$relsArray of relations
array$linesOutput lines array (is passed by reference and modified)
string$preCodePre-HTML code
array$recurCheckRecursivity check stack
string$htmlColorClassAlternative HTML color class to use.
Returns
void private
See also
singleRecordLines()

Definition at line 614 of file ImportExport.php.

◆ callHook()

◆ checkDokType()

TYPO3\CMS\Impexp\ImportExport::checkDokType (   $checkTable,
  $doktype 
)

Verifies that a table is allowed on a certain doktype of a page

Parameters
string$checkTableTable name to check
int$doktypedoktype value.
Returns
bool TRUE if OK

Definition at line 786 of file ImportExport.php.

◆ checkPID()

TYPO3\CMS\Impexp\ImportExport::checkPID (   $pid)

Checking if a PID is in the webmounts of the user

Parameters
int$pidPage ID to check
Returns
bool TRUE if OK

Definition at line 1006 of file ImportExport.php.

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

◆ compareRecords()

TYPO3\CMS\Impexp\ImportExport::compareRecords (   $databaseRecord,
  $importRecord,
  $table,
  $inverseDiff = false 
)

Compares two records, the current database record and the one from the import memory. Will return HTML code to show any differences between them!

Parameters
array$databaseRecordDatabase record, all fields (new values)
array$importRecordImport memorys record for the same table/uid, all fields (old values)
string$tableThe table name of the record
bool$inverseDiffInverse the diff view (switch red/green, needed for pre-update difference view)
Returns
string HTML

Definition at line 1089 of file ImportExport.php.

◆ displayContentOverview()

◆ doesRecordExist()

TYPO3\CMS\Impexp\ImportExport::doesRecordExist (   $table,
  $uid,
  $fields = '' 
)

Checks if the record exists

Parameters
string$tableTable name
int$uidUID of record
string$fieldsField list to select. Default is "uid,pid
Returns
array Result of ::getRecord() which means the record if found, otherwise FALSE

Definition at line 1034 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\Import\addSingle().

◆ dontIgnorePid()

TYPO3\CMS\Impexp\ImportExport::dontIgnorePid (   $table,
  $uid 
)

Checks if the position of an updated record is configured to be corrected. This can be disabled globally and changed for elements individually.

Parameters
string$tableTable name
int$uidUid or record
Returns
bool TRUE if the position of the record should be updated to match the one in the import structure

Definition at line 1021 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\Import\writeRecords_pages_order(), and TYPO3\CMS\Impexp\Import\writeRecords_records_order().

◆ error()

TYPO3\CMS\Impexp\ImportExport::error (   $msg)

Sets error message in the internal error log

Parameters
string$msgError message
Returns
void

Definition at line 1194 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\ImportExport\addGeneralErrorsByTable(), TYPO3\CMS\Impexp\Import\addSingle(), TYPO3\CMS\Impexp\Import\addToMapId(), TYPO3\CMS\Impexp\Import\checkImportPrerequisites(), TYPO3\CMS\Impexp\Import\checkOrCreateDir(), TYPO3\CMS\Impexp\ImportExport\displayContentOverview(), TYPO3\CMS\Impexp\Export\export_addDBRelations(), TYPO3\CMS\Impexp\Export\export_addFile(), TYPO3\CMS\Impexp\Export\export_addFilesFromRelations(), TYPO3\CMS\Impexp\Export\export_addRecord(), TYPO3\CMS\Impexp\Export\export_addSysFile(), TYPO3\CMS\Impexp\Import\fixCharsets(), TYPO3\CMS\Impexp\Import\fixUidLocalInSysFileReferenceRecords(), TYPO3\CMS\Impexp\Import\getNextContentPart(), TYPO3\CMS\Impexp\Import\getNextFilePart(), TYPO3\CMS\Impexp\Import\import_addFileNameToBeCopied(), TYPO3\CMS\Impexp\Import\loadFile(), TYPO3\CMS\Impexp\Import\processSoftReferences_saveFile(), TYPO3\CMS\Impexp\Import\processSoftReferences_saveFile_createRelFile(), TYPO3\CMS\Impexp\Import\removeSysFileReferenceRecordsFromImportDataWithRelationToMissingFile(), TYPO3\CMS\Impexp\Import\setFlexFormRelations(), TYPO3\CMS\Impexp\Import\setRelations(), TYPO3\CMS\Impexp\Import\setRelations_db(), TYPO3\CMS\Impexp\ImportExport\singleRecordLines(), TYPO3\CMS\Impexp\Import\unlinkTempFiles(), TYPO3\CMS\Impexp\Import\writeFileVerify(), TYPO3\CMS\Impexp\Import\writeRecords_records(), TYPO3\CMS\Impexp\Import\writeSysFileResourceForLegacyImport(), and TYPO3\CMS\Impexp\Import\writeTemporaryFileFromData().

◆ flatInversePageTree()

TYPO3\CMS\Impexp\ImportExport::flatInversePageTree (   $idH,
  $a = [] 
)

Recursively flattening the idH array

Parameters
array$idHPage uid hierarchy
array$aAccumulation array of pages (internal, don't set from outside)
Returns
array Array with uid-uid pairs for all pages in the page tree.
See also
Import::flatInversePageTree_pid()

Definition at line 935 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\Export\setPageTree(), TYPO3\CMS\Impexp\Import\writeRecords_pages(), and TYPO3\CMS\Impexp\Import\writeRecords_records_order().

◆ getBackendUser()

TYPO3\CMS\Impexp\ImportExport::getBackendUser ( )
protected

◆ getDatabaseConnection()

TYPO3\CMS\Impexp\ImportExport::getDatabaseConnection ( )
protected
Returns
DatabaseConnection

Definition at line 1220 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\Import\addSingle(), and TYPO3\CMS\Impexp\Import\fetchStorageRecords().

◆ getFileProcObj()

TYPO3\CMS\Impexp\ImportExport::getFileProcObj ( )

Returns file processing object, initialized only once.

Returns
ExtendedFileUtility File processor object

Definition at line 1158 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\Import\processSoftReferences_saveFile(), TYPO3\CMS\Impexp\Import\processSoftReferences_saveFile_createRelFile(), and TYPO3\CMS\Impexp\Import\writeFileVerify().

◆ getLanguageService()

TYPO3\CMS\Impexp\ImportExport::getLanguageService ( )
protected
Returns
LanguageService

Definition at line 1228 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\Import\fixCharsets(), and TYPO3\CMS\Impexp\ImportExport\singleRecordLines().

◆ getRecordPath()

TYPO3\CMS\Impexp\ImportExport::getRecordPath (   $pid)

Returns the page title path of a PID value. Results are cached internally

Parameters
int$pidRecord PID to check
Returns
string The path for the input PID

Definition at line 1045 of file ImportExport.php.

◆ getRTEoriginalFilename()

TYPO3\CMS\Impexp\ImportExport::getRTEoriginalFilename (   $string)

Creates the original file name for a copy-RTE image (magic type)

Parameters
string$stringRTE copy filename, eg. "RTEmagicC_user_pm_icon_01.gif.gif @return string|NULL RTE original filename, eg. "RTEmagicP_user_pm_icon_01.gif". If the input filename was NOT prefixed RTEmagicC_ as RTE images would be, NULL is returned!

Definition at line 1140 of file ImportExport.php.

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

◆ getTemporaryFolderName()

TYPO3\CMS\Impexp\ImportExport::getTemporaryFolderName ( )
protected

◆ inclRelation()

TYPO3\CMS\Impexp\ImportExport::inclRelation (   $table)

Returns TRUE if the input table name is to be included as relation

Parameters
string$tableTable name
Returns
bool TRUE, if table is marked static

Definition at line 969 of file ImportExport.php.

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

◆ includeSoftref()

TYPO3\CMS\Impexp\ImportExport::includeSoftref (   $tokenID)

Returns TRUE if soft reference should be included in exported file.

Parameters
string$tokenIDToken ID for soft reference
Returns
bool TRUE if softreference media should be included

Definition at line 994 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\Export\export_addDBRelations(), TYPO3\CMS\Impexp\Export\export_addDBRelations_registerRelation(), and TYPO3\CMS\Impexp\Export\export_addFilesFromRelations().

◆ init()

TYPO3\CMS\Impexp\ImportExport::init ( )

Init the object, both import and export

Returns
void

Definition at line 271 of file ImportExport.php.

References $GLOBALS.

◆ isExcluded()

TYPO3\CMS\Impexp\ImportExport::isExcluded (   $table,
  $uid 
)

Returns TRUE if the element should be excluded as static record.

Parameters
string$tableTable name
int$uidUID value
Returns
bool TRUE, if table is marked static

Definition at line 983 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\Export\export_addDBRelations_registerRelation(), and TYPO3\CMS\Impexp\Import\setRelations_db().

◆ isTableStatic()

TYPO3\CMS\Impexp\ImportExport::isTableStatic (   $table)

Returns TRUE if the input table name is to be regarded as a static relation (that is, not exported etc).

Parameters
string$tableTable name
Returns
bool TRUE, if table is marked static

Definition at line 955 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\Export\export_addDBRelations_registerRelation(), and TYPO3\CMS\Impexp\Import\setRelations_db().

◆ printErrorLog()

TYPO3\CMS\Impexp\ImportExport::printErrorLog ( )

Returns a table with the error-messages.

Returns
string HTML print of error log

Definition at line 1204 of file ImportExport.php.

◆ renderControls()

TYPO3\CMS\Impexp\ImportExport::renderControls (   $r)

Render input controls for import or export

Parameters
array$rConfiguration for element
Returns
string HTML

Definition at line 803 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\ImportExport\displayContentOverview().

◆ renderSelectBox()

TYPO3\CMS\Impexp\ImportExport::renderSelectBox (   $prefix,
  $value,
  $optValues 
)

Makes a selector-box from optValues

Parameters
string$prefixForm element name
string$valueCurrent value
array$optValuesOptions to display (key/value pairs)
Returns
string HTML select element

Definition at line 1062 of file ImportExport.php.

◆ singleRecordLines()

TYPO3\CMS\Impexp\ImportExport::singleRecordLines (   $table,
  $uid,
$lines,
  $preCode,
  $checkImportInPidRecord = false 
)

Add entries for a single record

Parameters
string$tableTable name
int$uidRecord uid
array$linesOutput lines array (is passed by reference and modified)
string$preCodePre-HTML code
bool$checkImportInPidRecordIf you want import validation, you can set this so it checks if the import can take place on the specified page.
Returns
void

Definition at line 446 of file ImportExport.php.

References $GLOBALS, $uid, TYPO3\CMS\Impexp\ImportExport\error(), TYPO3\CMS\Impexp\ImportExport\getBackendUser(), and TYPO3\CMS\Impexp\ImportExport\getLanguageService().

Referenced by TYPO3\CMS\Impexp\ImportExport\traverseAllRecords(), TYPO3\CMS\Impexp\ImportExport\traversePageRecords(), and TYPO3\CMS\Impexp\ImportExport\traversePageTree().

◆ softrefSelector()

TYPO3\CMS\Impexp\ImportExport::softrefSelector (   $cfg)

Selectorbox with export options for soft references

Parameters
array$cfgSoftref configuration array. An export box is shown only if a substitution scheme is found for the soft reference.
Returns
string Selector box HTML

Definition at line 832 of file ImportExport.php.

◆ traverseAllRecords()

TYPO3\CMS\Impexp\ImportExport::traverseAllRecords (   $pT,
$lines 
)

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

Parameters
array$pTPage tree array with uid/subrow (from ->dat[header][pagetree]
array$linesOutput lines array (is passed by reference and modified)
Returns
void

Definition at line 407 of file ImportExport.php.

References TYPO3\CMS\Impexp\ImportExport\addGeneralErrorsByTable(), and TYPO3\CMS\Impexp\ImportExport\singleRecordLines().

Referenced by TYPO3\CMS\Impexp\ImportExport\displayContentOverview().

◆ traversePageRecords()

TYPO3\CMS\Impexp\ImportExport::traversePageRecords (   $pT,
$lines 
)

Go through remaining pages (not in tree)

Parameters
array$pTPage tree array with uid/subrow (from ->dat[header][pagetree]
array$linesOutput lines array (is passed by reference and modified)
Returns
void

Definition at line 382 of file ImportExport.php.

References TYPO3\CMS\Impexp\ImportExport\singleRecordLines().

Referenced by TYPO3\CMS\Impexp\ImportExport\displayContentOverview().

◆ traversePageTree()

TYPO3\CMS\Impexp\ImportExport::traversePageTree (   $pT,
$lines,
  $preCode = '' 
)

Go through page tree for display

Parameters
array$pTPage tree array with uid/subrow (from ->dat[header][pagetree]
array$linesOutput lines array (is passed by reference and modified)
string$preCodePre-HTML code
Returns
void

Definition at line 352 of file ImportExport.php.

References TYPO3\CMS\Impexp\ImportExport\singleRecordLines().

Referenced by TYPO3\CMS\Impexp\ImportExport\displayContentOverview().

◆ verifyFolderAccess()

TYPO3\CMS\Impexp\ImportExport::verifyFolderAccess (   $dirPrefix,
  $noAlternative = false 
)

Verifies that the input path (relative to PATH_site) is found in the backend users filemounts. If it doesn't it will try to find another relative filemount for the user and return an alternative path prefix for the file.

Parameters
string$dirPrefixPath relative to PATH_site
bool$noAlternativeIf set, Do not look for alternative path! Just return FALSE
Returns
string|bool If a path is available that will be returned, otherwise FALSE.

Definition at line 883 of file ImportExport.php.

Referenced by TYPO3\CMS\Impexp\Import\processSoftReferences_saveFile_createRelFile().

Member Data Documentation

◆ $allowPHPScripts

TYPO3\CMS\Impexp\ImportExport::$allowPHPScripts = false

Definition at line 142 of file ImportExport.php.

◆ $cache_getRecordPath

TYPO3\CMS\Impexp\ImportExport::$cache_getRecordPath = []

Definition at line 213 of file ImportExport.php.

◆ $checkPID_cache

TYPO3\CMS\Impexp\ImportExport::$checkPID_cache = []

Definition at line 220 of file ImportExport.php.

◆ $compress

TYPO3\CMS\Impexp\ImportExport::$compress = false

◆ $dat

◆ $display_import_pid_record

TYPO3\CMS\Impexp\ImportExport::$display_import_pid_record = []

Definition at line 107 of file ImportExport.php.

◆ $doesImport

TYPO3\CMS\Impexp\ImportExport::$doesImport = false

Definition at line 98 of file ImportExport.php.

◆ $errorLog

TYPO3\CMS\Impexp\ImportExport::$errorLog = []

Definition at line 206 of file ImportExport.php.

◆ $excludeMap

TYPO3\CMS\Impexp\ImportExport::$excludeMap = []

Definition at line 178 of file ImportExport.php.

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

◆ $extensionDependencies

TYPO3\CMS\Impexp\ImportExport::$extensionDependencies = []

Definition at line 192 of file ImportExport.php.

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

◆ $fileadminFolderName

TYPO3\CMS\Impexp\ImportExport::$fileadminFolderName = ''

Definition at line 77 of file ImportExport.php.

◆ $fileIDMap

TYPO3\CMS\Impexp\ImportExport::$fileIDMap = []

Definition at line 156 of file ImportExport.php.

◆ $fileProcObj

◆ $force_all_UIDS

TYPO3\CMS\Impexp\ImportExport::$force_all_UIDS = false

Definition at line 128 of file ImportExport.php.

◆ $global_ignore_pid

TYPO3\CMS\Impexp\ImportExport::$global_ignore_pid = false

Definition at line 121 of file ImportExport.php.

◆ $iconFactory

TYPO3\CMS\Impexp\ImportExport::$iconFactory
protected

Definition at line 252 of file ImportExport.php.

◆ $import_mapId

TYPO3\CMS\Impexp\ImportExport::$import_mapId = []

Definition at line 199 of file ImportExport.php.

◆ $import_mode

TYPO3\CMS\Impexp\ImportExport::$import_mode = []

Definition at line 114 of file ImportExport.php.

◆ $mode

TYPO3\CMS\Impexp\ImportExport::$mode = ''

Definition at line 84 of file ImportExport.php.

◆ $relOnlyTables

TYPO3\CMS\Impexp\ImportExport::$relOnlyTables = []

Definition at line 163 of file ImportExport.php.

◆ $relStaticTables

TYPO3\CMS\Impexp\ImportExport::$relStaticTables = []

Definition at line 171 of file ImportExport.php.

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

◆ $remainHeader

TYPO3\CMS\Impexp\ImportExport::$remainHeader = []
protected

Definition at line 247 of file ImportExport.php.

◆ $showDiff

TYPO3\CMS\Impexp\ImportExport::$showDiff = false

◆ $showStaticRelations

TYPO3\CMS\Impexp\ImportExport::$showStaticRelations = false

Definition at line 70 of file ImportExport.php.

◆ $softrefCfg

TYPO3\CMS\Impexp\ImportExport::$softrefCfg = []

Definition at line 185 of file ImportExport.php.

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

◆ $softrefInputValues

TYPO3\CMS\Impexp\ImportExport::$softrefInputValues = []

Definition at line 149 of file ImportExport.php.

◆ $update

TYPO3\CMS\Impexp\ImportExport::$update = false