6 * This property contains multiple {DAV:}href elements, each containing a url.
10 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
11 * @author Evert Pot (http://www.rooftopsolutions.nl/)
12 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
14 class Sabre_DAV_Property_HrefList extends Sabre_DAV_Property {
24 * Automatically prefix the url with the server base directory
28 private $autoPrefix = true;
34 * @param bool $autoPrefix
36 public function __construct(array $hrefs, $autoPrefix = true) {
38 $this->hrefs = $hrefs;
39 $this->autoPrefix = $autoPrefix;
48 public function getHrefs() {
55 * Serializes this property.
57 * It will additionally prepend the href property with the server's base uri.
59 * @param Sabre_DAV_Server $server
60 * @param DOMElement $dom
63 public function serialize(Sabre_DAV_Server $server,DOMElement $dom) {
65 $prefix = $server->xmlNamespaces['DAV:'];
67 foreach($this->hrefs as $href) {
68 $elem = $dom->ownerDocument->createElement($prefix . ':href');
69 $elem->nodeValue = ($this->autoPrefix?$server->getBaseUri():'') . $href;
70 $dom->appendChild($elem);
76 * Unserializes this property from a DOM Element
78 * This method returns an instance of this class.
79 * It will only decode {DAV:}href values.
81 * @param DOMElement $dom
82 * @return Sabre_DAV_Property_HrefList
84 static function unserialize(DOMElement $dom) {
87 foreach($dom->childNodes as $child) {
88 if (Sabre_DAV_XMLUtil::toClarkNotation($child)==='{DAV:}href') {
89 $hrefs[] = $child->textContent;
92 return new self($hrefs, false);