File_IMC
[ class tree: File_IMC ] [ index: File_IMC ] [ all elements ]

Class: File_IMC_Build

Source Location: /File_IMC-0.4.0/File/IMC/Build.php

Class Overview


This class helps build files in the vCard and vCalendar formats.


Author(s):

Variables

Methods


Child classes:

File_IMC_Build_Vcard
This class builds a single vCard (version 3.0 or 2.1).

Inherited Variables

Inherited Methods


Class Details

[line 68]
This class helps build files in the vCard and vCalendar formats.

General note: we use the terms "set" "add" and "get" as function prefixes.

"Set" means there is only one iteration of a component, and it has only one value repetition, so you set the whole thing at once.

"Add" means either multiple iterations of a component are allowed, or that there is only one iteration allowed but there can be multiple value repetitions, so you add iterations or repetitions to the current stack.

"Get" returns the full vCard line for a single iteration.



[ Top ]


Class Variables

$autoparam =  null

[line 105]

Tracks which component (N, ADR, TEL, etc) value was last set or added.

Used when adding parameters automatically to the proper component.


Type:   string


[ Top ]

$param = array()

[line 94]

Parameters for vCard components.
  • Access: public

Type:   array


[ Top ]

$value = array()

[line 81]

Values for vCard components.
  • Access: public

Type:   array


[ Top ]



Method Detail

addParam   [line 280]

mixed addParam( string $param_name, string $param_value, [string $comp = null], [mixed $iter = null])

Adds a parameter value for a given component and parameter name.

Note that although vCard 2.1 and vCalendar allow you to specify a parameter value without a name (e.g., "HOME" instead of "TYPE=HOME") this class is not so lenient. ;-) You must specify a parameter name (TYPE, ENCODING, etc) when adding a parameter. Call multiple times if you want to add multiple values to the same parameter. E.g.:

$vcard = File_IMC::build('vCard');

// set "TYPE=HOME,PREF" for the first TEL component $vcard->addParam('TYPE', 'HOME', 'TEL', 0); $vcard->addParam('TYPE', 'PREF', 'TEL', 0);

  • Return: Void on success
  • Throws: File_IMC_Excpetion on failure.
  • Access: public

Parameters:

string   $param_name   —  The parameter name, such as TYPE, VALUE, or ENCODING.
string   $param_value   —  The parameter value.
string   $comp   —  The vCard component for which this is a paramter (ADR, TEL, etc). If null, will be the component that was last set or added-to.
mixed   $iter   —  An integer vCard component iteration that this is a param for. E.g., if you have more than one ADR component, 0 refers to the first ADR, 1 to the second ADR, and so on. If null, the parameter will be added to the last component iteration available.

[ Top ]

addValue   [line 441]

void addValue( string $comp, int $iter, int $part, mixed $text)

Generic, all-purpose method to add a repetition of a string or array in $this->value, in a way suitable for later output as a vCard element. This appends the value to be the passed text or array value, leaving any prior values in place.
  • Access: public

Parameters:

string   $comp   —  The component to set the value for ('N', 'ADR', etc).
int   $iter   —  The component-iteration to set the value for.
int   $part   —  The part number of the component-iteration to set the value for.
mixed   $text   —  A string or array; the set of repeated values for this component-iteration part.

[ Top ]

escape   [line 196]

mixed escape( &$text, mixed $text)

Prepares a string so it may be safely used as vCard values. DO NOT use this with binary encodings. Operates on text in-place; does not return a value. Recursively descends into arrays.

Escapes a string so that... ; => \; , => \, newline => literal \n

  • Return: Void on success
  • Throws: File_IMC_Exception on failure.
  • Access: public

Parameters:

mixed   $text   —  The string or array or strings to escape.
   &$text   — 

[ Top ]

fetch   [line 638]

string fetch( )

Fetches a full vCard/vCal text block based on $this->value and $this->param.
  • Return: A properly formatted vCard/vCalendar text block.
  • Access: public

Overridden in child classes as:

File_IMC_Build_Vcard::fetch()
Fetches a full vCard text block based on $this->value and

[ Top ]

getMeta   [line 368]

string getMeta( string $comp, [int $iter = 0])

Gets the left-side/prefix/before-the-colon (metadata) part of a vCard line, including the component identifier, the parameter list, and a colon.
  • Return: The line prefix metadata.
  • Access: public

Parameters:

string   $comp   —  The component to get metadata for (ADR, TEL, etc).
int   $iter   —  The vCard component iteration to get the metadata for. E.g., if you have more than one ADR component, 0 refers to the first ADR, 1 to the second ADR, and so on.

[ Top ]

getParam   [line 516]

string getParam( string $comp, [int $iter = 0])

Gets back the parameter string for a given component.
  • Access: public

Parameters:

string   $comp   —  The component to get parameters for (ADR, TEL, etc).
int   $iter   —  The vCard component iteration to get the param list for. E.g., if you have more than one ADR component, 0 refers to the first ADR, 1 to the second ADR, and so on.

[ Top ]

getValue   [line 474]

string getValue( string $comp, [int $iter = 0], [int $part = 0], [mixed $rept = null])

Generic, all-purpose method to get back the data stored in $this->value.
  • Return: The value, escaped and delimited, of all repetitions in the component-iteration part (or specific repetition within the part).
  • Access: public

Parameters:

string   $comp   —  The component to set the value for ('N', 'ADR', etc).
int   $iter   —  The component-iteration to set the value for.
int   $part   —  The part number of the component-iteration to get the value for.
mixed   $rept   —  The repetition number within the part to get; if null, get all repetitions of the part within the iteration.

[ Top ]

getVersion   [line 168]

string getVersion( )

Gets back the version of the the vCard. Only one iteration.
  • Return: The data-source of the vCard.
  • Access: public

[ Top ]

reset   [line 120]

void reset( [string $version = null])

Resets the vCard values and params to be blank.
  • Access: public

Parameters:

string   $version   —  The vCard version to reset to ('2.1' or '3.0' -- default is the same version as previously set).

[ Top ]

setFromArray   [line 583]

void setFromArray( array $src)

Builds a vCard/vCal from a parser result array. Only send one vCard from the parse-results.

Usage (to build from first vCard in parsed results):

$parse = File_IMC::parse('vCard'); // new parser $info = $parse->fromFile('sample.vcf'); // parse file

$vcard = File_IMC::build('vCard'); // new builder $vcard->setFromArray($info);


Parameters:

array   $src   —  One vCard entry as parsed using File_IMC::parse()

[ Top ]

setValue   [line 408]

void setValue( string $comp, int $iter, int $part, mixed $text)

Generic, all-purpose method to store a string or array in $this->value, in a way suitable for later output as a vCard element. This forces the value to be the passed text or array value, overriding any prior values.
  • Access: public

Parameters:

string   $comp   —  The component to set the value for ('N', 'ADR', etc).
int   $iter   —  The component-iteration to set the value for.
int   $part   —  The part number of the component-iteration to set the value for.
mixed   $text   —  A string or array; the set of repeated values for this component-iteration part.

[ Top ]

setVersion   [line 152]

mixed setVersion( string $text)

Sets the version of the specification to use. Only one iteration.

Overload this function in the driver to validate and set the version

  • Return: Void on success, or a PEAR_Error object on failure.
  • Abstract:
  • Access: public

Overridden in child classes as:

File_IMC_Build_Vcard::setVersion()
Sets the version of the the vCard. Only one iteration.

Parameters:

string   $text   —  The text value of the verson text (e.g. '3.0' or '2.1').

[ Top ]

validateParam   [line 340]

mixed validateParam( string $name, string $text, [string $comp = null], [string $iter = null])

Validates parameter names and values
  • Return: Boolean true if the parameter is valid
  • Abstract:
  • Throws: File_IMC_Exception if not.
  • Access: public

Overridden in child classes as:

File_IMC_Build_Vcard::validateParam()
Validates parameter names and values based on the vCard version (2.1 or 3.0).

Parameters:

string   $name   —  The parameter name (e.g., TYPE or ENCODING).
string   $text   —  The parameter value (e.g., HOME or BASE64).
string   $comp   —  Optional, the component name (e.g., ADR or PHOTO). Only used for error messaging.
string   $iter   —  Optional, the iteration of the component. Only used for error messaging.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:32:03 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.