[Pkg-owncloud-commits] [php-sabre-vobject] 199/341: Support vCard group.
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:47 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit 1cdacfb2d4af2b1e6aa710784cb8cbaf0dd5285e
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date: Mon Jan 26 11:44:48 2015 +0100
Support vCard group.
---
lib/Parser/XML.php | 22 ++++++++++++++++++++--
tests/VObject/Parser/XmlTest.php | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/lib/Parser/XML.php b/lib/Parser/XML.php
index 8ea459e..e2f95ce 100644
--- a/lib/Parser/XML.php
+++ b/lib/Parser/XML.php
@@ -158,9 +158,10 @@ class XML extends Parser {
* Parse xCalendar and xCard properties.
*
* @param Component $parentComponent
+ * @param string $propertyNamePrefix
* @return void
*/
- protected function parseProperties(Component $parentComponent) {
+ protected function parseProperties(Component $parentComponent, $propertyNamePrefix = '') {
foreach ($this->pointer as $xmlProperty) {
@@ -197,6 +198,23 @@ class XML extends Parser {
continue;
}
+ // xCard group.
+ if ($propertyName === 'group') {
+
+ if (!isset($xmlProperty['attributes']['name'])) {
+ continue;
+ }
+
+ $this->pointer = &$xmlProperty['value'];
+ $this->parseProperties(
+ $parentComponent,
+ $xmlProperty['attributes']['name'] . '.'
+ );
+
+ continue;
+
+ }
+
// Collect parameters.
foreach ($xmlProperty['value'] as $i => $xmlPropertyChild) {
@@ -293,7 +311,7 @@ class XML extends Parser {
$this->createProperty(
$parentComponent,
- $propertyName,
+ $propertyNamePrefix . $propertyName,
$propertyParameters,
$propertyType,
$propertyValue
diff --git a/tests/VObject/Parser/XmlTest.php b/tests/VObject/Parser/XmlTest.php
index 0e59eae..6808b27 100644
--- a/tests/VObject/Parser/XmlTest.php
+++ b/tests/VObject/Parser/XmlTest.php
@@ -1179,6 +1179,40 @@ XML
}
+ function testRFC6351Section5Group() {
+
+ $this->assertXMLEqualsToMimeDir(
+<<<XML
+<?xml version="1.0" encoding="UTF-8"?>
+<vcards xmlns="urn:ietf:params:xml:ns:vcard-4.0">
+ <vcard>
+ <group name="contact">
+ <fn>
+ <text>Gordon</text>
+ </fn>
+ </group>
+ <group name="media">
+ <fn>
+ <text>Gordon</text>
+ </fn>
+ </group>
+ <tel>
+ <uri>tel:+1-555-555-555</uri>
+ </tel>
+ </vcard>
+</vcards>
+XML
+,
+ 'BEGIN:VCARD' . CRLF .
+ 'VERSION:4.0' . CRLF .
+ 'contact.FN:Gordon' . CRLF .
+ 'media.FN:Gordon' . CRLF .
+ 'TEL:tel:+1-555-555-555' . CRLF .
+ 'END:VCARD' . CRLF
+ );
+
+ }
+
/**
* Check this equality:
* XML -> object model -> MIME Dir.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list