Documentation

Horde_Data_Tsv extends Horde_Data_Base

Horde_Data implementation for tab-separated data (TSV).

Tags
author

Jan Schneider jan@horde.org

author

Chuck Hagenbuch chuck@horde.org

category

Horde

copyright

1999-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL

Table of Contents

$storage  : Horde_Data_Storage
Storage object.
$_browser  : Horde_Browser
Browser object.
$_cleanupCallback  : callable
Cleanup callback function.
$_contentType  : string
MIME content type.
$_extension  : string
File extension.
$_http  : Horde_Http_Client
HTTP client object.
$_vars  : Horde_Variables
Variables object.
$_warnings  : array<string|int, mixed>
A list of warnings raised during the last operation.
__construct()  : mixed
Constructor.
cleanup()  : mixed
Removes any uploaded and moved files.
exportData()  : string
Builds a TSV file from a given data structure and returns it as a string.
exportFile()  : mixed
Builds a TSV file from a given data structure and triggers its download.
getContentType()  : string
Returns the content type.
getFilename()  : string
Returns the full filename including the basename and extension.
getNewline()  : string
Tries to determine the expected newline character based on the platform information passed by the browser's agent header.
importData()  : array<string|int, mixed>
Convert data file contents to list of data records.
importFile()  : mixed
Imports a file.
importUrl()  : mixed
Imports a URL.
nextStep()  : mixed
Takes all necessary actions for the given import step, parameters and form values and returns the next necessary step.
warnings()  : array<string|int, mixed>
Returns a list of warnings that have been raised during the last operation.
_mapDate()  : string
Maps a date/time string to an associative array.

Properties

$_browser

Browser object.

protected Horde_Browser $_browser

$_cleanupCallback

Cleanup callback function.

protected callable $_cleanupCallback

$_contentType

MIME content type.

protected string $_contentType = 'text/tab-separated-values'

$_extension

File extension.

protected string $_extension = 'tsv'

$_http

HTTP client object.

protected Horde_Http_Client $_http

$_vars

Variables object.

protected Horde_Variables $_vars

$_warnings

A list of warnings raised during the last operation.

protected array<string|int, mixed> $_warnings = array()

Methods

__construct()

Constructor.

public __construct(Horde_Data_Storage $storage[, array<string|int, mixed> $params = array() ]) : mixed
Parameters
$storage : Horde_Data_Storage
$params : array<string|int, mixed> = array()

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.
Return values
mixed —

cleanup()

Removes any uploaded and moved files.

public cleanup() : mixed
Return values
mixed —

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

exportData()

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

public exportData(array<string|int, mixed> $data[, bool $header = false ]) : string
Parameters
$data : array<string|int, mixed>

A two-dimensional array containing the data set.

$header : bool = false

If true, the rows of $data are associative arrays with field names as their keys.

Return values
string —

The TSV data.

exportFile()

Builds a TSV file from a given data structure and triggers its download.

public exportFile(string $filename, array<string|int, mixed> $data[, bool $header = false ]) : mixed

It DOES NOT exit the current script but only outputs the correct headers and data.

Parameters
$filename : string

The name of the file to be downloaded.

$data : array<string|int, mixed>

A two-dimensional array containing the data set.

$header : bool = false

If true, the rows of $data are associative arrays with field names as their keys.

Return values
mixed —

getContentType()

Returns the content type.

public getContentType() : string
Return values
string —

The content type.

getFilename()

Returns the full filename including the basename and extension.

public getFilename(string $basename) : string
Parameters
$basename : string

Basename for the file.

Return values
string —

The file name.

getNewline()

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

public getNewline() : string
Return values
string —

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

importData()

Convert data file contents to list of data records.

public importData(string $contents[, bool $header = false ][, string $delimiter = " " ]) : array<string|int, mixed>
Parameters
$contents : string

Data file contents.

$header : bool = false

True if a header row is present.

$delimiter : string = " "

Field delimiter.

Return values
array<string|int, mixed> —

List of data records.

importFile()

Imports a file.

public importFile(mixed $filename[, mixed $header = false ]) : mixed
Parameters
$filename : mixed
$header : mixed = false
Return values
mixed —

importUrl()

Imports a URL.

public importUrl(mixed $url[, mixed $header = false ]) : mixed
Parameters
$url : mixed
$header : mixed = false
Tags
since
2.1.0
Return values
mixed —

nextStep()

Takes all necessary actions for the given import step, parameters and form values and returns the next necessary step.

public nextStep(int $action[, array<string|int, mixed> $param = array() ]) : mixed
Parameters
$action : int

The current step. One of the IMPORT_* constants.

$param : array<string|int, mixed> = array()

An associative array containing needed parameters for the current step.

Tags
throws
Horde_Data_Exception
Return values
mixed —

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

warnings()

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

public warnings() : array<string|int, mixed>
Return values
array<string|int, mixed> —

A (possibly empty) list of warnings.

_mapDate()

Maps a date/time string to an associative array.

protected _mapDate(string $date, string $type, array<string|int, mixed> $params, int $key) : string
Parameters
$date : string

The date.

$type : string

One of 'date', 'time' or 'datetime'.

$params : array<string|int, mixed>

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).
$key : int

The key to use for $params.

Return values
string —

The date or time in ISO format.

Search results