4 * supported-report-set property.
6 * This property is defined in RFC3253, but since it's
7 * so common in other webdav-related specs, it is part of the core server.
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_DAV_Property_SupportedReportSet extends Sabre_DAV_Property {
22 protected $reports = array();
25 * Creates the property
27 * Any reports passed in the constructor
28 * should be valid report-types in clark-notation.
30 * Either a string or an array of strings must be passed.
32 * @param mixed $reports
34 public function __construct($reports = null) {
36 if (!is_null($reports))
37 $this->addReport($reports);
42 * Adds a report to this property
44 * The report must be a string in clark-notation.
45 * Multiple reports can be specified as an array.
47 * @param mixed $report
50 public function addReport($report) {
52 if (!is_array($report)) $report = array($report);
54 foreach($report as $r) {
56 if (!preg_match('/^{([^}]*)}(.*)$/',$r))
57 throw new Sabre_DAV_Exception('Reportname must be in clark-notation');
59 $this->reports[] = $r;
66 * Returns the list of supported reports
70 public function getValue() {
72 return $this->reports;
79 * @param Sabre_DAV_Server $server
80 * @param DOMElement $prop
83 public function serialize(Sabre_DAV_Server $server, DOMElement $prop) {
85 foreach($this->reports as $reportName) {
87 $supportedReport = $prop->ownerDocument->createElement('d:supported-report');
88 $prop->appendChild($supportedReport);
90 $report = $prop->ownerDocument->createElement('d:report');
91 $supportedReport->appendChild($report);
93 preg_match('/^{([^}]*)}(.*)$/',$reportName,$matches);
95 list(, $namespace, $element) = $matches;
97 $prefix = isset($server->xmlNamespaces[$namespace])?$server->xmlNamespaces[$namespace]:null;
100 $report->appendChild($prop->ownerDocument->createElement($prefix . ':' . $element));
102 $report->appendChild($prop->ownerDocument->createElementNS($namespace, 'x:' . $element));