[Pkg-owncloud-commits] [php-sabre-vobject] 179/341: Start supporting vCard.
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:45 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 961efcdf5f87fec7c72835346941e0255bfd527f
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date: Wed Jan 21 15:29:44 2015 +0100
Start supporting vCard.
---
lib/Parser/XML.php | 46 ++++++++++++++++++++++++++++++++++------------
1 file changed, 34 insertions(+), 12 deletions(-)
diff --git a/lib/Parser/XML.php b/lib/Parser/XML.php
index 9242793..2a37ec7 100644
--- a/lib/Parser/XML.php
+++ b/lib/Parser/XML.php
@@ -84,14 +84,32 @@ class XML extends Parser {
throw new EofException('End of input stream, or no input supplied');
}
- if ($this->input['name'] === '{' . self::XCAL_NAMESPACE . '}icalendar') {
+ switch ($this->input['name']) {
- $this->root = new VCalendar([], false);
- $this->pointer = &$this->input['value'][0];
- $this->parseVcalendarComponents($this->root);
+ case '{' . self::XCAL_NAMESPACE . '}icalendar':
+ $this->root = new VCalendar([], false);
+ $this->pointer = &$this->input['value'][0];
+ $this->parseVCalendarComponents($this->root);
+ break;
+
+ case '{' . self::XCARD_NAMESPACE . '}vcards':
+ $collection = [];
+
+ foreach ($this->input['value'] as &$vCard) {
+
+ $this->root = new VCard(['version' => '4.0'], false);
+ $collection[] = $this->root;
+ $this->pointer = &$vCard;
+ $this->parseVCardComponents($this->root);
+
+ }
+
+ $this->root = $collection;
+ break;
+
+ default:
+ throw new \Exception('Unsupported XML standard');
- } else {
- throw new \Exception('Unsupported XML standard');
}
return $this->root;
@@ -123,14 +141,18 @@ class XML extends Parser {
}
- foreach ($xmlParameters as $xmlParameter) {
- $propertyParameters[static::getTagName($xmlParameter['name'])]
- = $xmlParameter['value'][0]['value'];
- }
+ /**
+ * Parse a vCard.
+ *
+ * @param Sabre\VObject\Component $parentComponent
+ * @return void
+ */
+ protected function parseVCardComponents(Component $parentComponent) {
- array_splice($xmlProperty['value'], $i, 1);
+ $this->pointer = &$this->pointer['value'];
+ $this->parseProperty($parentComponent);
- }
+ }
protected function parseProperty(Component $parentComponent) {
--
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