42 'VCARD' =>
'Sabre\\VObject\\Component\\VCard',
51 'BINARY' =>
'Sabre\\VObject\\Property\\Binary',
52 'BOOLEAN' =>
'Sabre\\VObject\\Property\\Boolean',
53 'CONTENT-ID' =>
'Sabre\\VObject\\Property\\FlatText',
54 'DATE' =>
'Sabre\\VObject\\Property\\VCard\\Date',
55 'DATE-TIME' =>
'Sabre\\VObject\\Property\\VCard\\DateTime',
56 'DATE-AND-OR-TIME' =>
'Sabre\\VObject\\Property\\VCard\\DateAndOrTime',
57 'FLOAT' =>
'Sabre\\VObject\\Property\\FloatValue',
58 'INTEGER' =>
'Sabre\\VObject\\Property\\IntegerValue',
59 'LANGUAGE-TAG' =>
'Sabre\\VObject\\Property\\VCard\\LanguageTag',
60 'TIMESTAMP' =>
'Sabre\\VObject\\Property\\VCard\\TimeStamp',
61 'TEXT' =>
'Sabre\\VObject\\Property\\Text',
62 'TIME' =>
'Sabre\\VObject\\Property\\Time',
63 'UNKNOWN' =>
'Sabre\\VObject\\Property\\Unknown',
64 'URI' =>
'Sabre\\VObject\\Property\\Uri',
65 'URL' =>
'Sabre\\VObject\\Property\\Uri',
66 'UTC-OFFSET' =>
'Sabre\\VObject\\Property\\UtcOffset',
77 'N' =>
'Sabre\\VObject\\Property\\Text',
78 'FN' =>
'Sabre\\VObject\\Property\\FlatText',
79 'PHOTO' =>
'Sabre\\VObject\\Property\\Binary',
80 'BDAY' =>
'Sabre\\VObject\\Property\\VCard\\DateAndOrTime',
81 'ADR' =>
'Sabre\\VObject\\Property\\Text',
82 'LABEL' =>
'Sabre\\VObject\\Property\\FlatText',
83 'TEL' =>
'Sabre\\VObject\\Property\\FlatText',
84 'EMAIL' =>
'Sabre\\VObject\\Property\\FlatText',
85 'MAILER' =>
'Sabre\\VObject\\Property\\FlatText',
86 'GEO' =>
'Sabre\\VObject\\Property\\FlatText',
87 'TITLE' =>
'Sabre\\VObject\\Property\\FlatText',
88 'ROLE' =>
'Sabre\\VObject\\Property\\FlatText',
89 'LOGO' =>
'Sabre\\VObject\\Property\\Binary',
92 'ORG' =>
'Sabre\\VObject\\Property\\Text',
93 'NOTE' =>
'Sabre\\VObject\\Property\\FlatText',
94 'REV' =>
'Sabre\\VObject\\Property\\VCard\\TimeStamp',
95 'SOUND' =>
'Sabre\\VObject\\Property\\FlatText',
96 'URL' =>
'Sabre\\VObject\\Property\\Uri',
97 'UID' =>
'Sabre\\VObject\\Property\\FlatText',
98 'VERSION' =>
'Sabre\\VObject\\Property\\FlatText',
99 'KEY' =>
'Sabre\\VObject\\Property\\FlatText',
100 'TZ' =>
'Sabre\\VObject\\Property\\Text',
103 'CATEGORIES' =>
'Sabre\\VObject\\Property\\Text',
104 'SORT-STRING' =>
'Sabre\\VObject\\Property\\FlatText',
105 'PRODID' =>
'Sabre\\VObject\\Property\\FlatText',
106 'NICKNAME' =>
'Sabre\\VObject\\Property\\Text',
107 'CLASS' =>
'Sabre\\VObject\\Property\\FlatText',
110 'FBURL' =>
'Sabre\\VObject\\Property\\Uri',
111 'CAPURI' =>
'Sabre\\VObject\\Property\\Uri',
112 'CALURI' =>
'Sabre\\VObject\\Property\\Uri',
113 'CALADRURI' =>
'Sabre\\VObject\\Property\\Uri',
116 'IMPP' =>
'Sabre\\VObject\\Property\\Uri',
119 'SOURCE' =>
'Sabre\\VObject\\Property\\Uri',
120 'XML' =>
'Sabre\\VObject\\Property\\FlatText',
121 'ANNIVERSARY' =>
'Sabre\\VObject\\Property\\VCard\\DateAndOrTime',
122 'CLIENTPIDMAP' =>
'Sabre\\VObject\\Property\\Text',
123 'LANG' =>
'Sabre\\VObject\\Property\\VCard\\LanguageTag',
124 'GENDER' =>
'Sabre\\VObject\\Property\\Text',
125 'KIND' =>
'Sabre\\VObject\\Property\\FlatText',
126 'MEMBER' =>
'Sabre\\VObject\\Property\\Uri',
127 'RELATED' =>
'Sabre\\VObject\\Property\\Uri',
130 'BIRTHPLACE' =>
'Sabre\\VObject\\Property\\FlatText',
131 'DEATHPLACE' =>
'Sabre\\VObject\\Property\\FlatText',
132 'DEATHDATE' =>
'Sabre\\VObject\\Property\\VCard\\DateAndOrTime',
135 'EXPERTISE' =>
'Sabre\\VObject\\Property\\FlatText',
136 'HOBBY' =>
'Sabre\\VObject\\Property\\FlatText',
137 'INTEREST' =>
'Sabre\\VObject\\Property\\FlatText',
138 'ORG-DIRECTORY' =>
'Sabre\\VObject\\Property\\FlatText',
149 if (!$this->version) {
155 $this->version = self::VCARD21;
158 $this->version = self::VCARD30;
161 $this->version = self::VCARD40;
166 return self::UNKNOWN;
191 return $converter->convert($this,
$target);
229 self::VCARD21 =>
'2.1',
230 self::VCARD30 =>
'3.0',
231 self::VCARD40 =>
'4.0',
240 'message' =>
'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.',
244 $this->VERSION = $versionMap[self::DEFAULT_VERSION];
250 'message' =>
'CardDAV servers are not allowed to accept vCard 2.1.',
256 $uid = $this->
select(
'UID');
257 if (
count($uid) === 0) {
258 if (
$options & self::PROFILE_CARDDAV) {
261 $message =
'vCards on CardDAV servers MUST have a UID property.';
265 $message =
'Adding a UID to a vCard property is recommended.';
272 'level' => $warningLevel,
278 $fn = $this->
select(
'FN');
279 if (
count($fn) !== 1) {
285 if (isset($this->N)) {
286 $value = explode(
';', (
string)$this->N);
287 if (isset($value[1]) && $value[1]) {
288 $this->FN = $value[1] .
' ' . $value[0];
290 $this->FN = $value[0];
295 } elseif (isset($this->ORG)) {
296 $this->FN = (string)$this->ORG;
300 } elseif (isset($this->EMAIL)) {
301 $this->FN = (string)$this->EMAIL;
307 'level' => $repaired ? 1 : 3,
308 'message' =>
'The FN property must appear in the VCARD component exactly 1 time',
339 'ANNIVERSARY' =>
'?',
344 'CLIENTPIDMAP' =>
'*',
399 foreach ($this->
select($propertyName) as $field) {
402 if (isset($field[
'TYPE']) && $field[
'TYPE']->has(
'PREF')) {
404 } elseif (isset($field[
'PREF'])) {
405 $pref = $field[
'PREF']->getValue();
408 if ($pref < $lastPref || is_null($preferred)) {
430 foreach ($this->
select($propertyName) as $field) {
431 if (isset($field[
'TYPE']) && $field[
'TYPE']->has(
$type)) {
464 foreach ($this->
children() as $child) {
465 $properties[] = $child->jsonSerialize();
469 strtolower($this->name),
485 $propertiesByGroup = [];
487 foreach ($this->
children() as $property) {
489 $group = $property->group;
491 if (!isset($propertiesByGroup[$group])) {
492 $propertiesByGroup[$group] = [];
495 $propertiesByGroup[$group][] = $property;
499 $writer->startElement(strtolower($this->name));
501 foreach ($propertiesByGroup as $group => $properties) {
503 if (!empty($group)) {
505 $writer->startElement(
'group');
506 $writer->writeAttribute(
'name', strtolower($group));
510 foreach ($properties as $property) {
511 switch ($property->name) {
517 $value = $property->getParts();
518 $fragment =
new Xml\Element\XmlFragment($value[0]);
519 $writer->write($fragment);
523 $property->xmlSerialize($writer);
529 if (!empty($group)) {
530 $writer->endElement();
535 $writer->endElement();
548 $className = parent::getClassNameForPropertyName($propertyName);
551 if ($className ==
'Sabre\\VObject\\Property\\Binary' && $this->
getDocumentType() === self::VCARD40) {
552 return 'Sabre\\VObject\\Property\\Uri';
getByType($propertyName, $type)
Returns a property with a specific TYPE value (ADR, TEL, or EMAIL).
xmlSerialize(Xml\Writer $writer)
This method serializes the data into XML.
iCalendar/vCard/jCal/jCard/xCal/xCard writer object.
This utility converts vcards from one version to another.
select($name)
Returns an array with elements that match the specified name.
jsonSerialize()
This method returns an array, with the representation as it should be encoded in json.
const VERSION
Full version number.
convert($target)
Converts the document to a different vcard version.
getClassNameForPropertyName($propertyName)
Returns the default class for a property name.
const DEFAULT_VERSION
VCards with version 2.1, 3.0 and 4.0 are found.
catch(Exception $e) $message
preferred($propertyName)
Returns a preferred field.
count()
Returns the number of elements.
getDefaults()
This method should return a list of default property values.
static getUUID()
Returns a pseudo-random v4 UUID.
static getDocumentType()
Returns the current document type.
children()
Returns a flat list of all the properties and components in this component.
validate($options=0)
Validates the node for correctness.