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

 isActive ($table, $uid)
 
 excludePageAndRecords ($pageUid, $pageTree)
 
 addGeneralErrorsByTable ($table)
 
 getTemporaryFolderName ()
 
 getBackendUser ()
 
 getLanguageService ()
 

Protected Attributes

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

Definition at line 64 of file ImportExport.php.

Constructor & Destructor Documentation

__construct ( )

The constructor

Definition at line 267 of file ImportExport.php.

References GeneralUtility\makeInstance().

Member Function Documentation

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 742 of file ImportExport.php.

addGeneralErrorsByTable (   $table)
protected

Log general error message for a given table

Parameters
string$tabledatabase table name
Returns
void

Definition at line 488 of file ImportExport.php.

References ImportExport\error().

Referenced by ImportExport\traverseAllRecords(), Import\writeRecords_pages(), and Import\writeRecords_records().

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 677 of file ImportExport.php.

callHook (   $name,
  $params 
)

Call Hook

Parameters
string$nameName of the hook
array$paramsArray with params
Returns
void

Definition at line 1229 of file ImportExport.php.

Referenced by Import\setFlexFormRelations(), Import\setRelations(), Import\writeRecords_pages(), Import\writeRecords_pages_order(), Import\writeRecords_records(), and Import\writeRecords_records_order().

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 845 of file ImportExport.php.

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 1061 of file ImportExport.php.

Referenced by Export\export_addRecord().

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 1144 of file ImportExport.php.

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 1089 of file ImportExport.php.

Referenced by Import\addSingle().

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 1076 of file ImportExport.php.

Referenced by Import\writeRecords_pages_order(), and Import\writeRecords_records_order().

excludePageAndRecords (   $pageUid,
  $pageTree 
)
protected

Exclude a page, its sub pages (recursively) and records placed in them from this import/export

Parameters
int$pageUidUid of the page to exclude
array$pageTreePage tree array with uid/subrow (from ->dat[header][pagetree]
Returns
void

Definition at line 413 of file ImportExport.php.

Referenced by ImportExport\traversePageTree().

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 990 of file ImportExport.php.

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

getBackendUser ( )
protected
Returns
BackendUserAuthentication

Definition at line 1279 of file ImportExport.php.

Referenced by Import\addSingle(), ImportExport\singleRecordLines(), and Import\writeFileVerify().

getFileProcObj ( )

Returns file processing object, initialized only once.

Returns
ExtendedFileUtility File processor object

Definition at line 1213 of file ImportExport.php.

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

getLanguageService ( )
protected
Returns
LanguageService

Definition at line 1287 of file ImportExport.php.

Referenced by ImportExport\singleRecordLines().

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 1100 of file ImportExport.php.

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 1195 of file ImportExport.php.

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

getTemporaryFolderName ( )
protected
Returns
string

Definition at line 972 of file ImportExport.php.

Referenced by Export\getTemporaryFilesPathForExport(), and Import\loadFile().

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 1024 of file ImportExport.php.

Referenced by Export\export_addDBRelations_registerRelation().

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 1049 of file ImportExport.php.

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

init ( )

Init the object, both import and export

Returns
void

Definition at line 281 of file ImportExport.php.

References $GLOBALS.

isActive (   $table,
  $uid 
)
protected

Test whether a record is active (i.e. not hidden)

Parameters
string$tableName of the records' database table
int$uidDatabase uid of the record
Returns
bool true if the record is active, false otherwise

Definition at line 397 of file ImportExport.php.

References $GLOBALS.

Referenced by Export\export_addRecord(), ImportExport\singleRecordLines(), and ImportExport\traversePageTree().

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 1038 of file ImportExport.php.

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

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 1010 of file ImportExport.php.

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

printErrorLog ( )

Returns a table with the error-messages.

Returns
string HTML print of error log

Definition at line 1271 of file ImportExport.php.

renderControls (   $r)

Render input controls for import or export

Parameters
array$rConfiguration for element
Returns
string HTML

Definition at line 862 of file ImportExport.php.

Referenced by ImportExport\displayContentOverview().

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 1117 of file ImportExport.php.

setExcludeDisabledRecords (   $excludeDisabledRecords = false)

Set flag to control whether disabled records and their children are excluded (true) or included (false). Defaults to the old behaviour of including everything.

Parameters
bool$excludeDisabledRecordsSet to true if if all disabled records should be excluded, false otherwise
Returns
$this for fluent calls

Definition at line 1245 of file ImportExport.php.

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 508 of file ImportExport.php.

References $GLOBALS, ImportExport\error(), ImportExport\getBackendUser(), ImportExport\getLanguageService(), and ImportExport\isActive().

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

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 891 of file ImportExport.php.

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 469 of file ImportExport.php.

References ImportExport\addGeneralErrorsByTable(), and ImportExport\singleRecordLines().

Referenced by ImportExport\displayContentOverview().

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 444 of file ImportExport.php.

References ImportExport\singleRecordLines().

Referenced by ImportExport\displayContentOverview().

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 362 of file ImportExport.php.

References ImportExport\excludePageAndRecords(), ImportExport\isActive(), and ImportExport\singleRecordLines().

Referenced by ImportExport\displayContentOverview().

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 942 of file ImportExport.php.

Referenced by Import\processSoftReferences_saveFile_createRelFile().

Member Data Documentation

$allowPHPScripts = false

Definition at line 143 of file ImportExport.php.

$cache_getRecordPath = []

Definition at line 215 of file ImportExport.php.

$checkPID_cache = []

Definition at line 222 of file ImportExport.php.

$compress = false

Definition at line 230 of file ImportExport.php.

Referenced by Export\addFilePart(), and Export\compileMemoryToFileContent().

$display_import_pid_record = []

Definition at line 108 of file ImportExport.php.

$doesImport = false

Definition at line 99 of file ImportExport.php.

$errorLog = []

Definition at line 208 of file ImportExport.php.

$excludeDisabledRecords = false
protected

Definition at line 262 of file ImportExport.php.

$excludeMap = []

Definition at line 180 of file ImportExport.php.

Referenced by Export\setHeaderBasics().

$extensionDependencies = []

Definition at line 194 of file ImportExport.php.

Referenced by Export\setHeaderBasics().

$fileadminFolderName = ''

Definition at line 78 of file ImportExport.php.

$fileIDMap = []

Definition at line 157 of file ImportExport.php.

$force_all_UIDS = false

Definition at line 129 of file ImportExport.php.

$global_ignore_pid = false

Definition at line 122 of file ImportExport.php.

$iconFactory
protected

Definition at line 254 of file ImportExport.php.

$import_mapId = []

Definition at line 201 of file ImportExport.php.

$import_mode = []

Definition at line 115 of file ImportExport.php.

$mode = ''

Definition at line 85 of file ImportExport.php.

$relOnlyTables = []

Definition at line 165 of file ImportExport.php.

$relStaticTables = []

Definition at line 173 of file ImportExport.php.

Referenced by Export\setHeaderBasics().

$remainHeader = []
protected

Definition at line 249 of file ImportExport.php.

$showDiff = false

Definition at line 136 of file ImportExport.php.

Referenced by ImportExport\displayContentOverview().

$showStaticRelations = false

Definition at line 71 of file ImportExport.php.

$softrefCfg = []

Definition at line 187 of file ImportExport.php.

Referenced by Export\setHeaderBasics().

$softrefInputValues = []

Definition at line 150 of file ImportExport.php.

$update = false

Definition at line 92 of file ImportExport.php.

Referenced by ImportExport\displayContentOverview().