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

Class: Contact_Vcard_Build

Source Location: /Contact_Vcard_Build-1.1.1/Contact_Vcard_Build.php

Class Overview

PEAR
   |
   --Contact_Vcard_Build



Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 69]


[ Top ]


Class Variables

$autoparam =  null

[line 109]

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

Used when adding parameters automatically to the proper component.

  • Access: public

Type:   string


[ Top ]

$param = array()

[line 95]

Parameters for vCard components.
  • Access: public

Type:   array


[ Top ]

$value = array()

[line 82]

Values for vCard components.
  • Access: public

Type:   array


[ Top ]



Method Detail

Contact_Vcard_Build (Constructor)   [line 128]

void Contact_Vcard_Build( [string $version = '3.0'])

Constructor.

Parameters:

string   $version   —  The vCard version to build; affects which parameters are allowed and which components are returned by fetch().

[ Top ]

addAddress   [line 1653]

void addAddress( mixed $pob, mixed $extend, mixed $street, mixed $locality, mixed $region, mixed $postcode, mixed $country)

Sets the value of one entire ADR iteration. There can be zero, one, or more ADR components in a vCard.
  • Access: public

Parameters:

mixed   $pob   —  String (one repetition) or array (multiple reptitions) of the p.o. box part of the ADR component iteration.
mixed   $extend   —  String (one repetition) or array (multiple reptitions) of the "extended address" part of the ADR component iteration.
mixed   $street   —  String (one repetition) or array (multiple reptitions) of the street address part of the ADR component iteration.
mixed   $locality   —  String (one repetition) or array (multiple reptitions) of the locailty (e.g., city) part of the ADR component iteration.
mixed   $region   —  String (one repetition) or array (multiple reptitions) of the region (e.g., state, province, or governorate) part of the ADR component iteration.
mixed   $postcode   —  String (one repetition) or array (multiple reptitions) of the postal code (e.g., ZIP code) part of the ADR component iteration.
mixed   $country   —  String (one repetition) or array (multiple reptitions) of the country-name part of the ADR component iteration.

[ Top ]

addCategories   [line 1899]

void addCategories( mixed $text, [ $append = true])

Sets the full value of the CATEGORIES component. There is only one component iteration allowed per vCard, but there may be multiple value repetitions in the iteration.
  • Access: public

Parameters:

mixed   $text   —  String (one repetition) or array (multiple reptitions) of the component iteration value.
   $append   — 

[ Top ]

addEmail   [line 1808]

void addEmail( string $text)

Sets the value of one EMAIL component iteration. There can be zero, one, or more component iterations in a vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

addLabel   [line 1715]

void addLabel( string $text)

Sets the value of one LABEL component iteration. There can be zero, one, or more component iterations in a vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

addNickname   [line 1857]

void addNickname( mixed $text)

Sets the full value of the NICKNAME component. There is only one component iteration allowed per vCard, but there may be multiple value repetitions in the iteration.
  • Access: public

Parameters:

mixed   $text   —  String (one repetition) or array (multiple reptitions) of the component iteration value.

[ Top ]

addOrganization   [line 1947]

void addOrganization( mixed $text)

Sets the full value of the ORG component. There can be only one ORG component in a vCard.

The ORG component can have one or more parts (as opposed to repetitions of values within those parts). The first part is the highest-level organization, the second part is the next-highest, the third part is the third-highest, and so on. There can by any number of parts in one ORG iteration. (This is different from other components, such as NICKNAME, where an iteration has only one part but may have many repetitions within that part.)

  • Access: public

Parameters:

mixed   $text   —  String (one ORG part) or array (of ORG parts) to use as the value for the component iteration.

[ Top ]

addParam   [line 228]

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 allows 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 = new Contact_Vcard_Build();

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

  • Return: Void on success, or a PEAR_Error object 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 ]

addTelephone   [line 1762]

void addTelephone( string $text)

Sets the value of one TEL component iteration. There can be zero, one, or more component iterations in a vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

addValue   [line 602]

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 ]

countIter   [line 2359]

int countIter( string $type)

Count the number of iterations for an element type.
  • Return: The number of iterations for that type.
  • Access: public

Parameters:

string   $type   —  The element type to count iterations for (ADR, ORG, etc).

[ Top ]

countRept   [line 2385]

int countRept( string $type, $rept, int $iter)

Count the number of repetitions for an element type and iteration number.
  • Return: The number of repetitions for that type and iteration.
  • Access: public

Parameters:

string   $type   —  The element type to count iterations for (ADR, ORG, etc).
int   $iter   —  The iteration number to count repetitions for.
   $rept   — 

[ Top ]

escape   [line 155]

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, or a PEAR_Error object on failure.
  • Access: public

Parameters:

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

[ Top ]

fetch   [line 2074]

string fetch( )

Fetches a full vCard text block based on $this->value and

$this->param. The order of the returned components is similar to their order in RFC 2426. Honors the value of $this->value['VERSION'] to determine which vCard components are returned (2.1- or 3.0-compliant).

  • Return: A properly formatted vCard text block.
  • Access: public

[ Top ]

getAddress   [line 1682]

mixed getAddress( int $iter)

Gets back the value of one ADR component iteration.
  • Return: The value of this component iteration, or a PEAR_Error if the iteration is not valid.
  • Access: public

Parameters:

int   $iter   —  The component iteration-number to get the value for.

[ Top ]

getAgent   [line 1564]

string getAgent( )

Gets back the value of the AGENT component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getBirthday   [line 1112]

string getBirthday( )

Gets back the value of the BDAY component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getCategories   [line 1918]

string getCategories( )

Gets back the value of the CATEGORIES component. There is only one component allowed per vCard, but there may be multiple value repetitions in the iteration.
  • Return: The value of this component.
  • Access: public

[ Top ]

getClass   [line 1374]

string getClass( )

Gets back the value of the CLASS component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getEmail   [line 1831]

mixed getEmail( int $iter)

Gets back the value of one iteration of the EMAIL component. There can be zero, one, or more component iterations in a vCard.
  • Return: The value of this component, or a PEAR_Error if the iteration number is not valid.
  • Access: public

Parameters:

int   $iter   —  The component iteration-number to get the value for.

[ Top ]

getFormattedName   [line 792]

string getFormattedName( )

Gets back the full FN component value. Only ever returns iteration zero, because only one FN component is allowed per vCard.
  • Return: The FN value of the vCard.
  • Access: public

[ Top ]

getGeo   [line 1607]

string getGeo( )

Gets back the value of the GEO component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getKey   [line 1074]

string getKey( )

Gets back the value of the KEY component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getLabel   [line 1738]

mixed getLabel( int $iter)

Gets back the value of one iteration of the LABEL component.

There can be zero, one, or more component iterations in a vCard.

  • Return: The value of this component, or a PEAR_Error if the iteration number is not valid.
  • Access: public

Parameters:

int   $iter   —  The component iteration-number to get the value for.

[ Top ]

getLogo   [line 997]

string getLogo( )

Gets back the value of the LOGO component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getMailer   [line 1186]

string getMailer( )

Gets back the value of the MAILER component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getMeta   [line 529]

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 ]

getName   [line 709]

string getName( )

Gets back the full N component (first iteration only, since there can only be one N component per vCard).
  • Return: The first N component-interation of the vCard.
  • Access: public

[ Top ]

getNickname   [line 1876]

string getNickname( )

Gets back the value of the NICKNAME component. There is only one component allowed per vCard, but there may be multiple value repetitions in the iteration.
  • Return: The value of this component.
  • Access: public

[ Top ]

getNote   [line 1223]

string getNote( )

Gets back the value of the NOTE component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getOrganization   [line 1971]

string getOrganization( )

Gets back the value of the ORG component.
  • Return: The value of this component.

[ Top ]

getParam   [line 438]

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 ]

getPhoto   [line 956]

string getPhoto( )

Gets back the value of the PHOTO component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getProductID   [line 1450]

string getProductID( )

Gets back the value of the PRODID component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getRevision   [line 1490]

string getRevision( )

Gets back the value of the REV component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getRole   [line 1298]

string getRole( )

Gets back the value of the ROLE component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getSortString   [line 1412]

string getSortString( )

Gets back the value of the SORT-STRING component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getSound   [line 1035]

string getSound( )

Gets back the value of the SOUND component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getSource   [line 867]

string getSource( )

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

[ Top ]

getSourceName   [line 915]

string getSourceName( )

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

[ Top ]

getTelephone   [line 1785]

mixed getTelephone( int $iter)

Gets back the value of one iteration of the TEL component. There can be zero, one, or more component iterations in a vCard.
  • Return: The value of this component, or a PEAR_Error if the iteration number is not valid.
  • Access: public

Parameters:

int   $iter   —  The component iteration-number to get the value for.

[ Top ]

getTitle   [line 1260]

string getTitle( )

Gets back the value of the TITLE component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getTZ   [line 1149]

string getTZ( )

Gets back the value of the TZ component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getUniqueID   [line 1527]

string getUniqueID( )

Gets back the value of the UID component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getURL   [line 1337]

string getURL( )

Gets back the value of the URL component. There is only one allowed per vCard.
  • Return: The value of this component.
  • Access: public

[ Top ]

getValue   [line 636]

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 831]

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 494]

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 ]

send   [line 2328]

void send( string $filename, [string $disposition = 'attachment'], [string $charset = 'us-ascii'])

Send the vCard as a downloadable file.
  • Access: public

Parameters:

string   $filename   —  The file name to give the vCard.
string   $disposition   —  How the file should be sent, either 'inline' or 'attachment'.
string   $charset   —  The character set to use, defaults to 'us-ascii'.

[ Top ]

setAgent   [line 1546]

void setAgent( string $text)

Sets the value of the AGENT component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setBirthday   [line 1094]

void setBirthday( string $text)

Sets the value of the BDAY component. There is only one allowed per vCard. Date format is "yyyy-mm-dd[Thh:ii[:ss[Z|-06:00]]]".
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setClass   [line 1356]

void setClass( string $text)

Sets the value of the CLASS component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setFormattedName   [line 736]

mixed setFormattedName( [string $text = null])

Sets the FN component of the card. If no text is passed as the FN value, constructs an FN automatically from N components. There is only one FN iteration per vCard.
  • Return: Void on success, or a PEAR_Error object on failure.
  • Access: public

Parameters:

string   $text   —  Override the automatic generation of FN from N elements with the specified text.

[ Top ]

setFromArray   [line 2019]

void setFromArray( array $src)

Builds a vCard from a Contact_Vcard_Parse result array. Only send one vCard from the parse-results.

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

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

$vcard = new Contact_Vcard_Build(); // new builder $vcard->setFromArray($info[0]); // [0] is the first card

  • See: Contact_Vcard_Parse::fromText()
  • See: Contact_Vcard_Parse::fromFile()
  • Access: public

Parameters:

array   $src   —  One vCard entry as parsed using Contact_Vcard_Parse.

[ Top ]

setGeo   [line 1588]

void setGeo( string $lat, string $lon)

Sets the value of both parts of the GEO component. There is only one GEO component allowed per vCard.
  • Access: public

Parameters:

string   $lat   —  The value to set for the longitude part (decimal, + or -).
string   $lon   —  The value to set for the latitude part (decimal, + or -).

[ Top ]

setKey   [line 1055]

void setKey( string $text)

Sets the value of the KEY component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setLogo   [line 978]

void setLogo( string $text)

Sets the value of the LOGO component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setMailer   [line 1168]

void setMailer( string $text)

Sets the value of the MAILER component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setName   [line 687]

void setName( mixed $family, mixed $given, mixed $addl, mixed $prefix, mixed $suffix)

Sets the full N component of the vCard. Will replace all other values. There can only be one N component per vCard.
  • Access: public

Parameters:

mixed   $family   —  Single (string) or multiple (array) family/last name.
mixed   $given   —  Single (string) or multiple (array) given/first name.
mixed   $addl   —  Single (string) or multiple (array) additional/middle name.
mixed   $prefix   —  Single (string) or multiple (array) honorific prefix such as Mr., Miss, etc.
mixed   $suffix   —  Single (string) or multiple (array) honorific suffix such as III, Jr., Ph.D., etc.

[ Top ]

setNote   [line 1205]

void setNote( string $text)

Sets the value of the NOTE component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setPhoto   [line 937]

void setPhoto( string $text)

Sets the value of the PHOTO component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setProductID   [line 1432]

void setProductID( string $text)

Sets the value of the PRODID component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setRevision   [line 1472]

void setRevision( string $text)

Sets the value of the REV component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setRole   [line 1280]

void setRole( string $text)

Sets the value of the ROLE component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setSortString   [line 1394]

void setSortString( string $text)

Sets the value of the SORT-STRING component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setSound   [line 1017]

void setSound( string $text)

Sets the value of the SOUND component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setSource   [line 850]

void setSource( string $text)

Sets the data-source of the the vCard. Only one iteration.
  • Access: public

Parameters:

string   $text   —  The text value of the data-source text.

[ Top ]

setSourceName   [line 888]

mixed setSourceName( [string $text = null])

Sets the displayed name of the vCard data-source. Only one iteration.

If no name is specified, copies the value of SOURCE.

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

Parameters:

string   $text   —  The text value of the displayed data-source name. If null, copies the value of SOURCE.

[ Top ]

setTitle   [line 1242]

void setTitle( string $text)

Sets the value of the TITLE component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setTZ   [line 1131]

void setTZ( string $text)

Sets the value of the TZ component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setUniqueID   [line 1509]

void setUniqueID( string $text)

Sets the value of the UID component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setURL   [line 1319]

void setURL( string $text)

Sets the value of the URL component. There is only one allowed per vCard.
  • Access: public

Parameters:

string   $text   —  The value to set for this component.

[ Top ]

setValue   [line 569]

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 810]

mixed setVersion( [string $text = '3.0'])

Sets the version of the the vCard. Only one iteration.
  • Return: Void on success, or a PEAR_Error object on failure.
  • Access: public

Parameters:

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

[ Top ]

validateParam   [line 289]

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

Validates parameter names and values based on the vCard version (2.1 or 3.0).
  • Return: Boolean true if the parameter is valid, or a PEAR_Error object if not.
  • Access: public

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 14:19:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.