]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/DAV/Property/HrefList.php
privacy_image_cache: checking if the cached file really is an image
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / DAV / Property / HrefList.php
1 <?php
2
3 /**
4  * HrefList property
5  *
6  * This property contains multiple {DAV:}href elements, each containing a url.
7  *
8  * @package Sabre
9  * @subpackage DAV
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
13  */
14 class Sabre_DAV_Property_HrefList extends Sabre_DAV_Property {
15
16     /**
17      * hrefs
18      *
19      * @var array
20      */
21     private $hrefs;
22
23     /**
24      * Automatically prefix the url with the server base directory
25      *
26      * @var bool
27      */
28     private $autoPrefix = true;
29
30     /**
31      * __construct
32      *
33      * @param array $hrefs
34      * @param bool $autoPrefix
35      */
36     public function __construct(array $hrefs, $autoPrefix = true) {
37
38         $this->hrefs = $hrefs;
39         $this->autoPrefix = $autoPrefix;
40
41     }
42
43     /**
44      * Returns the uris
45      *
46      * @return array
47      */
48     public function getHrefs() {
49
50         return $this->hrefs;
51
52     }
53
54     /**
55      * Serializes this property.
56      *
57      * It will additionally prepend the href property with the server's base uri.
58      *
59      * @param Sabre_DAV_Server $server
60      * @param DOMElement $dom
61      * @return void
62      */
63     public function serialize(Sabre_DAV_Server $server,DOMElement $dom) {
64
65         $prefix = $server->xmlNamespaces['DAV:'];
66
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);
71         }
72
73     }
74
75     /**
76      * Unserializes this property from a DOM Element
77      *
78      * This method returns an instance of this class.
79      * It will only decode {DAV:}href values.
80      *
81      * @param DOMElement $dom
82      * @return Sabre_DAV_Property_HrefList
83      */
84     static function unserialize(DOMElement $dom) {
85
86         $hrefs = array();
87         foreach($dom->childNodes as $child) {
88             if (Sabre_DAV_XMLUtil::toClarkNotation($child)==='{DAV:}href') {
89                 $hrefs[] = $child->textContent;
90             }
91         }
92         return new self($hrefs, false);
93
94     }
95
96 }