diff options
author | Mario <mario@mariovavti.com> | 2019-04-25 11:24:09 +0200 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-04-25 11:24:09 +0200 |
commit | f1c07977809ce3221286d53e99f0d91145b1166f (patch) | |
tree | 4c067a3b701ea56f10070c386b26a30f93666eb0 /vendor/sabre/vobject/lib/Component/VCard.php | |
parent | 701167bc125700efb3e6ce759b85bcb4d36ee42e (diff) | |
download | volse-hubzilla-f1c07977809ce3221286d53e99f0d91145b1166f.tar.gz volse-hubzilla-f1c07977809ce3221286d53e99f0d91145b1166f.tar.bz2 volse-hubzilla-f1c07977809ce3221286d53e99f0d91145b1166f.zip |
Revert "update composer libs"
This reverts commit e779335d060b3a51d6a144d23af4097ae6801473
Diffstat (limited to 'vendor/sabre/vobject/lib/Component/VCard.php')
-rw-r--r-- | vendor/sabre/vobject/lib/Component/VCard.php | 314 |
1 files changed, 169 insertions, 145 deletions
diff --git a/vendor/sabre/vobject/lib/Component/VCard.php b/vendor/sabre/vobject/lib/Component/VCard.php index 860e45ffa..bca623d5e 100644 --- a/vendor/sabre/vobject/lib/Component/VCard.php +++ b/vendor/sabre/vobject/lib/Component/VCard.php @@ -15,8 +15,8 @@ use Sabre\Xml; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class VCard extends VObject\Document -{ +class VCard extends VObject\Document { + /** * The default name for this component. * @@ -24,7 +24,7 @@ class VCard extends VObject\Document * * @var string */ - public static $defaultName = 'VCARD'; + static $defaultName = 'VCARD'; /** * Caching the version number. @@ -38,7 +38,7 @@ class VCard extends VObject\Document * * @var array */ - public static $componentMap = [ + static $componentMap = [ 'VCARD' => 'Sabre\\VObject\\Component\\VCard', ]; @@ -47,23 +47,23 @@ class VCard extends VObject\Document * * @var array */ - public static $valueMap = [ - 'BINARY' => 'Sabre\\VObject\\Property\\Binary', - 'BOOLEAN' => 'Sabre\\VObject\\Property\\Boolean', - 'CONTENT-ID' => 'Sabre\\VObject\\Property\\FlatText', // vCard 2.1 only - 'DATE' => 'Sabre\\VObject\\Property\\VCard\\Date', - 'DATE-TIME' => 'Sabre\\VObject\\Property\\VCard\\DateTime', + static $valueMap = [ + 'BINARY' => 'Sabre\\VObject\\Property\\Binary', + 'BOOLEAN' => 'Sabre\\VObject\\Property\\Boolean', + 'CONTENT-ID' => 'Sabre\\VObject\\Property\\FlatText', // vCard 2.1 only + 'DATE' => 'Sabre\\VObject\\Property\\VCard\\Date', + 'DATE-TIME' => 'Sabre\\VObject\\Property\\VCard\\DateTime', 'DATE-AND-OR-TIME' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', // vCard only - 'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue', - 'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue', - 'LANGUAGE-TAG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', - 'TIMESTAMP' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', - 'TEXT' => 'Sabre\\VObject\\Property\\Text', - 'TIME' => 'Sabre\\VObject\\Property\\Time', - 'UNKNOWN' => 'Sabre\\VObject\\Property\\Unknown', // jCard / jCal-only. - 'URI' => 'Sabre\\VObject\\Property\\Uri', - 'URL' => 'Sabre\\VObject\\Property\\Uri', // vCard 2.1 only - 'UTC-OFFSET' => 'Sabre\\VObject\\Property\\UtcOffset', + 'FLOAT' => 'Sabre\\VObject\\Property\\FloatValue', + 'INTEGER' => 'Sabre\\VObject\\Property\\IntegerValue', + 'LANGUAGE-TAG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', + 'TIMESTAMP' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', + 'TEXT' => 'Sabre\\VObject\\Property\\Text', + 'TIME' => 'Sabre\\VObject\\Property\\Time', + 'UNKNOWN' => 'Sabre\\VObject\\Property\\Unknown', // jCard / jCal-only. + 'URI' => 'Sabre\\VObject\\Property\\Uri', + 'URL' => 'Sabre\\VObject\\Property\\Uri', // vCard 2.1 only + 'UTC-OFFSET' => 'Sabre\\VObject\\Property\\UtcOffset', ]; /** @@ -71,70 +71,72 @@ class VCard extends VObject\Document * * @var array */ - public static $propertyMap = [ + static $propertyMap = [ + // vCard 2.1 properties and up - 'N' => 'Sabre\\VObject\\Property\\Text', - 'FN' => 'Sabre\\VObject\\Property\\FlatText', - 'PHOTO' => 'Sabre\\VObject\\Property\\Binary', - 'BDAY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', - 'ADR' => 'Sabre\\VObject\\Property\\Text', - 'LABEL' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 - 'TEL' => 'Sabre\\VObject\\Property\\FlatText', - 'EMAIL' => 'Sabre\\VObject\\Property\\FlatText', + 'N' => 'Sabre\\VObject\\Property\\Text', + 'FN' => 'Sabre\\VObject\\Property\\FlatText', + 'PHOTO' => 'Sabre\\VObject\\Property\\Binary', + 'BDAY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', + 'ADR' => 'Sabre\\VObject\\Property\\Text', + 'LABEL' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 + 'TEL' => 'Sabre\\VObject\\Property\\FlatText', + 'EMAIL' => 'Sabre\\VObject\\Property\\FlatText', 'MAILER' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 - 'GEO' => 'Sabre\\VObject\\Property\\FlatText', - 'TITLE' => 'Sabre\\VObject\\Property\\FlatText', - 'ROLE' => 'Sabre\\VObject\\Property\\FlatText', - 'LOGO' => 'Sabre\\VObject\\Property\\Binary', + 'GEO' => 'Sabre\\VObject\\Property\\FlatText', + 'TITLE' => 'Sabre\\VObject\\Property\\FlatText', + 'ROLE' => 'Sabre\\VObject\\Property\\FlatText', + 'LOGO' => 'Sabre\\VObject\\Property\\Binary', // 'AGENT' => 'Sabre\\VObject\\Property\\', // Todo: is an embedded vCard. Probably rare, so // not supported at the moment - 'ORG' => 'Sabre\\VObject\\Property\\Text', - 'NOTE' => 'Sabre\\VObject\\Property\\FlatText', - 'REV' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', - 'SOUND' => 'Sabre\\VObject\\Property\\FlatText', - 'URL' => 'Sabre\\VObject\\Property\\Uri', - 'UID' => 'Sabre\\VObject\\Property\\FlatText', + 'ORG' => 'Sabre\\VObject\\Property\\Text', + 'NOTE' => 'Sabre\\VObject\\Property\\FlatText', + 'REV' => 'Sabre\\VObject\\Property\\VCard\\TimeStamp', + 'SOUND' => 'Sabre\\VObject\\Property\\FlatText', + 'URL' => 'Sabre\\VObject\\Property\\Uri', + 'UID' => 'Sabre\\VObject\\Property\\FlatText', 'VERSION' => 'Sabre\\VObject\\Property\\FlatText', - 'KEY' => 'Sabre\\VObject\\Property\\FlatText', - 'TZ' => 'Sabre\\VObject\\Property\\Text', + 'KEY' => 'Sabre\\VObject\\Property\\FlatText', + 'TZ' => 'Sabre\\VObject\\Property\\Text', // vCard 3.0 properties - 'CATEGORIES' => 'Sabre\\VObject\\Property\\Text', + 'CATEGORIES' => 'Sabre\\VObject\\Property\\Text', 'SORT-STRING' => 'Sabre\\VObject\\Property\\FlatText', - 'PRODID' => 'Sabre\\VObject\\Property\\FlatText', - 'NICKNAME' => 'Sabre\\VObject\\Property\\Text', - 'CLASS' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 + 'PRODID' => 'Sabre\\VObject\\Property\\FlatText', + 'NICKNAME' => 'Sabre\\VObject\\Property\\Text', + 'CLASS' => 'Sabre\\VObject\\Property\\FlatText', // Removed in vCard 4.0 // rfc2739 properties - 'FBURL' => 'Sabre\\VObject\\Property\\Uri', - 'CAPURI' => 'Sabre\\VObject\\Property\\Uri', - 'CALURI' => 'Sabre\\VObject\\Property\\Uri', + 'FBURL' => 'Sabre\\VObject\\Property\\Uri', + 'CAPURI' => 'Sabre\\VObject\\Property\\Uri', + 'CALURI' => 'Sabre\\VObject\\Property\\Uri', 'CALADRURI' => 'Sabre\\VObject\\Property\\Uri', // rfc4770 properties 'IMPP' => 'Sabre\\VObject\\Property\\Uri', // vCard 4.0 properties - 'SOURCE' => 'Sabre\\VObject\\Property\\Uri', - 'XML' => 'Sabre\\VObject\\Property\\FlatText', - 'ANNIVERSARY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', + 'SOURCE' => 'Sabre\\VObject\\Property\\Uri', + 'XML' => 'Sabre\\VObject\\Property\\FlatText', + 'ANNIVERSARY' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', 'CLIENTPIDMAP' => 'Sabre\\VObject\\Property\\Text', - 'LANG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', - 'GENDER' => 'Sabre\\VObject\\Property\\Text', - 'KIND' => 'Sabre\\VObject\\Property\\FlatText', - 'MEMBER' => 'Sabre\\VObject\\Property\\Uri', - 'RELATED' => 'Sabre\\VObject\\Property\\Uri', + 'LANG' => 'Sabre\\VObject\\Property\\VCard\\LanguageTag', + 'GENDER' => 'Sabre\\VObject\\Property\\Text', + 'KIND' => 'Sabre\\VObject\\Property\\FlatText', + 'MEMBER' => 'Sabre\\VObject\\Property\\Uri', + 'RELATED' => 'Sabre\\VObject\\Property\\Uri', // rfc6474 properties 'BIRTHPLACE' => 'Sabre\\VObject\\Property\\FlatText', 'DEATHPLACE' => 'Sabre\\VObject\\Property\\FlatText', - 'DEATHDATE' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', + 'DEATHDATE' => 'Sabre\\VObject\\Property\\VCard\\DateAndOrTime', // rfc6715 properties - 'EXPERTISE' => 'Sabre\\VObject\\Property\\FlatText', - 'HOBBY' => 'Sabre\\VObject\\Property\\FlatText', - 'INTEREST' => 'Sabre\\VObject\\Property\\FlatText', + 'EXPERTISE' => 'Sabre\\VObject\\Property\\FlatText', + 'HOBBY' => 'Sabre\\VObject\\Property\\FlatText', + 'INTEREST' => 'Sabre\\VObject\\Property\\FlatText', 'ORG-DIRECTORY' => 'Sabre\\VObject\\Property\\FlatText', + ]; /** @@ -142,22 +144,23 @@ class VCard extends VObject\Document * * @return int */ - public function getDocumentType() - { + function getDocumentType() { + if (!$this->version) { - $version = (string) $this->VERSION; + + $version = (string)$this->VERSION; switch ($version) { - case '2.1': + case '2.1' : $this->version = self::VCARD21; break; - case '3.0': + case '3.0' : $this->version = self::VCARD30; break; - case '4.0': + case '4.0' : $this->version = self::VCARD40; break; - default: + default : // We don't want to cache the version if it's unknown, // because we might get a version property in a bit. return self::UNKNOWN; @@ -165,6 +168,7 @@ class VCard extends VObject\Document } return $this->version; + } /** @@ -181,11 +185,11 @@ class VCard extends VObject\Document * * @return VCard */ - public function convert($target) - { - $converter = new VObject\VCardConverter(); + function convert($target) { + $converter = new VObject\VCardConverter(); return $converter->convert($this, $target); + } /** @@ -217,8 +221,8 @@ class VCard extends VObject\Document * * @return array */ - public function validate($options = 0) - { + function validate($options = 0) { + $warnings = []; $versionMap = [ @@ -228,28 +232,29 @@ class VCard extends VObject\Document ]; $version = $this->select('VERSION'); - if (1 === count($version)) { - $version = (string) $this->VERSION; - if ('2.1' !== $version && '3.0' !== $version && '4.0' !== $version) { + if (count($version) === 1) { + $version = (string)$this->VERSION; + if ($version !== '2.1' && $version !== '3.0' && $version !== '4.0') { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.', - 'node' => $this, + 'node' => $this, ]; if ($options & self::REPAIR) { $this->VERSION = $versionMap[self::DEFAULT_VERSION]; } } - if ('2.1' === $version && ($options & self::PROFILE_CARDDAV)) { + if ($version === '2.1' && ($options & self::PROFILE_CARDDAV)) { $warnings[] = [ - 'level' => 3, + 'level' => 3, 'message' => 'CardDAV servers are not allowed to accept vCard 2.1.', - 'node' => $this, + 'node' => $this, ]; } + } $uid = $this->select('UID'); - if (0 === count($uid)) { + if (count($uid) === 0) { if ($options & self::PROFILE_CARDDAV) { // Required for CardDAV $warningLevel = 3; @@ -264,22 +269,23 @@ class VCard extends VObject\Document $warningLevel = 1; } $warnings[] = [ - 'level' => $warningLevel, + 'level' => $warningLevel, 'message' => $message, - 'node' => $this, + 'node' => $this, ]; } $fn = $this->select('FN'); - if (1 !== count($fn)) { + if (count($fn) !== 1) { + $repaired = false; - if (($options & self::REPAIR) && 0 === count($fn)) { + if (($options & self::REPAIR) && count($fn) === 0) { // We're going to try to see if we can use the contents of the // N property. if (isset($this->N)) { - $value = explode(';', (string) $this->N); + $value = explode(';', (string)$this->N); if (isset($value[1]) && $value[1]) { - $this->FN = $value[1].' '.$value[0]; + $this->FN = $value[1] . ' ' . $value[0]; } else { $this->FN = $value[0]; } @@ -287,19 +293,20 @@ class VCard extends VObject\Document // Otherwise, the ORG property may work } elseif (isset($this->ORG)) { - $this->FN = (string) $this->ORG; + $this->FN = (string)$this->ORG; $repaired = true; // Otherwise, the EMAIL property may work } elseif (isset($this->EMAIL)) { - $this->FN = (string) $this->EMAIL; + $this->FN = (string)$this->EMAIL; $repaired = true; } + } $warnings[] = [ - 'level' => $repaired ? 1 : 3, + 'level' => $repaired ? 1 : 3, 'message' => 'The FN property must appear in the VCARD component exactly 1 time', - 'node' => $this, + 'node' => $this, ]; } @@ -307,6 +314,7 @@ class VCard extends VObject\Document parent::validate($options), $warnings ); + } /** @@ -324,49 +332,50 @@ class VCard extends VObject\Document * * @var array */ - public function getValidationRules() - { + function getValidationRules() { + return [ - 'ADR' => '*', - 'ANNIVERSARY' => '?', - 'BDAY' => '?', - 'CALADRURI' => '*', - 'CALURI' => '*', - 'CATEGORIES' => '*', + 'ADR' => '*', + 'ANNIVERSARY' => '?', + 'BDAY' => '?', + 'CALADRURI' => '*', + 'CALURI' => '*', + 'CATEGORIES' => '*', 'CLIENTPIDMAP' => '*', - 'EMAIL' => '*', - 'FBURL' => '*', - 'IMPP' => '*', - 'GENDER' => '?', - 'GEO' => '*', - 'KEY' => '*', - 'KIND' => '?', - 'LANG' => '*', - 'LOGO' => '*', - 'MEMBER' => '*', - 'N' => '?', - 'NICKNAME' => '*', - 'NOTE' => '*', - 'ORG' => '*', - 'PHOTO' => '*', - 'PRODID' => '?', - 'RELATED' => '*', - 'REV' => '?', - 'ROLE' => '*', - 'SOUND' => '*', - 'SOURCE' => '*', - 'TEL' => '*', - 'TITLE' => '*', - 'TZ' => '*', - 'URL' => '*', - 'VERSION' => '1', - 'XML' => '*', + 'EMAIL' => '*', + 'FBURL' => '*', + 'IMPP' => '*', + 'GENDER' => '?', + 'GEO' => '*', + 'KEY' => '*', + 'KIND' => '?', + 'LANG' => '*', + 'LOGO' => '*', + 'MEMBER' => '*', + 'N' => '?', + 'NICKNAME' => '*', + 'NOTE' => '*', + 'ORG' => '*', + 'PHOTO' => '*', + 'PRODID' => '?', + 'RELATED' => '*', + 'REV' => '?', + 'ROLE' => '*', + 'SOUND' => '*', + 'SOURCE' => '*', + 'TEL' => '*', + 'TITLE' => '*', + 'TZ' => '*', + 'URL' => '*', + 'VERSION' => '1', + 'XML' => '*', // FN is commented out, because it's already handled by the // validate function, which may also try to repair it. // 'FN' => '+', 'UID' => '?', ]; + } /** @@ -383,11 +392,12 @@ class VCard extends VObject\Document * * @return VObject\Property|null */ - public function preferred($propertyName) - { + function preferred($propertyName) { + $preferred = null; $lastPref = 101; foreach ($this->select($propertyName) as $field) { + $pref = 101; if (isset($field['TYPE']) && $field['TYPE']->has('PREF')) { $pref = 1; @@ -399,9 +409,10 @@ class VCard extends VObject\Document $preferred = $field; $lastPref = $pref; } - } + } return $preferred; + } /** @@ -415,8 +426,7 @@ class VCard extends VObject\Document * * @return VObject\Property|null */ - public function getByType($propertyName, $type) - { + function getByType($propertyName, $type) { foreach ($this->select($propertyName) as $field) { if (isset($field['TYPE']) && $field['TYPE']->has($type)) { return $field; @@ -429,13 +439,14 @@ class VCard extends VObject\Document * * @return array */ - protected function getDefaults() - { + protected function getDefaults() { + return [ 'VERSION' => '4.0', - 'PRODID' => '-//Sabre//Sabre VObject '.VObject\Version::VERSION.'//EN', - 'UID' => 'sabre-vobject-'.VObject\UUIDUtil::getUUID(), + 'PRODID' => '-//Sabre//Sabre VObject ' . VObject\Version::VERSION . '//EN', + 'UID' => 'sabre-vobject-' . VObject\UUIDUtil::getUUID(), ]; + } /** @@ -444,8 +455,8 @@ class VCard extends VObject\Document * * @return array */ - public function jsonSerialize() - { + function jsonSerialize() { + // A vcard does not have sub-components, so we're overriding this // method to remove that array element. $properties = []; @@ -458,19 +469,23 @@ class VCard extends VObject\Document strtolower($this->name), $properties, ]; + } /** * This method serializes the data into XML. This is used to create xCard or * xCal documents. * - * @param Xml\Writer $writer XML writer + * @param Xml\Writer $writer XML writer. + * + * @return void */ - public function xmlSerialize(Xml\Writer $writer) - { + function xmlSerialize(Xml\Writer $writer) { + $propertiesByGroup = []; foreach ($this->children() as $property) { + $group = $property->group; if (!isset($propertiesByGroup[$group])) { @@ -478,20 +493,25 @@ class VCard extends VObject\Document } $propertiesByGroup[$group][] = $property; + } $writer->startElement(strtolower($this->name)); foreach ($propertiesByGroup as $group => $properties) { + if (!empty($group)) { + $writer->startElement('group'); $writer->writeAttribute('name', strtolower($group)); + } foreach ($properties as $property) { switch ($property->name) { + case 'VERSION': - break; + continue; case 'XML': $value = $property->getParts(); @@ -502,15 +522,18 @@ class VCard extends VObject\Document default: $property->xmlSerialize($writer); break; + } } if (!empty($group)) { $writer->endElement(); } + } $writer->endElement(); + } /** @@ -520,15 +543,16 @@ class VCard extends VObject\Document * * @return string */ - public function getClassNameForPropertyName($propertyName) - { + function getClassNameForPropertyName($propertyName) { + $className = parent::getClassNameForPropertyName($propertyName); // In vCard 4, BINARY no longer exists, and we need URI instead. - if ('Sabre\\VObject\\Property\\Binary' == $className && self::VCARD40 === $this->getDocumentType()) { + if ($className == 'Sabre\\VObject\\Property\\Binary' && $this->getDocumentType() === self::VCARD40) { return 'Sabre\\VObject\\Property\\Uri'; } - return $className; + } + } |