mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-07 00:48:55 +00:00
Set notifications of events; the actual notification routine is not yet implemented
This commit is contained in:
parent
62ec9bfa69
commit
8196f9b900
26 changed files with 324 additions and 212 deletions
|
@ -20,9 +20,6 @@ class Sabre_DAV_XMLUtil {
|
|||
* {http://www.example.org}myelem
|
||||
*
|
||||
* This format is used throughout the SabreDAV sourcecode.
|
||||
* Elements encoded with the urn:DAV namespace will
|
||||
* be returned as if they were in the DAV: namespace. This is to avoid
|
||||
* compatibility problems.
|
||||
*
|
||||
* This function will return null if a nodetype other than an Element is passed.
|
||||
*
|
||||
|
@ -33,8 +30,7 @@ class Sabre_DAV_XMLUtil {
|
|||
|
||||
if ($dom->nodeType !== XML_ELEMENT_NODE) return null;
|
||||
|
||||
// Mapping back to the real namespace, in case it was dav
|
||||
if ($dom->namespaceURI=='urn:DAV') $ns = 'DAV:'; else $ns = $dom->namespaceURI;
|
||||
$ns = $dom->namespaceURI;
|
||||
|
||||
// Mapping to clark notation
|
||||
return '{' . $ns . '}' . $dom->localName;
|
||||
|
@ -64,29 +60,11 @@ class Sabre_DAV_XMLUtil {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method takes an XML document (as string) and converts all instances of the
|
||||
* DAV: namespace to urn:DAV
|
||||
*
|
||||
* This is unfortunately needed, because the DAV: namespace violates the xml namespaces
|
||||
* spec, and causes the DOM to throw errors
|
||||
*
|
||||
* @param string $xmlDocument
|
||||
* @return array|string|null
|
||||
*/
|
||||
static function convertDAVNamespace($xmlDocument) {
|
||||
|
||||
// This is used to map the DAV: namespace to urn:DAV. This is needed, because the DAV:
|
||||
// namespace is actually a violation of the XML namespaces specification, and will cause errors
|
||||
return preg_replace("/xmlns(:[A-Za-z0-9_]*)?=(\"|\')DAV:(\\2)/","xmlns\\1=\\2urn:DAV\\2",$xmlDocument);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides a generic way to load a DOMDocument for WebDAV use.
|
||||
*
|
||||
* This method throws a Sabre_DAV_Exception_BadRequest exception for any xml errors.
|
||||
* It does not preserve whitespace, and it converts the DAV: namespace to urn:DAV.
|
||||
* It does not preserve whitespace.
|
||||
*
|
||||
* @param string $xml
|
||||
* @throws Sabre_DAV_Exception_BadRequest
|
||||
|
@ -118,10 +96,11 @@ class Sabre_DAV_XMLUtil {
|
|||
libxml_clear_errors();
|
||||
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML(self::convertDAVNamespace($xml),LIBXML_NOWARNING | LIBXML_NOERROR);
|
||||
|
||||
// We don't generally care about any whitespace
|
||||
$dom->preserveWhiteSpace = false;
|
||||
|
||||
$dom->loadXML($xml,LIBXML_NOWARNING | LIBXML_NOERROR);
|
||||
|
||||
if ($error = libxml_get_last_error()) {
|
||||
libxml_clear_errors();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue