Class ImportExportBehavior
Behavior for dealing with data files directly on the server while avoiding directory traversal and publicly visible files.
- CComponent
- CBehavior implements IBehavior
- ImportExportBehavior
Author: Demitri Morgan <demitri@x2engine.com>
Author: Raymond Colebaugh <raymond@x2engine.com>
Located at x2engine/protected/components/ImportExportBehavior.php
public
false
|
|
public
type
|
|
public
string
|
|
public
string
|
|
protected
array
|
#
importTags( string $modelName, string $tagsField )
Create tag records for each of the specified tags |
protected
array
|
#
availableImportMaps( string $model = null )
List available import maps from a directory, optionally of type $model |
protected
array
|
|
protected
|
#
verifyImportMap( string $model, array $keys, array $attributes, boolean $createFields = false )
Parse the given keys and attributes to ensure required fields are mapped and new fields are to be created. The verified map will be stored in the 'importMap' key for the $_SESSION super global. |
protected
|
#
normalizeImportMap( array $map, array $fields )
Insert placeholders for unmapped fields to ensure the import map contains all possible fields |
protected
|
#
calculateCsvLength( mixed $csvfile )
Calculates the number of lines in a CSV file for import Warning: This must load and traverse the length of the file |
protected
|
|
protected
array
|
#
initializeModelImporter( resource $fp )
Read metadata from the CSV and initialize session variables |
protected
|
#
createImportMap( array $attributes, array $meta )
The goal of this function is to attempt to map meta into a series of Contact attributes, which it will do via string comparison on the Contact attribute names, the Contact attribute labels and a pattern match. |
protected
|
#
setCurrentActionText( mixed $attributes = null )
Append an empty placeholder for action texts, or set the attribute of the last action text in the container if attributes are specified |
protected
|
#
importRecordAttribute( string $modelName,
The import assumes we have human readable data in the CSV and will thus need to convert. This method converts link, date, and dateTime fields to the appropriate machine friendly data. |
protected
|
#
importRecordLinkAttribute( string $modelName,
Handle setting link type fields and create linked records if specified |
protected static
|
#
fixupImportedContactName( mixed $model )
Helper method to help out the user in the special case where a Contact's full name is set, but first and last name aren't, or vice versa. |
protected
|
#
fixupImportedAttributes( string $modelName,
This method is used after importing a records attributes to perform extra tasks, such as assigning lead routing, setting visibility, and reconstructing Action associations. |
protected
|
#
saveImportedModel(
Remove a record with the same ID, save the model attributes in the container, and increment the count of imported records |
protected
integer
|
|
protected
array
|
#
prepareImportSampleRecords( mixed $meta, mixed $fp )
This grabs 5 sample records from the CSV to get an example of what the data looks like. |
protected
|
#
reconstructImportedActionAssoc(
Handle reconstructing and validating Action associations |
protected
|
#
finishImportBatch( string $modelName, boolean $mappedId, boolean $finished = false )
Finalize this batch of records by performing a mass insert, handling accounting, updating nameIds, and rendering the JSON response |
protected
|
#
massUpdateImportedNameIds( array $importedIds, string $type )
Populate the nameId field since auto-populating fields is disabled and it is far more efficient to do it in a single query |
protected
|
#
triggerImportedRecords( array $importedIds, string $type )
Trigger the X2Workflow RecordCreateTrigger on the imported models |
protected
|
#
handleImportAccounting( array $models, string $modelName, array $lastInsertedIds, boolean $mappedId = false )
Create additional records related to the import, including the requested Tags, comment Actions, Import records, Events, and Relationships |
protected
|
#
fixupLinkFields( integer $modelName, string $type, string $primaryIdRange )
Process the link-type fields to set nameId |
protected
|
#
establishImportRelationships( integer $firstNewId, boolean $mappedId = false )
Create relationships records for the linked models |
protected
|
#
markFailedRecord( string $modelName,
Save the failed record into a CSV with validation errors |
protected
|
|
protected
array
|
#
readExportFormatOptions( array $params )
Retrieve all associated export format options from the request parameters |
protected
string
|
#
adjustExportPath( string $path, array $params, string $filetype = 'csv' )
Modifies the export path to ensure a consistent file extensions |
public
|
attach(),
detach(),
events(),
getEnabled(),
getOwner(),
setEnabled()
|
__call(),
__get(),
__isset(),
__set(),
__unset(),
asa(),
attachBehavior(),
attachBehaviors(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
detachBehavior(),
detachBehaviors(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
getEventHandlers(),
hasEvent(),
hasEventHandler(),
hasProperty(),
raiseEvent()
|
$enabled,
$owner
|