Class VCard - Stefanius67/VCard GitHub Wiki
A vcard file may contain multiple contacts.
- Creation of vCard Files Version 3.0 (RFC 2426)
- Import of vCard Files Version 2.1 and 3.0
Create an instance of VCard
, add the desired VCardContacts
to it and save
it as file with the write()
method.
Open the file with the read()
method and retrieve the containing contacts with
the getContact()
method.
You can either iterate over all contacts from 0 ... getContactCount()
(instead
of getContactCount() the return value of read()
can be used) or you can use
getContactList()
to call up a list of names of all contacts contained so you be
able to access a specific contact.
Constant | Description |
---|---|
PREF |
preferrred entry |
WORK |
information for work |
HOME |
information for home |
POSTAL |
postal address |
PARCEL |
parcel address for delivery |
INTER |
international address for delivery |
DOMESTIC |
domestic address for delivery |
VOICE |
communication number: standard phone |
CELL |
communication number: cellular phone |
FAX |
communication number: facsimile device |
MSG |
communication number: number has voice messaging support |
VIDEO |
communication number: video conferencing telephone number |
PAGER |
communication number: paging device telephone number |
BBS |
communication number: bulletin board system telephone number |
MODEM |
communication number: modem connected telephone number |
CAR |
communication number: car-phone telephone number |
ISDN |
communication number: ISDN service telephone number |
PCS |
communication number: personal communication services telephone number |
Method | Description |
---|---|
addContact | Add contact to vcard file. |
getContact | Get contact data. |
getContactCount | Number of contacts the vcard containing. |
getContactList | Get a named list of all contacts. |
getEncoding | Get the encoding currently set. |
read | Read vcard - file. |
setEncoding | Set the encoding for the file. |
write | Write vcard to file. |
Add contact to vcard file.
public VCard::addContact(\SKien\VCard\VCardContact $oContact) : void
Parameters:
Parameter | Type | Description |
---|---|---|
oContact |
\SKien\VCard\VCardContact |
Get contact data.
public VCard::getContact(int $i) : \SKien\VCard\VCardContact|null
Parameters:
Parameter | Type | Description |
---|---|---|
i |
int | index of the requested contact (0 <= $i < getContactCount ) |
Return Type: \SKien\VCard\VCardContact|null
null, if index is out of the contact count
Number of contacts the vcard containing.
public VCard::getContactCount() : int
Return Type: int
Get a named list of all contacts.
public VCard::getContactList() : string[]
The complete VCardContact object can be called up with the method
getContact ()
via the corresponding index.
Return Type: string[]
Get the encoding currently set.
public static VCard::getEncoding() : string
Return Type: string
Read vcard - file.
public VCard::read(string $strFilename) : int
Parameters:
Parameter | Type | Description |
---|---|---|
strFilename |
string |
Return Type: int
count of contacts imported
Set the encoding for the file.
public static VCard::setEncoding(string $strEncoding) : void
For export:
- always use UTF-8 (default). only exception i found so far is MS-Outlook - it comes in trouble with german umlauts, so use 'Windows-1252' instead. please send note to [email protected] if you found any further exceptions...
For import:
- feel free to use your preferred charset (may depends on configuration of your system)
Parameters:
Parameter | Type | Description |
---|---|---|
strEncoding |
string |
Write vcard to file.
public VCard::write(string $strFilename, bool $bTest = false) : void
Parameters:
Parameter | Type | Description |
---|---|---|
strFilename |
string | |
bTest |
bool | output to browser for internal testing... |