void action_import(
bool
0
)
|
|
The action handler.
Parameters:
bool add(
&$record, Array
$record
)
|
|
Add a valid record to the db
Parameters:
|
Array |
$record: |
The record to add |
|
|
&$record: |
|
API Tags:
| Return: | Wether or not there were errors |
void addRecords(
&$importerrors,
&$validatedrecs, Array
$importerrors, Array
$validatedrecs
)
|
|
Adds the validated records but checks for errors first
Parameters:
|
Array |
$importerrors: |
Errors that occurred during validation of importfile |
|
Array |
$validatedrecs: |
Records that were validated |
|
|
&$importerrors: |
|
|
|
&$validatedrecs: |
|
void addToRecord(
&$record, String
$attrname, String
$value, Array
$record
)
|
|
Add one value to the record
Parameters:
|
Array |
$record: |
the record wich will be changed |
|
String |
$attrname: |
the name of the attribute |
|
String |
$value: |
the value of that attribute |
|
|
&$record: |
|
Array checkAllFields(
Array
$fields, Array
&$values
)
|
|
Checks the allfield for correct data
Parameters:
|
Array |
$fields: |
The fields |
|
Array |
&$values: |
The values of the fields |
API Tags:
| Return: | An array with an error message, if an error occurred |
array checkImport(
array
$col_map, array
$initial_values
)
|
|
Checks the import by the col_map and the initial_values Check if all obligatory fields are used in the col_map or the initial_values Check if there are no fields used twice
Parameters:
|
array |
$col_map: |
The use of the fields for the columns in the csv |
|
array |
$initial_values: |
The initial_values of the importnode |
API Tags:
| Return: | An array with errors, if there are any |
void doAnalyze(
string
$fileid, [array
$importerrors = array()]
)
|
|
This function shows a form where the user can choose the mapping of the column, an allfield and if the first record must be past over
Parameters:
|
string |
$fileid: |
the id of the uploaded file |
|
array |
$importerrors: |
An array with the import errors |
void doImport(
[Bool
$nopost = false]
)
|
|
The real import function actually imports the importfile
Parameters:
This function shows a form to upload a .csv
Parameters:
This function checks if there is enough information to import the date
else it wil shows a form to set how the file wil be imported
This function takes care of uploaded file
int estimateColumnCount(
Array
$rows, String
$delimiter
)
|
|
Counts the number of columns in the first row
Parameters:
|
Array |
$rows: |
The rows from the csv-file |
|
String |
$delimiter: |
The char which seperate the fields |
API Tags:
| Return: | The number of columns |
String estimateDelimiter(
Array
$rows
)
|
|
Gets the char which is used for enclosure in the csv-file
Parameters:
|
Array |
$rows: |
The rows from the csv-file |
API Tags:
String estimateEnclosure(
Array
$rows
)
|
|
Gets the char which is used for enclosure in the csv-file
Parameters:
|
Array |
$rows: |
The rows from the csv-file |
API Tags:
Array fgetcsvfromarray(
Array
$arr, int
$columncount, [String
$delimiterChar = ','], [String
$enclosureChar = '"']
)
|
|
Get data from each line
Parameters:
|
Array |
$arr: |
An array with the lines from the CSV file |
|
int |
$columncount: |
The number of columns in the file |
|
String |
$delimiterChar: |
The delimeter character |
|
String |
$enclosureChar: |
The enclosure character |
API Tags:
| Return: | An array with the CSV data |
void fgetcsvfromline(
$line,
$columncount, [
$delimiterChar = ','], [
$enclosureChar = '"']
)
|
|
Parameters:
|
|
$line: |
|
|
|
$columncount: |
|
|
|
$delimiterChar: |
|
|
|
$enclosureChar: |
|
mixed getAllFieldsValues(
&$col_map, Array
$col_map
)
|
|
Add the allField to the col_map array
but only if a valid field is selected
Parameters:
|
Array |
$col_map: |
The map of columns (!stub) |
|
|
&$col_map: |
|
API Tags:
| Return: | The value for the field to use with all records |
String getAttributeSelector(
[int
$index = 0], [String
$value = ""], [String
$othername = ""], [int
$emptycol = 2]
)
|
|
Returns a dropdownlist with all possible field in the importnode
Parameters:
|
int |
$index: |
the number of the column |
|
String |
$value: |
the name of the attribute that is selected in the list (if empty then select the last one) |
|
String |
$othername: |
if set, use a other name for the dropdown, else use the name "col_map[index]" |
|
int |
$emptycol: |
mode for empty column (0 = no empty column, 1= empty column, 2= an 'ignore this column' (default)) |
API Tags:
| Return: | the html-code for the dropdownlist (<select>...</sekect>) |
Array getAttributesTranslation(
Array
$attributes
)
|
|
Make a record of translations of the given attributes
Parameters:
|
Array |
$attributes: |
The attributes to translate |
API Tags:
| Return: | The result of the translation |
void getImportButtons(
string
$phase
)
|
|
Get import buttons.
Parameters:
|
string |
$phase: |
import phase ('init', 'upload', 'process', 'analyze') |
array getIntegratedAttributes(
)
|
|
Get al attributes from the import node that have the flag AF_ONETOONE_INTEGRATE
API Tags:
| Return: | A list with all attributes from the import node that have the flag AF_ONETOONE_INTEGRATE |
Array getObligatoryAttributes(
)
|
|
Gives all obligatory attributes
Same as getUsableAttributes with parameter true
API Tags:
| Return: | An array with all the obligatory attributes |
int getRowCount(
string
$file, bool
$skipFirstRow
)
|
|
Returns the CSV line count.
Parameters:
|
string |
$file: |
the path to the csv-file |
|
bool |
$skipFirstRow: |
Skip the first row? |
API Tags:
Array getSampleRows(
String
$file
)
|
|
Get the first 5 lines from the csv-file
Parameters:
|
String |
$file: |
The path to the csv-file |
API Tags:
| Return: | The 5 lines from the csv file |
string getTmpFileDestination(
string
$fileid
)
|
|
Get the destination of the uploaded csv-file
Parameters:
|
string |
$fileid: |
The id of the file |
API Tags:
| Return: | The path of the file |
object instance &getUsableAttribute(
String
$name
)
|
|
Get the real attribute (instance) by his name
Parameters:
|
String |
$name: |
name of the attribute |
API Tags:
Array getUsableAttributes(
[bool
$obligatoryOnly = false]
)
|
|
Gives all the attributes that can be used for the import
Parameters:
|
bool |
$obligatoryOnly: |
if false then give all attributes, if true then give only the obligatory ones defaults to false |
API Tags:
Array getValidatedRecords(
String
$file
)
|
|
Get the validated records
Parameters:
|
String |
$file: |
The import csv file |
API Tags:
| Return: | with importerrors and validatedrecs |
mixed getValueFromRecord(
Array
$record, String
$fieldname
)
|
|
Gets a raw value from a record with ATK values for a specific attribute
Parameters:
|
String |
$fieldname: |
The name of the attribute to get the value for |
|
Array |
$record: |
The record to search through |
API Tags:
boolean hasRelationAttribute(
String
$attrname
)
|
|
Check whether the attribute has a relation (only manytoonerelations)
Parameters:
|
String |
$attrname: |
name of the attribute |
API Tags:
| Return: | result of the check |
void importHeader(
string
$phase
)
|
|
Import header.
Parameters:
|
string |
$phase: |
import phase ('init', 'upload', 'process', 'analyze') |
void importPage(
string
$phase, string
$content
)
|
|
Create import page for the given phase.
Parameters:
|
string |
$phase: |
import phase (init, upload, process) |
|
string |
$content: |
page content |
mixed inArray(
Array
$array, mixed
$value
)
|
|
The same als the php function array_search, but now much better.
This function is not case sensitive
Parameters:
|
Array |
$array: |
The array to search through |
|
mixed |
$value: |
The value to search for |
API Tags:
| Return: | The key if it is in the array, else false |
Array initColmap(
Array
$firstRecord, Bool
&$matchFound
)
|
|
Tries to make a default col_map with the first record of the csv-file
Parameters:
|
Array |
$firstRecord: |
The first record of the CSV file |
|
Bool |
&$matchFound: |
Found a match? |
API Tags:
| Return: | The default col_map |
boolean integrateAttribute(
Object
$attr
)
|
|
Checks whether the attribute has the flag AF_ONETOONE_INTEGRATE
Parameters:
|
Object |
$attr: |
The attribute to check |
API Tags:
| Return: | The result of the check |
boolean isHide(
Object
$attr
)
|
|
Checks whether the attribute is hiden by a flag
Parameters:
|
Object |
$attr: |
The attribute to check |
API Tags:
| Return: | The result of the check |
boolean isObligatory(
Object
$attr
)
|
|
Checks whether the attribute is obligatory
Parameters:
|
Object |
$attr: |
The attribute to check |
API Tags:
| Return: | The result of the check |
mixed isRelationAttribute(
String
$attrname
)
|
|
Check whether the attribute is part of a relation
Parameters:
|
String |
$attrname: |
name of the attribute |
API Tags:
| Return: | false if not, relation name if yes |
bool prepareUpdateRecord(
Array
&$record
)
|
|
Here we prepare our record for updating or return false,
indicating that we need to insert the record instead of updating it
Parameters:
|
Array |
&$record: |
The record to prepare |
API Tags:
| Return: | If the record wasn't prepared we return false, otherwise true |
void setImportNode(
&$node, atkNode
$node
)
|
|
Sets the import node. By default this is the same node as set by setNode, but if you call this method after the setNode call you can override the import node.
Parameters:
|
atkNode |
$node: |
node instance |
|
|
&$node: |
|
API Tags:
void setNode(
&$node, atkNode
$node
)
|
|
Sets the node for this handler. Implicitly sets the import node too!
Parameters:
|
atkNode |
$node: |
node instance |
|
|
&$node: |
|
API Tags:
Redefinition of:
- atkActionHandler::setNode()
- Set the calling node of the current action.
bool showErrors(
Array
$importerrors, [Array
$extraerror = null]
)
|
|
Determines wether or not errors occurred and shows the analyze screen if errors occurred.
Parameters:
|
Array |
$importerrors: |
An array with the errors that occurred |
|
Array |
$extraerror: |
An extra error, if we found errors |
API Tags:
| Return: | Wether or not errors occurred |
bool update(
&$record, Array
$record
)
|
|
Update a record in the db
Parameters:
|
Array |
$record: |
the record to update |
|
|
&$record: |
|
API Tags:
| Return: | Wether or not there were errors |
bool validate(
&$record, array
$record
)
|
|
Check whether the record if valide to import
Parameters:
|
array |
$record: |
the record |
|
|
&$record: |
|
API Tags:
| Return: | Wether or not there were errors |
void validateRecord(
Array
&$rec, Array
&$validatedrecs, Array
&$importerrors, int
$counter
)
|
|
Validates a record
Parameters:
|
Array |
&$rec: |
The record to validate |
|
Array |
&$validatedrecs: |
The records thus far validated |
|
Array |
&$importerrors: |
The errors so far in the import process |
|
int |
$counter: |
The number that the record is |
String _getAnalyseExtraOptions(
String
$skipfirstrow, String
$doupdate, String
$updatekey1, String
$onfalseidentifier, String
$allFields, Bool
$novalidatefirst
)
|
|
Returns the extra options of the importhandler
Parameters:
|
String |
$skipfirstrow: |
Wether or not to skip the first row |
|
String |
$doupdate: |
Wether or not to do an update |
|
String |
$updatekey1: |
The key to update on |
|
String |
$onfalseidentifier: |
What to do on a false identifier |
|
String |
$allFields: |
The fields to import |
|
Bool |
$novalidatefirst: |
Validate before the import |
API Tags:
| Return: | The HTML with the extra options |
String _getAnalyseHeader(
String
$fileid, String
$columncount, String
$delimiter, String
$enclosure, int
$rowcount
)
|
|
Returns the HTML header for the 'analyse' mode of the import handler
Parameters:
|
String |
$fileid: |
The 'id' (name) of the file we are importing |
|
String |
$columncount: |
The number of columns we have |
|
String |
$delimiter: |
The delimiter in the file |
|
String |
$enclosure: |
The enclosure in the file |
|
int |
$rowcount: |
The number of rows in the CSV file |
API Tags:
void _getAnalyseSample(
String
$columncount, String
$col_map, String
$csv_data, String
$skipfirstrow
)
|
|
Returns a sample of the analysis
Parameters:
|
String |
$columncount: |
The number of columns we have |
|
String |
$col_map: |
A mapping of the column |
|
String |
$csv_data: |
The CSV data |
|
String |
$skipfirstrow: |
Wether or not to skip the first row |
mixed _getAttributeValue(
String
$attributename, Array
$allFields, mixed
$value, Array
&$importerrors, Integer
$counter, Array
$rec
)
|
|
Gets the ATK value of the attribute
Parameters:
|
String |
$attributename: |
The name of the attribute |
|
Array |
$allFields: |
Array with all the fields |
|
mixed |
$value: |
The value from the CSV file |
|
Array |
&$importerrors: |
Any import errors which may occur or may have occured |
|
Integer |
$counter: |
The counter of the validatedrecords |
|
Array |
$rec: |
The record |
API Tags:
| Return: | The ATK value of the field |
Array _getDuplicateColumns(
Array
$array
)
|
|
Array with columns
Parameters:
|
Array |
$array: |
The array the columns to check |
API Tags:
| Return: | The duplicate columns |
String _getErrors(
Array
$importerrors
)
|
|
Transforms the $importerrors array into displayable HTML
Parameters:
|
Array |
$importerrors: |
A special array with arrays in it $importerrors[0] are general errors, other than that the numbers stand for recordnumbers |
API Tags:
| Return: | HTML table with the errors |
Information Tags:
| Todo: | make this use templates |
String _getSampleValue(
String
$attributename, String
$value
)
|
|
Gets the displayable value for the attribute
Parameters:
|
String |
$attributename: |
The name of the attribute |
|
String |
$value: |
The value of the attribute |
API Tags:
| Return: | The displayable value for the attribute |
void _returnErrors(
Array
$errors, String
$singleerror, String
$doubleerror, Array
&$collection
)
|
|
Checks if there are errors and if there are then it adds it to the collection
Parameters:
|
Array |
$errors: |
The errors to check |
|
String |
$singleerror: |
The language code to use for a single error |
|
String |
$doubleerror: |
The language code to use for multiple errors |
|
Array |
&$collection: |
The collection of errors thus far |
bool _usableForImport(
bool
$obligatoryOnly, Object
&$attrib
)
|
|
Check if an attribute is usable for import.
Parameters:
|
bool |
$obligatoryOnly: |
Wether or not we should concider obligatory attributes |
|
Object |
&$attrib: |
The attribute |
API Tags:
| Return: | Wether or not the attribute is usable for import |