[Pkg-owncloud-commits] [php-sabre-vobject] 213/341: Support groups when serializing to xCard.
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:49 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 df9bd377fa0f7f3a6190df2317d1fc207bd4668f
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date: Mon Jan 26 16:28:16 2015 +0100
Support groups when serializing to xCard.
---
lib/Component/VCard.php | 47 +++++++++++++++++++++++++++++++++++++----------
1 file changed, 37 insertions(+), 10 deletions(-)
diff --git a/lib/Component/VCard.php b/lib/Component/VCard.php
index b5a10a5..4cee726 100644
--- a/lib/Component/VCard.php
+++ b/lib/Component/VCard.php
@@ -439,23 +439,50 @@ class VCard extends VObject\Document {
*/
function xmlSerialize(Xml\Writer $writer) {
- $writer->startElement(strtolower($this->name));
+ $propertiesByGroup = [];
foreach ($this->children as $property) {
- switch ($property->name) {
+ $group = $property->group;
- case 'VERSION':
- continue;
+ if (!isset($propertiesByGroup[$group])) {
+ $propertiesByGroup[$group] = [];
+ }
- case 'XML':
- $value = $property->getParts();
- $writer->writeRaw(' ' . $value[0] . "\n ");
- break;
+ $propertiesByGroup[$group][] = $property;
+
+ }
+
+ $writer->startElement(strtolower($this->name));
+
+ foreach ($propertiesByGroup as $group => $properties) {
+
+ if (!empty($group)) {
- default:
- $property->xmlSerialize($writer);
+ $writer->startElement('group');
+ $writer->writeAttribute('name', strtolower($group));
+
+ }
+
+ foreach ($properties as $property) {
+ switch ($property->name) {
+
+ case 'VERSION':
+ continue;
+
+ case 'XML':
+ $value = $property->getParts();
+ $writer->writeRaw(' ' . $value[0] . "\n ");
+ break;
+
+ default:
+ $property->xmlSerialize($writer);
+
+ }
+ }
+ if (!empty($group)) {
+ $writer->endElement();
}
}
--
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