From b35122f7a6ad42756c35bb60ba1f06c3dcd45c77 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 21 Oct 2013 15:46:31 -0700 Subject: add sabre (1.8.x) via composer in the !@#$ place it wants to be --- .../dav/lib/Sabre/DAV/Property/GetLastModified.php | 78 ++++++++++ vendor/sabre/dav/lib/Sabre/DAV/Property/Href.php | 99 +++++++++++++ .../sabre/dav/lib/Sabre/DAV/Property/HrefList.php | 105 ++++++++++++++ vendor/sabre/dav/lib/Sabre/DAV/Property/IHref.php | 25 ++++ .../dav/lib/Sabre/DAV/Property/LockDiscovery.php | 104 ++++++++++++++ .../dav/lib/Sabre/DAV/Property/ResourceType.php | 127 +++++++++++++++++ .../sabre/dav/lib/Sabre/DAV/Property/Response.php | 157 +++++++++++++++++++++ .../dav/lib/Sabre/DAV/Property/ResponseList.php | 59 ++++++++ .../dav/lib/Sabre/DAV/Property/SupportedLock.php | 78 ++++++++++ .../lib/Sabre/DAV/Property/SupportedReportSet.php | 111 +++++++++++++++ 10 files changed, 943 insertions(+) create mode 100644 vendor/sabre/dav/lib/Sabre/DAV/Property/GetLastModified.php create mode 100644 vendor/sabre/dav/lib/Sabre/DAV/Property/Href.php create mode 100644 vendor/sabre/dav/lib/Sabre/DAV/Property/HrefList.php create mode 100644 vendor/sabre/dav/lib/Sabre/DAV/Property/IHref.php create mode 100644 vendor/sabre/dav/lib/Sabre/DAV/Property/LockDiscovery.php create mode 100644 vendor/sabre/dav/lib/Sabre/DAV/Property/ResourceType.php create mode 100644 vendor/sabre/dav/lib/Sabre/DAV/Property/Response.php create mode 100644 vendor/sabre/dav/lib/Sabre/DAV/Property/ResponseList.php create mode 100644 vendor/sabre/dav/lib/Sabre/DAV/Property/SupportedLock.php create mode 100644 vendor/sabre/dav/lib/Sabre/DAV/Property/SupportedReportSet.php (limited to 'vendor/sabre/dav/lib/Sabre/DAV/Property') diff --git a/vendor/sabre/dav/lib/Sabre/DAV/Property/GetLastModified.php b/vendor/sabre/dav/lib/Sabre/DAV/Property/GetLastModified.php new file mode 100644 index 000000000..9240f55cc --- /dev/null +++ b/vendor/sabre/dav/lib/Sabre/DAV/Property/GetLastModified.php @@ -0,0 +1,78 @@ +time = $time; + } elseif (is_int($time) || ctype_digit($time)) { + $this->time = new \DateTime('@' . $time); + } else { + $this->time = new \DateTime($time); + } + + // Setting timezone to UTC + $this->time->setTimezone(new \DateTimeZone('UTC')); + + } + + /** + * serialize + * + * @param DAV\Server $server + * @param \DOMElement $prop + * @return void + */ + public function serialize(DAV\Server $server, \DOMElement $prop) { + + $doc = $prop->ownerDocument; + //$prop->setAttribute('xmlns:b','urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/'); + //$prop->setAttribute('b:dt','dateTime.rfc1123'); + $prop->nodeValue = HTTP\Util::toHTTPDate($this->time); + + } + + /** + * getTime + * + * @return \DateTime + */ + public function getTime() { + + return $this->time; + + } + +} + diff --git a/vendor/sabre/dav/lib/Sabre/DAV/Property/Href.php b/vendor/sabre/dav/lib/Sabre/DAV/Property/Href.php new file mode 100644 index 000000000..ac198c723 --- /dev/null +++ b/vendor/sabre/dav/lib/Sabre/DAV/Property/Href.php @@ -0,0 +1,99 @@ +href = $href; + $this->autoPrefix = $autoPrefix; + + } + + /** + * Returns the uri + * + * @return string + */ + public function getHref() { + + return $this->href; + + } + + /** + * Serializes this property. + * + * It will additionally prepend the href property with the server's base uri. + * + * @param DAV\Server $server + * @param \DOMElement $dom + * @return void + */ + public function serialize(DAV\Server $server, \DOMElement $dom) { + + $prefix = $server->xmlNamespaces['DAV:']; + $elem = $dom->ownerDocument->createElement($prefix . ':href'); + + if ($this->autoPrefix) { + $value = $server->getBaseUri() . DAV\URLUtil::encodePath($this->href); + } else { + $value = $this->href; + } + $elem->appendChild($dom->ownerDocument->createTextNode($value)); + + $dom->appendChild($elem); + + } + + /** + * Unserializes this property from a DOM Element + * + * This method returns an instance of this class. + * It will only decode {DAV:}href values. For non-compatible elements null will be returned. + * + * @param \DOMElement $dom + * @return DAV\Property\Href + */ + static function unserialize(\DOMElement $dom) { + + if ($dom->firstChild && DAV\XMLUtil::toClarkNotation($dom->firstChild)==='{DAV:}href') { + return new self($dom->firstChild->textContent,false); + } + + } + +} diff --git a/vendor/sabre/dav/lib/Sabre/DAV/Property/HrefList.php b/vendor/sabre/dav/lib/Sabre/DAV/Property/HrefList.php new file mode 100644 index 000000000..3eab755ca --- /dev/null +++ b/vendor/sabre/dav/lib/Sabre/DAV/Property/HrefList.php @@ -0,0 +1,105 @@ +hrefs = $hrefs; + $this->autoPrefix = $autoPrefix; + + } + + /** + * Returns the uris + * + * @return array + */ + public function getHrefs() { + + return $this->hrefs; + + } + + /** + * Serializes this property. + * + * It will additionally prepend the href property with the server's base uri. + * + * @param DAV\Server $server + * @param \DOMElement $dom + * @return void + */ + public function serialize(DAV\Server $server,\DOMElement $dom) { + + $prefix = $server->xmlNamespaces['DAV:']; + + foreach($this->hrefs as $href) { + + $elem = $dom->ownerDocument->createElement($prefix . ':href'); + if ($this->autoPrefix) { + $value = $server->getBaseUri() . DAV\URLUtil::encodePath($href); + } else { + $value = $href; + } + $elem->appendChild($dom->ownerDocument->createTextNode($value)); + + $dom->appendChild($elem); + } + + } + + /** + * Unserializes this property from a DOM Element + * + * This method returns an instance of this class. + * It will only decode {DAV:}href values. + * + * @param \DOMElement $dom + * @return DAV\Property\HrefList + */ + static function unserialize(\DOMElement $dom) { + + $hrefs = array(); + foreach($dom->childNodes as $child) { + if (DAV\XMLUtil::toClarkNotation($child)==='{DAV:}href') { + $hrefs[] = $child->textContent; + } + } + return new self($hrefs, false); + + } + +} diff --git a/vendor/sabre/dav/lib/Sabre/DAV/Property/IHref.php b/vendor/sabre/dav/lib/Sabre/DAV/Property/IHref.php new file mode 100644 index 000000000..a4ae09b3f --- /dev/null +++ b/vendor/sabre/dav/lib/Sabre/DAV/Property/IHref.php @@ -0,0 +1,25 @@ +locks = $locks; + $this->revealLockToken = $revealLockToken; + + } + + /** + * serialize + * + * @param DAV\Server $server + * @param \DOMElement $prop + * @return void + */ + public function serialize(DAV\Server $server, \DOMElement $prop) { + + $doc = $prop->ownerDocument; + + foreach($this->locks as $lock) { + + $activeLock = $doc->createElementNS('DAV:','d:activelock'); + $prop->appendChild($activeLock); + + $lockScope = $doc->createElementNS('DAV:','d:lockscope'); + $activeLock->appendChild($lockScope); + + $lockScope->appendChild($doc->createElementNS('DAV:','d:' . ($lock->scope==DAV\Locks\LockInfo::EXCLUSIVE?'exclusive':'shared'))); + + $lockType = $doc->createElementNS('DAV:','d:locktype'); + $activeLock->appendChild($lockType); + + $lockType->appendChild($doc->createElementNS('DAV:','d:write')); + + /* {DAV:}lockroot */ + if (!self::$hideLockRoot) { + $lockRoot = $doc->createElementNS('DAV:','d:lockroot'); + $activeLock->appendChild($lockRoot); + $href = $doc->createElementNS('DAV:','d:href'); + $href->appendChild($doc->createTextNode($server->getBaseUri() . $lock->uri)); + $lockRoot->appendChild($href); + } + + $activeLock->appendChild($doc->createElementNS('DAV:','d:depth',($lock->depth == DAV\Server::DEPTH_INFINITY?'infinity':$lock->depth))); + $activeLock->appendChild($doc->createElementNS('DAV:','d:timeout','Second-' . $lock->timeout)); + + if ($this->revealLockToken) { + $lockToken = $doc->createElementNS('DAV:','d:locktoken'); + $activeLock->appendChild($lockToken); + $lockToken->appendChild($doc->createElementNS('DAV:','d:href','opaquelocktoken:' . $lock->token)); + } + + $activeLock->appendChild($doc->createElementNS('DAV:','d:owner',$lock->owner)); + + } + + } + +} + diff --git a/vendor/sabre/dav/lib/Sabre/DAV/Property/ResourceType.php b/vendor/sabre/dav/lib/Sabre/DAV/Property/ResourceType.php new file mode 100644 index 000000000..9582d5598 --- /dev/null +++ b/vendor/sabre/dav/lib/Sabre/DAV/Property/ResourceType.php @@ -0,0 +1,127 @@ +resourceType = array(); + elseif ($resourceType === DAV\Server::NODE_DIRECTORY) + $this->resourceType = array('{DAV:}collection'); + elseif (is_array($resourceType)) + $this->resourceType = $resourceType; + else + $this->resourceType = array($resourceType); + + } + + /** + * serialize + * + * @param DAV\Server $server + * @param \DOMElement $prop + * @return void + */ + public function serialize(DAV\Server $server, \DOMElement $prop) { + + $propName = null; + $rt = $this->resourceType; + + foreach($rt as $resourceType) { + if (preg_match('/^{([^}]*)}(.*)$/',$resourceType,$propName)) { + + if (isset($server->xmlNamespaces[$propName[1]])) { + $prop->appendChild($prop->ownerDocument->createElement($server->xmlNamespaces[$propName[1]] . ':' . $propName[2])); + } else { + $prop->appendChild($prop->ownerDocument->createElementNS($propName[1],'custom:' . $propName[2])); + } + + } + } + + } + + /** + * Returns the values in clark-notation + * + * For example array('{DAV:}collection') + * + * @return array + */ + public function getValue() { + + return $this->resourceType; + + } + + /** + * Checks if the principal contains a certain value + * + * @param string $type + * @return bool + */ + public function is($type) { + + return in_array($type, $this->resourceType); + + } + + /** + * Adds a resourcetype value to this property + * + * @param string $type + * @return void + */ + public function add($type) { + + $this->resourceType[] = $type; + $this->resourceType = array_unique($this->resourceType); + + } + + /** + * Unserializes a DOM element into a ResourceType property. + * + * @param \DOMElement $dom + * @return DAV\Property\ResourceType + */ + static public function unserialize(\DOMElement $dom) { + + $value = array(); + foreach($dom->childNodes as $child) { + + $value[] = DAV\XMLUtil::toClarkNotation($child); + + } + + return new self($value); + + } + +} diff --git a/vendor/sabre/dav/lib/Sabre/DAV/Property/Response.php b/vendor/sabre/dav/lib/Sabre/DAV/Property/Response.php new file mode 100644 index 000000000..58e90d89d --- /dev/null +++ b/vendor/sabre/dav/lib/Sabre/DAV/Property/Response.php @@ -0,0 +1,157 @@ +href = $href; + $this->responseProperties = $responseProperties; + + } + + /** + * Returns the url + * + * @return string + */ + public function getHref() { + + return $this->href; + + } + + /** + * Returns the property list + * + * @return array + */ + public function getResponseProperties() { + + return $this->responseProperties; + + } + + /** + * serialize + * + * @param DAV\Server $server + * @param \DOMElement $dom + * @return void + */ + public function serialize(DAV\Server $server, \DOMElement $dom) { + + $document = $dom->ownerDocument; + $properties = $this->responseProperties; + + $xresponse = $document->createElement('d:response'); + $dom->appendChild($xresponse); + + $uri = DAV\URLUtil::encodePath($this->href); + + // Adding the baseurl to the beginning of the url + $uri = $server->getBaseUri() . $uri; + + $xresponse->appendChild($document->createElement('d:href',$uri)); + + // The properties variable is an array containing properties, grouped by + // HTTP status + foreach($properties as $httpStatus=>$propertyGroup) { + + // The 'href' is also in this array, and it's special cased. + // We will ignore it + if ($httpStatus=='href') continue; + + // If there are no properties in this group, we can also just carry on + if (!count($propertyGroup)) continue; + + $xpropstat = $document->createElement('d:propstat'); + $xresponse->appendChild($xpropstat); + + $xprop = $document->createElement('d:prop'); + $xpropstat->appendChild($xprop); + + $nsList = $server->xmlNamespaces; + + foreach($propertyGroup as $propertyName=>$propertyValue) { + + $propName = null; + preg_match('/^{([^}]*)}(.*)$/',$propertyName,$propName); + + // special case for empty namespaces + if ($propName[1]=='') { + + $currentProperty = $document->createElement($propName[2]); + $xprop->appendChild($currentProperty); + $currentProperty->setAttribute('xmlns',''); + + } else { + + if (!isset($nsList[$propName[1]])) { + $nsList[$propName[1]] = 'x' . count($nsList); + } + + // If the namespace was defined in the top-level xml namespaces, it means + // there was already a namespace declaration, and we don't have to worry about it. + if (isset($server->xmlNamespaces[$propName[1]])) { + $currentProperty = $document->createElement($nsList[$propName[1]] . ':' . $propName[2]); + } else { + $currentProperty = $document->createElementNS($propName[1],$nsList[$propName[1]].':' . $propName[2]); + } + $xprop->appendChild($currentProperty); + + } + + if (is_scalar($propertyValue)) { + $text = $document->createTextNode($propertyValue); + $currentProperty->appendChild($text); + } elseif ($propertyValue instanceof DAV\PropertyInterface) { + $propertyValue->serialize($server,$currentProperty); + } elseif (!is_null($propertyValue)) { + throw new DAV\Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName); + } + + } + + $xpropstat->appendChild($document->createElement('d:status',$server->httpResponse->getStatusMessage($httpStatus))); + + } + + } + +} diff --git a/vendor/sabre/dav/lib/Sabre/DAV/Property/ResponseList.php b/vendor/sabre/dav/lib/Sabre/DAV/Property/ResponseList.php new file mode 100644 index 000000000..b605a4e9a --- /dev/null +++ b/vendor/sabre/dav/lib/Sabre/DAV/Property/ResponseList.php @@ -0,0 +1,59 @@ +responses = $responses; + + } + + /** + * serialize + * + * @param DAV\Server $server + * @param \DOMElement $dom + * @return void + */ + public function serialize(DAV\Server $server,\DOMElement $dom) { + + foreach($this->responses as $response) { + $response->serialize($server, $dom); + } + + } + +} diff --git a/vendor/sabre/dav/lib/Sabre/DAV/Property/SupportedLock.php b/vendor/sabre/dav/lib/Sabre/DAV/Property/SupportedLock.php new file mode 100644 index 000000000..e6f477c38 --- /dev/null +++ b/vendor/sabre/dav/lib/Sabre/DAV/Property/SupportedLock.php @@ -0,0 +1,78 @@ +supportsLocks = $supportsLocks; + + } + + /** + * serialize + * + * @param DAV\Server $server + * @param \DOMElement $prop + * @return void + */ + public function serialize(DAV\Server $server,\DOMElement $prop) { + + $doc = $prop->ownerDocument; + + if (!$this->supportsLocks) return null; + + $lockEntry1 = $doc->createElement('d:lockentry'); + $lockEntry2 = $doc->createElement('d:lockentry'); + + $prop->appendChild($lockEntry1); + $prop->appendChild($lockEntry2); + + $lockScope1 = $doc->createElement('d:lockscope'); + $lockScope2 = $doc->createElement('d:lockscope'); + $lockType1 = $doc->createElement('d:locktype'); + $lockType2 = $doc->createElement('d:locktype'); + + $lockEntry1->appendChild($lockScope1); + $lockEntry1->appendChild($lockType1); + $lockEntry2->appendChild($lockScope2); + $lockEntry2->appendChild($lockType2); + + $lockScope1->appendChild($doc->createElement('d:exclusive')); + $lockScope2->appendChild($doc->createElement('d:shared')); + + $lockType1->appendChild($doc->createElement('d:write')); + $lockType2->appendChild($doc->createElement('d:write')); + + //$frag->appendXML(''); + //$frag->appendXML(''); + + } + +} + diff --git a/vendor/sabre/dav/lib/Sabre/DAV/Property/SupportedReportSet.php b/vendor/sabre/dav/lib/Sabre/DAV/Property/SupportedReportSet.php new file mode 100644 index 000000000..993105b8a --- /dev/null +++ b/vendor/sabre/dav/lib/Sabre/DAV/Property/SupportedReportSet.php @@ -0,0 +1,111 @@ +addReport($reports); + + } + + /** + * Adds a report to this property + * + * The report must be a string in clark-notation. + * Multiple reports can be specified as an array. + * + * @param mixed $report + * @return void + */ + public function addReport($report) { + + if (!is_array($report)) $report = array($report); + + foreach($report as $r) { + + if (!preg_match('/^{([^}]*)}(.*)$/',$r)) + throw new DAV\Exception('Reportname must be in clark-notation'); + + $this->reports[] = $r; + + } + + } + + /** + * Returns the list of supported reports + * + * @return array + */ + public function getValue() { + + return $this->reports; + + } + + /** + * Serializes the node + * + * @param DAV\Server $server + * @param \DOMElement $prop + * @return void + */ + public function serialize(DAV\Server $server, \DOMElement $prop) { + + foreach($this->reports as $reportName) { + + $supportedReport = $prop->ownerDocument->createElement('d:supported-report'); + $prop->appendChild($supportedReport); + + $report = $prop->ownerDocument->createElement('d:report'); + $supportedReport->appendChild($report); + + preg_match('/^{([^}]*)}(.*)$/',$reportName,$matches); + + list(, $namespace, $element) = $matches; + + $prefix = isset($server->xmlNamespaces[$namespace])?$server->xmlNamespaces[$namespace]:null; + + if ($prefix) { + $report->appendChild($prop->ownerDocument->createElement($prefix . ':' . $element)); + } else { + $report->appendChild($prop->ownerDocument->createElementNS($namespace, 'x:' . $element)); + } + + } + + } + +} -- cgit v1.2.3