]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/CardDAV/Property/SupportedAddressData.php
36d9306e7aabd1ce55525922ce7e574a0acc640d
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / CardDAV / Property / SupportedAddressData.php
1 <?php
2
3 /**
4  * Supported-address-data property
5  *
6  * This property is a representation of the supported-address-data property
7  * in the CardDAV namespace.
8  *
9  * @package Sabre
10  * @subpackage CardDAV
11  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
12  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
13  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
14  */
15 class Sabre_CardDAV_Property_SupportedAddressData extends Sabre_DAV_Property {
16
17     /**
18      * supported versions
19      *
20      * @var array
21      */
22     protected $supportedData = array();
23
24     /**
25      * Creates the property
26      *
27      * @param array|null $supportedData
28      */
29     public function __construct(array $supportedData = null) {
30
31         if (is_null($supportedData)) {
32             $supportedData = array(
33                 array('contentType' => 'text/vcard', 'version' => '3.0'),
34                 array('contentType' => 'text/vcard', 'version' => '4.0'),
35             );
36         }
37
38        $this->supportedData = $supportedData;
39
40     }
41
42     /**
43      * Serializes the property in a DOMDocument
44      *
45      * @param Sabre_DAV_Server $server
46      * @param DOMElement $node
47      * @return void
48      */
49     public function serialize(Sabre_DAV_Server $server,DOMElement $node) {
50
51         $doc = $node->ownerDocument;
52
53         $prefix =
54             isset($server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV]) ?
55             $server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV] :
56             'card';
57
58         foreach($this->supportedData as $supported) {
59
60             $caldata = $doc->createElementNS(Sabre_CardDAV_Plugin::NS_CARDDAV, $prefix . ':address-data-type');
61             $caldata->setAttribute('content-type',$supported['contentType']);
62             $caldata->setAttribute('version',$supported['version']);
63             $node->appendChild($caldata);
64
65         }
66
67     }
68
69 }