4 * Supported-address-data property
6 * This property is a representation of the supported-address-data property
7 * in the CardDAV namespace.
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
15 class Sabre_CardDAV_Property_SupportedAddressData extends Sabre_DAV_Property {
22 protected $supportedData = array();
25 * Creates the property
27 * @param array|null $supportedData
29 public function __construct(array $supportedData = null) {
31 if (is_null($supportedData)) {
32 $supportedData = array(
33 array('contentType' => 'text/vcard', 'version' => '3.0'),
34 array('contentType' => 'text/vcard', 'version' => '4.0'),
38 $this->supportedData = $supportedData;
43 * Serializes the property in a DOMDocument
45 * @param Sabre_DAV_Server $server
46 * @param DOMElement $node
49 public function serialize(Sabre_DAV_Server $server,DOMElement $node) {
51 $doc = $node->ownerDocument;
54 isset($server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV]) ?
55 $server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV] :
58 foreach($this->supportedData as $supported) {
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);