3
* Class representing vCard entries.
5
* Copyright 2003-2013 Horde LLC (http://www.horde.org/)
7
* See the enclosed file COPYING for license information (LGPL). If you
8
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
10
* @author Karsten Fourmont <karsten@horde.org>
12
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
15
class Horde_Icalendar_Vcard extends Horde_Icalendar
17
// The following were shamelessly yoinked from Contact_Vcard_Build
18
// Part numbers for N components.
25
// Part numbers for ADR components.
29
const ADR_LOCALITY = 3;
31
const ADR_POSTCODE = 5;
32
const ADR_COUNTRY = 6;
34
// Part numbers for GEO components.
39
* The component type of this class.
43
public $type = 'vcard';
48
public function __construct($version = '2.1')
50
parent::__construct($version);
54
* Sets the version of this component.
59
* @param string A float-like version string.
61
public function setVersion($version)
63
$this->_oldFormat = $version < 3;
64
$this->_version = $version;
68
* Unlike vevent and vtodo, a vcard is normally not enclosed in an
69
* iCalendar container. (BEGIN..END)
73
public function exportvCalendar()
75
$requiredAttributes['VERSION'] = $this->_version;
76
$requiredAttributes['N'] = ';;;;;;';
77
if ($this->_version == '3.0') {
78
$requiredAttributes['FN'] = '';
81
foreach ($requiredAttributes as $name => $default_value) {
83
$this->getAttribute($name);
84
} catch (Horde_Icalendar_Exception $e) {
85
$this->setAttribute($name, $default_value);
89
return $this->_exportvData('VCARD');
93
* Returns the contents of the "N" tag as a printable Name:
96
* N:Duck;Dagobert;T;Professor;Sen.
98
* "Professor Dagobert T Duck Sen"
100
* @return string Full name of vcard "N" tag or null if no N tag.
102
public function printableName()
105
$name_parts = $this->getAttributeValues('N');
106
} catch (Horde_Icalendar_Exception $e) {
112
foreach (array(self::N_PREFIX, self::N_GIVEN, self::N_ADDL, self::N_FAMILY, self::N_SUFFIX) as $val) {
113
if (!empty($name_parts[$val])) {
114
$name_arr[] = $name_parts[$val];
118
return implode(' ', $name_arr);
122
* Static function to make a given email address rfc822 compliant.
124
* @param string $address An email address.
126
* @return string The RFC822-formatted email address.
128
static function getBareEmail($address)
130
$ob = new Horde_Mail_Rfc822_Address($address);
131
return $ob->bare_address;