$storage
$storage : \Horde_Data_Storage
Storage object.
Horde_Data implementation for comma-separated data (CSV).
$storage : \Horde_Data_Storage
Storage object.
__construct(\Horde_Data_Storage $storage, array $params = array())
Constructor.
\Horde_Data_Storage | $storage | |
array | $params | Optional parameters:
|
exportData(array $data, boolean $header = false, $export_mapping = array()) : string
Builds a CSV file from a given data structure and returns it as a string.
array | $data | A two-dimensional array containing the data set. |
boolean | $header | If true, the rows of $data are associative arrays with field names as their keys. |
$export_mapping |
The CSV data.
importFile(string $filename, boolean $header = false, string $sep = ',', string $quote = '', integer $fields = null, $import_mapping = array(), string $charset = null, string $crlf = null) : array
Imports and parses a CSV file.
string | $filename | The name of the file to parse. |
boolean | $header | Does the first line contain the field/column names? |
string | $sep | The field/column separator. |
string | $quote | The quoting character. |
integer | $fields | The number or fields/columns. |
$import_mapping | ||
string | $charset | The file's charset. |
string | $crlf | The file's linefeed characters. |
A two-dimensional array of all imported data rows. If $header was true the rows are associative arrays with the field/column names as the keys.
exportFile(string $filename, array $data, boolean $header = false, $export_mapping = array())
Builds a CSV file from a given data structure and triggers its download. It DOES NOT exit the current script but only outputs the correct headers and data.
string | $filename | The name of the file to be downloaded. |
array | $data | A two-dimensional array containing the data set. |
boolean | $header | If true, the rows of $data are associative arrays with field names as their keys. |
$export_mapping |
nextStep(integer $action, array $param = array()) : mixed
Takes all necessary actions for the given import step, parameters and form values and returns the next necessary step.
integer | $action | The current step. One of the IMPORT_* constants. |
array | $param | An associative array containing needed parameters for the current step. Keys for this driver:
|
Either the next step as an integer constant or imported data set after the final step.
getCsv(resource $file, array $params = array()) : array|boolean
Wrapper around fgetcsv().
Empty lines will be skipped. If the 'length' parameter is provided, all rows are filled up with empty strings up to this length, or stripped down to this length.
resource | $file | A file pointer. |
array | $params | Optional parameters. Possible values:
|
A row from the CSV file or false on error or end of file.
_mapDate(string $date, string $type, array $params, integer $key) : string
Maps a date/time string to an associative array.
string | $date | The date. |
string | $type | One of 'date', 'time' or 'datetime'. |
array | $params | Two-dimensional array with additional information about the formatting. Possible keys are:
|
integer | $key | The key to use for $params. |
The date or time in ISO format.