\Horde_Data_Outlookcsv

Horde_Data implementation for Outlook comma-separated data (CSV).

Summary

Methods
Properties
Constants
importFile()
exportData()
exportFile()
nextStep()
getCsv()
__construct()
importData()
importUrl()
getNewline()
getFilename()
getContentType()
warnings()
cleanup()
$storage
No constants found
_mapDate()
$_contentType
$_extension
$_browser
$_http
$_cleanupCallback
$_vars
$_warnings
N/A
No private methods found
No private properties found
N/A

Properties

$_contentType

$_contentType : string

MIME content type.

Type

string

$_extension

$_extension : string

File extension.

Type

string

$_browser

$_browser : \Horde_Browser

Browser object.

Type

\Horde_Browser

$_http

$_http : \Horde_Http_Client

HTTP client object.

Type

\Horde_Http_Client

$_cleanupCallback

$_cleanupCallback : callback

Cleanup callback function.

Type

callback

$_vars

$_vars : \Horde_Variables

Variables object.

Type

\Horde_Variables

$_warnings

$_warnings : array

A list of warnings raised during the last operation.

Type

array

Methods

importFile()

importFile(  $filename,   $header = false) 

Imports a file.

Parameters

$filename
$header

exportData()

exportData(array  $data, boolean  $header = false, array  $export_mapping = array()) : string

Builds a CSV file from a given data structure and returns it as a string.

Parameters

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.

array $export_mapping

TODO

Returns

string —

The CSV data.

exportFile()

exportFile(  $filename,   $data) 

Stub to export data to a file.

Parameters

$filename
$data

nextStep()

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.

Parameters

integer $action

The current step. One of the IMPORT_* constants.

array $param

An associative array containing needed parameters for the current step.

Throws

\Horde_Data_Exception

Returns

mixed —

Either the next step as an integer constant or imported data set after the final step.

getCsv()

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.

Parameters

resource $file

A file pointer.

array $params

Optional parameters. Possible values:

  • escape: The escape character.
  • length: The expected number of fields.
  • quote: The quote character.
  • separator: The field delimiter.

Returns

array|boolean —

A row from the CSV file or false on error or end of file.

__construct()

__construct(\Horde_Data_Storage  $storage, array  $params = array()) 

Constructor.

Parameters

\Horde_Data_Storage $storage
array $params

Optional parameters:

  • browser: (Horde_Browser) A browser object.
  • http: (Horde_Http_Client) A HTTP client object.
  • cleanup: (callback) A callback to call at cleanup time.
  • vars: (Horde_Variables) Form data.

importData()

importData(  $text) 

Stub to import passed data.

Parameters

$text

importUrl()

importUrl(  $url,   $header = false) 

Imports a URL.

Parameters

$url
$header

getNewline()

getNewline() : string

Tries to determine the expected newline character based on the platform information passed by the browser's agent header.

Returns

string —

The guessed expected newline characters, either \n, \r or \r\n.

getFilename()

getFilename(string  $basename) : string

Returns the full filename including the basename and extension.

Parameters

string $basename

Basename for the file.

Returns

string —

The file name.

getContentType()

getContentType() : string

Returns the content type.

Returns

string —

The content type.

warnings()

warnings() : array

Returns a list of warnings that have been raised during the last operation.

Returns

array —

A (possibly empty) list of warnings.

cleanup()

cleanup() : mixed

Removes any uploaded and moved files.

Returns

mixed —

If callback called, the return value of this call. This should be the value of the first import step.

_mapDate()

_mapDate(string  $date, string  $type, array  $params, integer  $key) : string

Maps a date/time string to an associative array.

Parameters

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:

  • delimiter: The character that seperates the different date/time parts.
  • format: If 'ampm' and $date contains a time we assume that it is in AM/PM format.
  • order: If $type is 'datetime' the order of the day and time parts: -1 (timestamp), 0 (day/time), 1 (time/day).
integer $key

The key to use for $params.

Returns

string —

The date or time in ISO format.