Author: ts
Date: Fri Sep 28 14:22:28 2007
New Revision: 6317
Log:
- Refactoring: Extracted property related behaviour to new
ezcWebdavPropertyHandler class.
# This is sensible because property serialization might be useful in the file
# backend, too. Beside that, size of ezcWebdavTransport must be drastically
# reduced.
Added:
trunk/Webdav/src/transports/property_handler.php (with props)
trunk/Webdav/src/transports/property_handlers/
Modified:
trunk/Webdav/design/class_diagram.png
trunk/Webdav/src/transport.php
trunk/Webdav/src/webdav_autoload.php
Modified: trunk/Webdav/design/class_diagram.png
==============================================================================
Binary files - no diff available.
Modified: trunk/Webdav/src/transport.php
==============================================================================
--- trunk/Webdav/src/transport.php [iso-8859-1] (original)
+++ trunk/Webdav/src/transport.php [iso-8859-1] Fri Sep 28 14:22:28 2007
@@ -102,10 +102,28 @@
* @param ezcWebdavTransportOptions $options
* @return void
*/
- public function __construct( ezcWebdavXmlTool $xml = null,
ezcWebdavTransportOptions $options = null )
- {
- $this->properties['xml'] = ( $xml === null ? new
ezcWebdavXmlTool() : $xml );
- $this->properties['options'] = ( $options === null ? new
ezcWebdavTransportOptions() : $options );
+ public function __construct(
+ ezcWebdavXmlTool $xml = null,
+ ezcWebdavPropertyHandler $propertyHandler = null,
+ ezcWebdavTransportOptions $options = null
+ )
+ {
+ $this->properties['xml'] = null;
+ $this->properties['propertyHandler'] = null;
+ $this->properties['options'] = null;
+
+ $this->xml = ( $xml === null
+ ? new ezcWebdavXmlTool()
+ : $xml
+ );
+ $this->propertyHandler = ( $propertyHandler === null
+ ? new ezcWebdavPropertyHandler( $this->xml )
+ : $propertyHandler
+ );
+ $this->options = ( $options === null
+ ? new ezcWebdavTransportOptions()
+ : $options
+ );
}
/**
@@ -227,25 +245,30 @@
* This method is called to finally send the response to the browser. It
* can be overwritten in test cases to change the behaviour of printing out
* the result and sending the headers. The method automatically generates
an
- * appropriate Content-Type header for XML output, if a DOMDocument is
received in
- * ezcWebdavDisplayInformation. A header existent in the response object
- * will not be affected and the method will silently go on.
- *
- * If the [EMAIL PROTECTED] ezcWebdavDisplayInformation::$body} property
is a string,
+ * appropriate Content-Type header for XML output, if an
+ * [EMAIL PROTECTED] ezcWebdavXmlDisplayInformation} is received. A header
existent in the
+ * response object will not be affected and the method will silently go on.
+ *
+ * If an [EMAIL PROTECTED] ezcWebdavStringDisplayInformation} is submitted
* correct setting of the Content-Type header is checked and an [EMAIL
PROTECTED]
- * ezcWebdavMissingHeaderException} is thrown in negative case [EMAIL
PROTECTED]
* ezcWebdavMissingHeaderException} is thrown in negative case.
*
- * If a null body is received, the method checks if Content-Type and
- * Content-Length headers are not present, so they are not excplicitly send
- * later on.
+ * If an [EMAIL PROTECTED] ezcWebdavEmptyDisplayInformation} is received,
the method
+ * checks if Content-Type and Content-Length headers are not present, so
+ * they are not excplicitly send later on.
*
* @param ezcWebdavDisplayInformation $info
* @return void
*
- * @todo ezcWebdavDisplayInformation should be refactored to have
- * subclasses for the different content types (DOMDOcument, null,
- * string).
+ * @throws ezcWebdavMissingHeaderException
+ * if the submitted $info parameter is an [EMAIL PROTECTED]
+ * ezcWebdavStringDisplayInformation} struct and the contained
+ * [EMAIL PROTECTED] ezcWebdavResponse} object has no Content-Type
header set.
+ * @throws ezcWebdavInvalidHeaderException
+ * if the submitted $info parameter is an [EMAIL PROTECTED]
+ * ezcWebdavEmptyDisplayInformation} and the contained [EMAIL
PROTECTED]
+ * ezcWebdavResponse} object has a Content-Type or a Content-Length
+ * header set.
*/
protected function sendResponse( ezcWebdavDisplayInformation $info )
{
@@ -775,7 +798,7 @@
break;
case 'prop':
$request->prop = new ezcWebdavBasicPropertyStorage();
- $this->extractProperties(
+ $this->propertyHandler->extractProperties(
$dom->documentElement->firstChild->childNodes,
$request->prop
);
@@ -789,319 +812,6 @@
return $request;
}
-
- /**
- * Returns extracted properties in an new ezcWebdavBasicPropertyStorage.
- * This method receives a DOMNodeList $domNodes, which must contain a set
- * of DOMElement objects, while each of those represents a WebDAV property.
- * The list may contain live properties as well as dead ones. Live
- * properties as defined in RFC 2518 are currently recognized. All other
- * properties in the DAV: namespace are silently ignored. Dead properties
- * are parsed. The properties are stored in the given [EMAIL PROTECTED]
- * new ezcWebdavBasicPropertyStorage} $storage. If a $flag value is
provided, this
- * one is submitted as the second parameter to
- * new ezcWebdavBasicPropertyStorage->attach() ([EMAIL PROTECTED]
- * ezcWebdavFlaggedPropertyStorage}).
- *
- * @param DOMNodeList $domNodes
- * @param new ezcWebdavBasicPropertyStorage $storage
- * @param int $flag
- * @return new ezcWebdavBasicPropertyStorage
- */
- protected function extractProperties( DOMNodeList $domNodes,
ezcWebdavBasicPropertyStorage $storage, $flag = null )
- {
- for ( $i = 0; $i < $domNodes->length; ++$i )
- {
- $currentNode = $domNodes->item( $i );
- if ( $currentNode->nodeType !== XML_ELEMENT_NODE )
- {
- // Skip
- continue;
- }
-
- // DAV: namespace indicates live property!
- // Other RFCs allready intruded into this namespace, as 3253 does.
- if ( $currentNode->namespaceURI ===
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE )
- {
- $property = $this->extractLiveProperty( $currentNode );
- // In case we don't know the property, we currently ignore it!
- if ( $property !== null )
- {
- $flag === null ? $storage->attach( $property ) :
$storage->attach( $property, $flag );
- }
- }
-
- // Other namespaces are always dead properties
- else
- {
- $property = $this->extractDeadProperty( $currentNode );
- $flag === null ? $storage->attach( $property ) :
$storage->attach( $property, $flag );
- }
- }
- return $storage;
- }
-
- /**
- * Extract a dead property from a DOMElement.
- * This method is responsible for parsing a [EMAIL PROTECTED]
ezcWebdavDeadProperty}
- * (unknown) property from a DOMElement.
- *
- * @param DOMElement $domElement
- * @return ezcWebdavDeadProperty
- * @todo How do we need to take care about different namespaces here?
- */
- protected function extractDeadProperty( DOMElement $domElement )
- {
- // Create standalone XML for property
- // It may possibly occur, that shortcut clashes occur...
- $propDom = new DOMDocument();
- $copiedNode = $propDom->importNode( $domElement, true );
- $propDom->appendChild( $copiedNode );
-
- return new ezcWebdavDeadProperty(
- $domElement->namespaceURI,
- $domElement->localName,
- $propDom->saveXML()
- );
- }
-
- /**
- * Extracts a live property from a DOMElement.
- * This method is responsible for parsing WebDAV live properties. The
- * DOMElement $domElement must be an XML element in the DAV: namepsace. If
- * the received property is not defined in RFC 2518, null is returned.
- *
- * @param DOMElement $domElement
- * @return ezcWebdavLiveProperty|null
- */
- protected function extractLiveProperty( DOMElement $domElement )
- {
- switch ( $domElement->localName )
- {
- case 'creationdate':
- $property = new ezcWebdavCreationDateProperty();
- if ( empty( $domElement->nodeValue ) === false )
- {
- $property->date = new ezcWebdavDateTime(
$domElement->nodeValue );
- }
- break;
- case 'displayname':
- $property = new ezcWebdavDisplayNameProperty();
- if ( empty( $domElement->nodeValue ) === false )
- {
- $property->displayName = $domElement->nodeValue;
- }
- break;
- case 'getcontentlanguage':
- $property = new ezcWebdavGetContentLanguageProperty();
- if ( empty( $domElement->nodeValue ) === false )
- {
- // e.g. 'de, en'
- $property->displayName = array_map( 'trim', explode( ',',
$domElement->nodeValue ) );
- }
- break;
- case 'getcontentlength':
- $property = new ezcWebdavGetContentLengthProperty();
- if ( empty( $domElement->nodeValue ) === false )
- {
- $property->length = trim( $domElement->nodeValue );
- }
- break;
- case 'getcontenttype':
- $property = new ezcWebdavGetContentTypeProperty();
- // @TODO: Should this throw an exception, if the match fails?
- // Currently, the property stays empty and the backend needs
to handle this
- if ( empty( $domElement->nodeValue ) === false
- && preg_match( self::GETCONTENTTYPE_REGEX,
$domElement->nodeValue, $matches ) > 0 )
- {
- $property->mime = $matches['mime'];
- $property->charset = $matches['charset'];
- }
- break;
- case 'getetag':
- $property = new ezcWebdavGetEtagProperty();
- if ( empty( $domElement->nodeValue ) === false )
- {
- $property->etag = $domElement->nodeValue;
- }
- break;
- case 'getlastmodified':
- $property = new ezcWebdavGetLastModifiedProperty();
- if ( empty( $domElement->nodeValue ) === false )
- {
- $property->date = new ezcWebdavDateTime(
$domElement->nodeValue );
- }
- break;
- case 'lockdiscovery':
- $property = new ezcWebdavLockDiscoveryProperty();
- if ( $domElement->hasChildNodes() === true )
- {
- $property->activeLock = $this->extractActiveLockContent(
$domElement );
- }
- break;
- case 'resourcetype':
- $property = new ezcWebdavResourceTypeProperty();
- if ( empty( $domElement->nodeValue ) === false )
- {
- $property->type = $domElement->nodeValue;
- }
- break;
- case 'source':
- $property = new ezcWebdavSourceProperty();
- if ( $domElement->hasChildNodes() === true )
- {
- $property->links = $this->extractLinkContent( $domElement
);
- }
- break;
- case 'supportedlock':
- $property = new ezcWebdavSupportedLockProperty();
- if ( $domElement->hasChildNodes() === true )
- {
- $property->links = $this->extractLockEntryContent(
$domElement );
- }
- break;
- default:
- // @TODO Implement extension plugins
- // Currently just ignore
- $property = $this->extractDeadProperty( $domElement );
- }
- return $property;
- }
-
- /**
- * Extracts the <activelock /> XML elements.
- * This method extracts the <activelock /> XML elements from the
- * <lockdiscovery /> element and returns the corresponding
- * ezcWebdavLockDiscoveryPropertyActiveLock object to be used as the
- * content of ezcWebdavLockDiscoveryProperty.
- *
- * @param DOMElement $domElement
- * @return ezcWebdavLockDiscoveryPropertyActiveLock
- */
- protected function extractActiveLockContent( DOMElement $domElement )
- {
- $activeLock = new ezcWebdavLockDiscoveryPropertyActiveLock();
-
- $activelockElement = $domElement->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'activelock' )->item( 0 );
- for ( $i = 0; $i < $activelockElement->childNodes->length; ++$i )
- {
- if ( ( ( $currentElement = $activelockElement->childNodes->item(
$i ) ) instanceof DOMElement ) === false )
- {
- // Skip non element children
- continue;
- }
- switch ( $currentElement->localName )
- {
- case 'locktype':
- if ( $currentElement->hasChildren &&
$currentElement->firstChild->localName !== 'write' )
- {
- $activelock->lockType =
ezcWebdavLockRequest::TYPE_READ;
- }
- else
- {
- $activelock->lockType =
ezcWebdavLockRequest::TYPE_WRITE;
- }
- break;
- case 'lockscope':
- if ( $currentElement->hasChildren )
- {
- switch ( $currentElement->firstChild->localName )
- {
- case 'exclusive':
- $activelock->lockScope =
ezcWebdavLockRequest::SCOPE_EXCLUSIVE;
- break;
- case 'shared':
- $activelock->lockScope =
ezcWebdavLockRequest::SCOPE_SHARED;
- break;
- }
- }
- break;
- case 'depth':
- switch ( trim( $currentElement->nodeValue ) )
- {
- case '0':
- $activelock->depth = ezcWebdavRequest::DEPTH_ZERO;
- break;
- case '1':
- $activelock->depth = ezcWebdavRequest::DEPTH_ONE;
- break;
- case 'infinity':
- $activelock->depth =
ezcWebdavRequest::DEPTH_INFINITY;
- break;
- }
- break;
- case 'owner':
- // Ignore <href /> element by intention!
- $activelock->owner = $currentElement->textContent;
- break;
- case 'timeout':
- // @TODO Need to check for special values here!
- $activelock->timeout = new ezcWebdavDateTime(
$currentElement->nodeValue );
- break;
- case 'locktoken':
- for ( $i = 0; $i < $currentElement->childNodes->length;
++$i )
- {
- $activelock->tokens[] = trim(
$currentElement->childNodes->item( $i )->textContent );
- }
- break;
- }
- }
- return $activelock;
- }
-
- /**
- * Extracts the <link /> XML elements.
- * This method extracts the <link /> XML elements from the <source />
- * element and returns the corresponding ezcWebdavSourcePropertyLink object
- * to be used as the content of ezcWebdavSourceProperty.
- *
- * @param DOMElement $domElement
- * @return ezcWebdavSourcePropertyLink
- */
- protected function extractLinkContent( DOMElement $domElement )
- {
- $links = array();
-
- $linkElements = $domElement->getElementsByTagNameNS(
- ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'link'
- );
- for ( $i = 0; $i < $linkElements->length; ++$i )
- {
- $links[] = new ezcWebdavSourcePropertyLink(
- $linkElements->item( $i )->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'src' )->nodeValue,
- $linkElements->item( $i )->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'dst' )->nodeValue
- );
- }
- return $links;
- }
-
- /**
- * Extracts the <lockentry /> XML elements.
- * This method extracts the <lockentry /> XML elements from the
<supportedlock />
- * element and returns the corresponding
- * ezcWebdavSupportedLockPropertyLockentry object to be used as the content
- * of ezcWebdavSupportedLockProperty.
- *
- * @param DOMElement $domElement
- * @return ezcWebdavSupportedLockProperty
- */
- protected function extractLockEntryContent( DOMElement $domElement )
- {
- $lockEntries = array();
-
- $lockEntryElements = $domElement->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'lockentry' );
- for ( $i = 0; $i < $lockEntryElements->length; ++$i )
- {
- $lockEntries[] = new ezcWebdavSupportedLockPropertyLockentry(
- ( $lockEntryElements->item( $i )->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'locktype' )->item( 0 )->localname ===
'write'
- ? ezcWebdavLockRequest::TYPE_WRITE :
ezcWebdavLockRequest::TYPE_READ ),
- ( $lockEntryElements->item( $i )->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'lockscope' )->item( 0 )->localname
=== 'shared'
- ? ezcWebdavLockRequest::SCOPE_SHARED :
ezcWebdavLockRequest::SCOPE_EXCLUSIVE )
- );
- }
- return $lockEntries;
- }
-
// PROPPATCH
/**
@@ -1140,7 +850,7 @@
for ( $i = 0; $i < $setElements->length; ++$i )
{
- $this->extractProperties(
+ $this->propertyHandler->extractProperties(
$setElements->item( $i )->firstChild->childNodes,
$request->updates,
ezcWebdavPropPatchRequest::SET
@@ -1149,7 +859,7 @@
for ( $i = 0; $i < $removeElements->length; ++$i )
{
- $this->extractProperties(
+ $this->propertyHandler->extractProperties(
$removeElements->item( $i )->firstChild->childNodes,
$request->updates,
ezcWebdavPropPatchRequest::REMOVE
@@ -1391,7 +1101,7 @@
$this->xml->createDomElement( $dom, 'propstat' )
);
- $this->serializePropertyStorage(
+ $this->propertyHandler->serializeProperties(
$response->storage,
$propstatElement->appendChild( $this->xml->createDomElement( $dom,
'prop' ) )
);
@@ -1404,268 +1114,6 @@
)->nodeValue = (string) $response;
return new ezcWebdavXmlDisplayInformation( $response, $dom );
- }
-
- /**
- * Serializes an object of new ezcWebdavBasicPropertyStorage to XML.
- * Attaches all properties of the $storage to the $parentElement XML
- * element.
- *
- * @param new ezcWebdavPropertyStorage $storage
- * @param DOMElement $parentElement
- * @return void
- */
- protected function serializePropertyStorage( ezcWebdavPropertyStorage
$storage, DOMElement $parentElement )
- {
- foreach ( $storage as $property )
- {
- if ( $property instanceof ezcWebdavLiveProperty )
- {
- $this->serializeLiveProperty( $property, $parentElement );
- }
- else
- {
- $this->serializeDeadProperty( $property, $parentElement );
- }
- }
- }
-
- /**
- * Returns the XML representation of a dead property.
- * Returns a DOMElement, representing the content of the given $property.
- * The newly created element is also appended as a child to the given
- * $parentElement.
- *
- * @param ezcWebdavDeadProperty $property
- * @param DOMElement $parentElement
- * @return DOMElement
- */
- protected function serializeDeadProperty( ezcWebdavDeadProperty $property,
DOMElement $parentElement )
- {
- if ( $property->content === null || ( $contentDom =
$this->xml->createDomDocument( $property->content ) ) === false )
- {
- return $parentElement->appendChild(
- $this->xml->createDomElement(
- $parentElement->ownerDocument,
- $property->name,
- $property->namespace
- )
- );
- }
-
- return $parentElement->appendChild(
- $parentElement->ownerDocument->importNode(
$contentDom->documentElement, true )
- );
- }
-
- /**
- * Returns the XML representation of a live property.
- * Returns a DOMElement, representing the content of the given $property.
- * The newly created element is also appended as a child to the given
- * $parentElement.
- *
- * @param ezcWebdavLiveProperty $property
- * @param DOMElement $parentElement
- * @return DOMElement
- */
- protected function serializeLiveProperty( ezcWebdavLiveProperty $property,
DOMElement $parentElement )
- {
- switch ( get_class( $property ) )
- {
- case 'ezcWebdavCreationDateProperty':
- $elementName = 'creationdate';
- $elementValue = ( $property->date !== null ?
$property->date->format( DATE_ISO8601 ) : null );
- break;
- case 'ezcWebdavDisplayNameProperty':
- $elementName = 'displayname';
- $elementValue = $property->displayName;
- break;
- case 'ezcWebdavGetContentLanguageProperty':
- $elementName = 'getcontentlanguage';
- $elementValue = ( count( $property->languages ) > 0 ? implode(
', ', $property->languages ) : null );
- break;
- case 'ezcWebdavGetContentLengthProperty':
- $elementName = 'getcontentlength';
- $elementValue = $property->length;
- break;
- case 'ezcWebdavGetContentTypeProperty':
- $elementName = 'getcontenttype';
- $elementValue = ( $property->mime !== null ? $property->mime .
( $property->charset === null ? '' : '; charset="' . $property->charset . '"' )
: null );
- break;
- case 'ezcWebdavGetEtagProperty':
- $elementName = 'getetag';
- $elementValue = $property->etag;
- break;
- case 'ezcWebdavGetLastModifiedProperty':
- $elementName = 'getlastmodified';
- $elementValue = ( $property->date !== null ?
$property->date->format( DATE_RFC1123 ) : null );
- break;
- case 'ezcWebdavLockDiscoveryProperty':
- $elementName = 'lockdiscovery';
- $elementValue = ( $property->activeLock !== null ?
$this->serializeActiveLockContent( $property->activeLock,
$parentElement->ownerDocument ) : null );
- break;
- case 'ezcWebdavResourceTypeProperty':
- $elementName = 'resourcetype';
- $elementValue = ( $property->type ===
ezcWebdavResourceTypeProperty::TYPE_COLLECTION ? array(
$this->xml->createDomElement( $parentElement->ownerDocument, 'collection' ) ) :
null );
- break;
- case 'ezcWebdavSourceProperty':
- $elementName = 'source';
- $elementValue = ( $property->links !== null ?
$this->serializeLinkContent( $property->links, $parentElement->ownerDocument )
: null );
- break;
- case 'ezcWebdavSupportedLockProperty':
- $elementName = 'supportedlock';
- $elementValue = ( $property->lockEntry !== null ?
$this->serializeLockEntryContent( $property->lockEntry,
$parentElement->ownerDocument ) : null );
- break;
- }
-
- $propertyElement = $parentElement->appendChild(
- $this->xml->createDomElement( $parentElement->ownerDocument,
$elementName, $property->namespace )
- );
-
- if ( $elementValue instanceof DOMDocument )
- {
- $propertyElement->appendChild(
- $dom->importNode( $elementValue->documentElement, true )
- );
- }
- else if ( is_array( $elementValue ) )
- {
- foreach( $elementValue as $subValue )
- {
- $propertyElement->appendChild( $subValue );
- }
- }
- else if ( is_scalar( $elementValue ) )
- {
- $propertyElement->nodeValue = $elementValue;
- }
-
- return $propertyElement;
- }
-
- /**
- * Serializes an array of ezcWebdavLockDiscoveryPropertyActiveLock
elements to XML.
- *
- * @param array(ezcWebdavLockDiscoveryPropertyActiveLock) $links
- * @param DOMDocument $dom To create the returned DOMElements.
- * @return array(DOMElement)
- */
- protected function serializeActiveLockContent( array $activeLocks = null,
DOMDocument $dom )
- {
- $activeLockElements = array();
- foreach ( $activeLocks as $activeLock )
- {
- $activeLockElement = $this->xml->createDomElement( $dom,
'activelock' );
-
- $activeLockElement->appendChild(
- $this->xml->createDomElement( $dom, 'locktype' )
- )->appendChild(
- $this->xml->createDomElement( $dom, ( $activeLock->lockType
=== ezcWebdavLockRequest::TYPE_READ ? 'read' : 'write' ) )
- );
-
- $activeLockElement->appendChild(
- $this->xml->createDomElement( $dom, 'lockscope' )
- )->appendChild(
- $this->xml->createDomElement( $dom, ( $activeLock->lockScope
=== ezcWebdavLockRequest::SCOPE_EXCLUSIVE ? 'exclusive' : 'shared' ) )
- );
-
- $depthElement = $activeLockElement->appendChild(
- $this->xml->createDomElement( $dom, 'depth' )
- );
-
- switch ( $activeLock->depth )
- {
- case ezcWebdavRequest::DEPTH_ZERO:
- $depthElement->nodeValue = '0';
- break;
- case ezcWebdavRequest::DEPTH_ONE:
- $depthElement->nodeValue = '1';
- break;
- case ezcWebdavRequest::DEPTH_INFINITY:
- $depthElement->nodeValue = 'Infity';
- break;
- }
-
- if ( $activeLock->owner !== null )
- {
- $activeLockElement->appendChild(
- $this->xml->createDomElement( $dom, 'owner' )
- )->nodeValue = $activeLock->owner;
- }
-
- $activeLockElement->appendChild(
- $this->xml->createDomElement( $dom, 'timeout' )
- )->$activeLock->timeout;
-
- foreach ( $activeLock->tokens as $token )
- {
- $activeLockElement->appendChild(
- $this->xml->createDomElement( $dom, 'locktoken' )
- )->appendChild(
- $this->xml->createDomElement( $dom, 'href' )
- )->nodeValue = $token;
- }
-
- $activeLockElements[] = $lockElement;
- }
-
- return $activeLockElements;
- }
-
- /**
- * Serializes an array of ezcWebdavSourcePropertyLink elements to XML.
- *
- * @param array(ezcWebdavSourcePropertyLink) $links
- * @param DOMDocument $dom To create the returned DOMElements.
- * @return array(DOMElement)
- */
- protected function serializeLinkContent( array $links = null, DOMDocument
$dom )
- {
- $linkContentElements = array();
-
- foreach( $links as $link )
- {
- $linkElement = $this->xml->createDomElement( $dom, 'link' );
- $linkElement->appendChild(
- $this->xml->createDomElement( $dom, 'src' )
- )->nodeValue = $link->src;
- $linkElement->appendChild(
- $this->xml->createDomElement( $dom, 'dst' )
- )->nodeValue = $link->dst;
- $linkContentElements[] = $linkElement;
- }
-
- return $linkContentElements;
- }
-
- /**
- * Serializes an array of ezcWebdavSupportedLockPropertyLockentry elements
to XML.
- *
- * @param array(ezcWebdavSupportedLockPropertyLockentry) $lockEntries
- * @param DOMDocument $dom To create the returned DOMElements.
- * @return array(DOMElement)
- */
- protected function serializeLockEntryContent( array $lockEntries = null,
DOMDocument $dom )
- {
- $lockEntryContentElements = array();
-
- foreach( $lockEntries as $lockEntry )
- {
- $lockEntryElement = $this->xml->createDomElement( $dom,
'lockentry' );
- $lockEntryElement->appendChild(
- $this->xml->createDomElement( $dom, 'lockscope' )
- )->appendChild(
- $this->xml->createDomElement( $dom, ( $lockEntry->lockScope
=== ezcWebdavLockRequest::SCOPE_EXCLUSIVE ? 'exclusive' : 'shared' ) )
- );
- $lockEntryElement->appendChild(
- $this->xml->createDomElement( $dom, 'locktype' )
- )->appendChild(
- $this->xml->createDomElement( $dom, ( $lockEntry->lockScope
=== ezcWebdavLockRequest::TYPE_READ ? 'read' : 'write' ) )
- );
- $lockEntryContentElements[] = $lockEntryElement;
- }
-
- return $lockEntryContentElements;
}
/**
@@ -1716,6 +1164,12 @@
throw new ezcBaseValueException( $propertyName,
$propertyValue, 'ezcWebdavXmlTool' );
}
break;
+ case 'propertyHandler':
+ if ( ( $propertyValue instanceof ezcWebdavPropertyHandler )
=== false )
+ {
+ throw new ezcBaseValueException( $propertyName,
$propertyValue, 'ezcWebdavPropertyHandler' );
+ }
+ break;
default:
throw new ezcBasePropertyNotFoundException( $propertyName );
}
Added: trunk/Webdav/src/transports/property_handler.php
==============================================================================
--- trunk/Webdav/src/transports/property_handler.php (added)
+++ trunk/Webdav/src/transports/property_handler.php [iso-8859-1] Fri Sep 28
14:22:28 2007
@@ -1,0 +1,608 @@
+<?php
+
+class ezcWebdavPropertyHandler
+{
+ /**
+ * XML tool.
+ *
+ * @var ezcWebdavXmlTool
+ */
+ protected $xml;
+
+ /**
+ * Creates a new property handler.
+ *
+ * An instance of this class is capable of handling live and dead WebDAV
+ * properties. It can extract properties from requests and generate
+ * response information for properties.
+ *
+ * @param ezcWebdavXmlTool $xml
+ * @return void
+ */
+ public function __construct( ezcWebdavXmlTool $xml )
+ {
+ $this->xml = $xml;
+ }
+
+ /**
+ * Returns extracted properties in an ezcWebdavPropertyStorage.
+ *
+ * This method receives a DOMNodeList $domNodes which must contain a set
+ * of DOMElement objects, while each of those represents a WebDAV property.
+ *
+ * The list may contain live properties as well as dead ones. Live
+ * properties ([EMAIL PROTECTED] ezcWebdavLiveProperty}) as defined in RFC
2518 are
+ * currently recognized. All other properties in the DAV: namespace are
+ * added as dead properties ([EMAIL PROTECTED] ezcWebdavDeadProperty}).
Dead
+ * properties are parsed in general in any namespace.
+ *
+ * The properties are stored in the given [EMAIL PROTECTED]
ezcWebdavPropertyStorage}
+ * $storage. If a $flag value is provided, this one is submitted as the
+ * second parameter to [EMAIL PROTECTED]
ezcWebdavFlaggedPropertyStorage->attach()}.
+ *
+ * @param DOMNodeList $domNodes
+ * @param ezcWebdavPropertyStorage $storage
+ * @param int $flag
+ * @return ezcWebdavBasicPropertyStorage
+ */
+ public function extractProperties( DOMNodeList $domNodes,
ezcWebdavBasicPropertyStorage $storage, $flag = null )
+ {
+ for ( $i = 0; $i < $domNodes->length; ++$i )
+ {
+ $currentNode = $domNodes->item( $i );
+ if ( $currentNode->nodeType !== XML_ELEMENT_NODE )
+ {
+ // Skip
+ continue;
+ }
+
+ // DAV: namespace indicates live property! If parsing live fails,
a dead property is returned
+ if ( $currentNode->namespaceURI ===
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE )
+ {
+ $flag === null
+ ? $storage->attach( $this->extractLiveProperty(
$currentNode ) )
+ : $storage->attach( $this->extractLiveProperty(
$currentNode ), $flag );
+ }
+ // Other namespaces are always dead properties
+ else
+ {
+ $flag === null
+ ? $storage->attach( $this->extractDeadProperty(
$currentNode ) )
+ : $storage->attach( $this->extractDeadProperty(
$currentNode ), $flag );
+ }
+ }
+ return $storage;
+ }
+
+ /**
+ * Extract a dead property from a DOMElement.
+ *
+ * This method is responsible for parsing a [EMAIL PROTECTED]
ezcWebdavDeadProperty}
+ * (unknown) property from a DOMElement.
+ *
+ * @param DOMElement $domElement
+ * @return ezcWebdavDeadProperty
+ *
+ * @todo How do we need to take care about different namespaces here?
+ */
+ protected function extractDeadProperty( DOMElement $domElement )
+ {
+ // Create standalone XML for property
+ // It may possibly occur, that shortcut clashes occur...
+ $propDom = new DOMDocument();
+ $copiedNode = $propDom->importNode( $domElement, true );
+ $propDom->appendChild( $copiedNode );
+
+ return new ezcWebdavDeadProperty(
+ $domElement->namespaceURI,
+ $domElement->localName,
+ $propDom->saveXML()
+ );
+ }
+
+ /**
+ * Extracts a live property from a DOMElement.
+ *
+ * This method is responsible for parsing WebDAV live properties. The
+ * DOMElement $domElement must be an XML element in the DAV: namepsace. If
+ * the received property is not defined in RFC 2518, null is returned.
+ *
+ * @param DOMElement $domElement
+ * @return ezcWebdavLiveProperty|null
+ */
+ protected function extractLiveProperty( DOMElement $domElement )
+ {
+ switch ( $domElement->localName )
+ {
+ case 'creationdate':
+ $property = new ezcWebdavCreationDateProperty();
+ if ( empty( $domElement->nodeValue ) === false )
+ {
+ $property->date = new ezcWebdavDateTime(
$domElement->nodeValue );
+ }
+ break;
+ case 'displayname':
+ $property = new ezcWebdavDisplayNameProperty();
+ if ( empty( $domElement->nodeValue ) === false )
+ {
+ $property->displayName = $domElement->nodeValue;
+ }
+ break;
+ case 'getcontentlanguage':
+ $property = new ezcWebdavGetContentLanguageProperty();
+ if ( empty( $domElement->nodeValue ) === false )
+ {
+ // e.g. 'de, en'
+ $property->displayName = array_map( 'trim', explode( ',',
$domElement->nodeValue ) );
+ }
+ break;
+ case 'getcontentlength':
+ $property = new ezcWebdavGetContentLengthProperty();
+ if ( empty( $domElement->nodeValue ) === false )
+ {
+ $property->length = trim( $domElement->nodeValue );
+ }
+ break;
+ case 'getcontenttype':
+ $property = new ezcWebdavGetContentTypeProperty();
+ // @TODO: Should this throw an exception, if the match fails?
+ // Currently, the property stays empty and the backend needs
to handle this
+ if ( empty( $domElement->nodeValue ) === false
+ && preg_match( self::GETCONTENTTYPE_REGEX,
$domElement->nodeValue, $matches ) > 0 )
+ {
+ $property->mime = $matches['mime'];
+ $property->charset = $matches['charset'];
+ }
+ break;
+ case 'getetag':
+ $property = new ezcWebdavGetEtagProperty();
+ if ( empty( $domElement->nodeValue ) === false )
+ {
+ $property->etag = $domElement->nodeValue;
+ }
+ break;
+ case 'getlastmodified':
+ $property = new ezcWebdavGetLastModifiedProperty();
+ if ( empty( $domElement->nodeValue ) === false )
+ {
+ $property->date = new ezcWebdavDateTime(
$domElement->nodeValue );
+ }
+ break;
+ case 'lockdiscovery':
+ $property = new ezcWebdavLockDiscoveryProperty();
+ if ( $domElement->hasChildNodes() === true )
+ {
+ $property->activeLock = $this->extractActiveLockContent(
$domElement );
+ }
+ break;
+ case 'resourcetype':
+ $property = new ezcWebdavResourceTypeProperty();
+ if ( empty( $domElement->nodeValue ) === false )
+ {
+ $property->type = $domElement->nodeValue;
+ }
+ break;
+ case 'source':
+ $property = new ezcWebdavSourceProperty();
+ if ( $domElement->hasChildNodes() === true )
+ {
+ $property->links = $this->extractLinkContent( $domElement
);
+ }
+ break;
+ case 'supportedlock':
+ $property = new ezcWebdavSupportedLockProperty();
+ if ( $domElement->hasChildNodes() === true )
+ {
+ $property->links = $this->extractLockEntryContent(
$domElement );
+ }
+ break;
+ default:
+ // @TODO Implement extension plugins
+ // Currently just ignore
+ $property = $this->extractDeadProperty( $domElement );
+ }
+ return $property;
+ }
+
+ /**
+ * Serializes an object of new ezcWebdavBasicPropertyStorage to XML.
+ * Attaches all properties of the $storage to the $parentElement XML
+ * element.
+ *
+ * @param new ezcWebdavPropertyStorage $storage
+ * @param DOMElement $parentElement
+ * @return void
+ */
+ public function serializeProperties( ezcWebdavPropertyStorage $storage,
DOMElement $parentElement )
+ {
+ foreach ( $storage as $property )
+ {
+ if ( $property instanceof ezcWebdavLiveProperty )
+ {
+ $this->serializeLiveProperty( $property, $parentElement );
+ }
+ else
+ {
+ $this->serializeDeadProperty( $property, $parentElement );
+ }
+ }
+ }
+
+ // Extracting
+
+ /**
+ * Extracts the <activelock /> XML elements.
+ * This method extracts the <activelock /> XML elements from the
+ * <lockdiscovery /> element and returns the corresponding
+ * ezcWebdavLockDiscoveryPropertyActiveLock object to be used as the
+ * content of ezcWebdavLockDiscoveryProperty.
+ *
+ * @param DOMElement $domElement
+ * @return ezcWebdavLockDiscoveryPropertyActiveLock
+ */
+ protected function extractActiveLockContent( DOMElement $domElement )
+ {
+ $activeLock = new ezcWebdavLockDiscoveryPropertyActiveLock();
+
+ $activelockElement = $domElement->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'activelock' )->item( 0 );
+ for ( $i = 0; $i < $activelockElement->childNodes->length; ++$i )
+ {
+ if ( ( ( $currentElement = $activelockElement->childNodes->item(
$i ) ) instanceof DOMElement ) === false )
+ {
+ // Skip non element children
+ continue;
+ }
+ switch ( $currentElement->localName )
+ {
+ case 'locktype':
+ if ( $currentElement->hasChildren &&
$currentElement->firstChild->localName !== 'write' )
+ {
+ $activelock->lockType =
ezcWebdavLockRequest::TYPE_READ;
+ }
+ else
+ {
+ $activelock->lockType =
ezcWebdavLockRequest::TYPE_WRITE;
+ }
+ break;
+ case 'lockscope':
+ if ( $currentElement->hasChildren )
+ {
+ switch ( $currentElement->firstChild->localName )
+ {
+ case 'exclusive':
+ $activelock->lockScope =
ezcWebdavLockRequest::SCOPE_EXCLUSIVE;
+ break;
+ case 'shared':
+ $activelock->lockScope =
ezcWebdavLockRequest::SCOPE_SHARED;
+ break;
+ }
+ }
+ break;
+ case 'depth':
+ switch ( trim( $currentElement->nodeValue ) )
+ {
+ case '0':
+ $activelock->depth = ezcWebdavRequest::DEPTH_ZERO;
+ break;
+ case '1':
+ $activelock->depth = ezcWebdavRequest::DEPTH_ONE;
+ break;
+ case 'infinity':
+ $activelock->depth =
ezcWebdavRequest::DEPTH_INFINITY;
+ break;
+ }
+ break;
+ case 'owner':
+ // Ignore <href /> element by intention!
+ $activelock->owner = $currentElement->textContent;
+ break;
+ case 'timeout':
+ // @TODO Need to check for special values here!
+ $activelock->timeout = new ezcWebdavDateTime(
$currentElement->nodeValue );
+ break;
+ case 'locktoken':
+ for ( $i = 0; $i < $currentElement->childNodes->length;
++$i )
+ {
+ $activelock->tokens[] = trim(
$currentElement->childNodes->item( $i )->textContent );
+ }
+ break;
+ }
+ }
+ return $activelock;
+ }
+
+ /**
+ * Extracts the <link /> XML elements.
+ * This method extracts the <link /> XML elements from the <source />
+ * element and returns the corresponding ezcWebdavSourcePropertyLink object
+ * to be used as the content of ezcWebdavSourceProperty.
+ *
+ * @param DOMElement $domElement
+ * @return ezcWebdavSourcePropertyLink
+ */
+ protected function extractLinkContent( DOMElement $domElement )
+ {
+ $links = array();
+
+ $linkElements = $domElement->getElementsByTagNameNS(
+ ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'link'
+ );
+ for ( $i = 0; $i < $linkElements->length; ++$i )
+ {
+ $links[] = new ezcWebdavSourcePropertyLink(
+ $linkElements->item( $i )->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'src' )->nodeValue,
+ $linkElements->item( $i )->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'dst' )->nodeValue
+ );
+ }
+ return $links;
+ }
+
+ /**
+ * Extracts the <lockentry /> XML elements.
+ * This method extracts the <lockentry /> XML elements from the
<supportedlock />
+ * element and returns the corresponding
+ * ezcWebdavSupportedLockPropertyLockentry object to be used as the content
+ * of ezcWebdavSupportedLockProperty.
+ *
+ * @param DOMElement $domElement
+ * @return ezcWebdavSupportedLockProperty
+ */
+ protected function extractLockEntryContent( DOMElement $domElement )
+ {
+ $lockEntries = array();
+
+ $lockEntryElements = $domElement->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'lockentry' );
+ for ( $i = 0; $i < $lockEntryElements->length; ++$i )
+ {
+ $lockEntries[] = new ezcWebdavSupportedLockPropertyLockentry(
+ ( $lockEntryElements->item( $i )->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'locktype' )->item( 0 )->localname ===
'write'
+ ? ezcWebdavLockRequest::TYPE_WRITE :
ezcWebdavLockRequest::TYPE_READ ),
+ ( $lockEntryElements->item( $i )->getElementsByTagNameNS(
ezcWebdavXmlTool::XML_DEFAULT_NAMESPACE, 'lockscope' )->item( 0 )->localname
=== 'shared'
+ ? ezcWebdavLockRequest::SCOPE_SHARED :
ezcWebdavLockRequest::SCOPE_EXCLUSIVE )
+ );
+ }
+ return $lockEntries;
+ }
+
+ // Serializing
+
+ /**
+ * Returns the XML representation of a dead property.
+ * Returns a DOMElement, representing the content of the given $property.
+ * The newly created element is also appended as a child to the given
+ * $parentElement.
+ *
+ * @param ezcWebdavDeadProperty $property
+ * @param DOMElement $parentElement
+ * @return DOMElement
+ */
+ protected function serializeDeadProperty( ezcWebdavDeadProperty $property,
DOMElement $parentElement )
+ {
+ if ( $property->content === null || ( $contentDom =
$this->xml->createDomDocument( $property->content ) ) === false )
+ {
+ return $parentElement->appendChild(
+ $this->xml->createDomElement(
+ $parentElement->ownerDocument,
+ $property->name,
+ $property->namespace
+ )
+ );
+ }
+
+ return $parentElement->appendChild(
+ $parentElement->ownerDocument->importNode(
$contentDom->documentElement, true )
+ );
+ }
+
+ /**
+ * Returns the XML representation of a live property.
+ * Returns a DOMElement, representing the content of the given $property.
+ * The newly created element is also appended as a child to the given
+ * $parentElement.
+ *
+ * @param ezcWebdavLiveProperty $property
+ * @param DOMElement $parentElement
+ * @return DOMElement
+ */
+ protected function serializeLiveProperty( ezcWebdavLiveProperty $property,
DOMElement $parentElement )
+ {
+ switch ( get_class( $property ) )
+ {
+ case 'ezcWebdavCreationDateProperty':
+ $elementName = 'creationdate';
+ $elementValue = ( $property->date !== null ?
$property->date->format( DATE_ISO8601 ) : null );
+ break;
+ case 'ezcWebdavDisplayNameProperty':
+ $elementName = 'displayname';
+ $elementValue = $property->displayName;
+ break;
+ case 'ezcWebdavGetContentLanguageProperty':
+ $elementName = 'getcontentlanguage';
+ $elementValue = ( count( $property->languages ) > 0 ? implode(
', ', $property->languages ) : null );
+ break;
+ case 'ezcWebdavGetContentLengthProperty':
+ $elementName = 'getcontentlength';
+ $elementValue = $property->length;
+ break;
+ case 'ezcWebdavGetContentTypeProperty':
+ $elementName = 'getcontenttype';
+ $elementValue = ( $property->mime !== null ? $property->mime .
( $property->charset === null ? '' : '; charset="' . $property->charset . '"' )
: null );
+ break;
+ case 'ezcWebdavGetEtagProperty':
+ $elementName = 'getetag';
+ $elementValue = $property->etag;
+ break;
+ case 'ezcWebdavGetLastModifiedProperty':
+ $elementName = 'getlastmodified';
+ $elementValue = ( $property->date !== null ?
$property->date->format( DATE_RFC1123 ) : null );
+ break;
+ case 'ezcWebdavLockDiscoveryProperty':
+ $elementName = 'lockdiscovery';
+ $elementValue = ( $property->activeLock !== null ?
$this->serializeActiveLockContent( $property->activeLock,
$parentElement->ownerDocument ) : null );
+ break;
+ case 'ezcWebdavResourceTypeProperty':
+ $elementName = 'resourcetype';
+ $elementValue = ( $property->type ===
ezcWebdavResourceTypeProperty::TYPE_COLLECTION ? array(
$this->xml->createDomElement( $parentElement->ownerDocument, 'collection' ) ) :
null );
+ break;
+ case 'ezcWebdavSourceProperty':
+ $elementName = 'source';
+ $elementValue = ( $property->links !== null ?
$this->serializeLinkContent( $property->links, $parentElement->ownerDocument )
: null );
+ break;
+ case 'ezcWebdavSupportedLockProperty':
+ $elementName = 'supportedlock';
+ $elementValue = ( $property->lockEntry !== null ?
$this->serializeLockEntryContent( $property->lockEntry,
$parentElement->ownerDocument ) : null );
+ break;
+ }
+
+ $propertyElement = $parentElement->appendChild(
+ $this->xml->createDomElement( $parentElement->ownerDocument,
$elementName, $property->namespace )
+ );
+
+ if ( $elementValue instanceof DOMDocument )
+ {
+ $propertyElement->appendChild(
+ $dom->importNode( $elementValue->documentElement, true )
+ );
+ }
+ else if ( is_array( $elementValue ) )
+ {
+ foreach( $elementValue as $subValue )
+ {
+ $propertyElement->appendChild( $subValue );
+ }
+ }
+ else if ( is_scalar( $elementValue ) )
+ {
+ $propertyElement->nodeValue = $elementValue;
+ }
+
+ return $propertyElement;
+ }
+
+ /**
+ * Serializes an array of ezcWebdavLockDiscoveryPropertyActiveLock
elements to XML.
+ *
+ * @param array(ezcWebdavLockDiscoveryPropertyActiveLock) $links
+ * @param DOMDocument $dom To create the returned DOMElements.
+ * @return array(DOMElement)
+ */
+ protected function serializeActiveLockContent( array $activeLocks = null,
DOMDocument $dom )
+ {
+ $activeLockElements = array();
+ foreach ( $activeLocks as $activeLock )
+ {
+ $activeLockElement = $this->xml->createDomElement( $dom,
'activelock' );
+
+ $activeLockElement->appendChild(
+ $this->xml->createDomElement( $dom, 'locktype' )
+ )->appendChild(
+ $this->xml->createDomElement( $dom, ( $activeLock->lockType
=== ezcWebdavLockRequest::TYPE_READ ? 'read' : 'write' ) )
+ );
+
+ $activeLockElement->appendChild(
+ $this->xml->createDomElement( $dom, 'lockscope' )
+ )->appendChild(
+ $this->xml->createDomElement( $dom, ( $activeLock->lockScope
=== ezcWebdavLockRequest::SCOPE_EXCLUSIVE ? 'exclusive' : 'shared' ) )
+ );
+
+ $depthElement = $activeLockElement->appendChild(
+ $this->xml->createDomElement( $dom, 'depth' )
+ );
+
+ switch ( $activeLock->depth )
+ {
+ case ezcWebdavRequest::DEPTH_ZERO:
+ $depthElement->nodeValue = '0';
+ break;
+ case ezcWebdavRequest::DEPTH_ONE:
+ $depthElement->nodeValue = '1';
+ break;
+ case ezcWebdavRequest::DEPTH_INFINITY:
+ $depthElement->nodeValue = 'Infity';
+ break;
+ }
+
+ if ( $activeLock->owner !== null )
+ {
+ $activeLockElement->appendChild(
+ $this->xml->createDomElement( $dom, 'owner' )
+ )->nodeValue = $activeLock->owner;
+ }
+
+ $activeLockElement->appendChild(
+ $this->xml->createDomElement( $dom, 'timeout' )
+ )->$activeLock->timeout;
+
+ foreach ( $activeLock->tokens as $token )
+ {
+ $activeLockElement->appendChild(
+ $this->xml->createDomElement( $dom, 'locktoken' )
+ )->appendChild(
+ $this->xml->createDomElement( $dom, 'href' )
+ )->nodeValue = $token;
+ }
+
+ $activeLockElements[] = $lockElement;
+ }
+
+ return $activeLockElements;
+ }
+
+ /**
+ * Serializes an array of ezcWebdavSupportedLockPropertyLockentry elements
to XML.
+ *
+ * @param array(ezcWebdavSupportedLockPropertyLockentry) $lockEntries
+ * @param DOMDocument $dom To create the returned DOMElements.
+ * @return array(DOMElement)
+ */
+ protected function serializeLockEntryContent( array $lockEntries = null,
DOMDocument $dom )
+ {
+ $lockEntryContentElements = array();
+
+ foreach( $lockEntries as $lockEntry )
+ {
+ $lockEntryElement = $this->xml->createDomElement( $dom,
'lockentry' );
+ $lockEntryElement->appendChild(
+ $this->xml->createDomElement( $dom, 'lockscope' )
+ )->appendChild(
+ $this->xml->createDomElement( $dom, ( $lockEntry->lockScope
=== ezcWebdavLockRequest::SCOPE_EXCLUSIVE ? 'exclusive' : 'shared' ) )
+ );
+ $lockEntryElement->appendChild(
+ $this->xml->createDomElement( $dom, 'locktype' )
+ )->appendChild(
+ $this->xml->createDomElement( $dom, ( $lockEntry->lockScope
=== ezcWebdavLockRequest::TYPE_READ ? 'read' : 'write' ) )
+ );
+ $lockEntryContentElements[] = $lockEntryElement;
+ }
+
+ return $lockEntryContentElements;
+ }
+
+ /**
+ * Serializes an array of ezcWebdavSourcePropertyLink elements to XML.
+ *
+ * @param array(ezcWebdavSourcePropertyLink) $links
+ * @param DOMDocument $dom To create the returned DOMElements.
+ * @return array(DOMElement)
+ */
+ protected function serializeLinkContent( array $links = null, DOMDocument
$dom )
+ {
+ $linkContentElements = array();
+
+ foreach( $links as $link )
+ {
+ $linkElement = $this->xml->createDomElement( $dom, 'link' );
+ $linkElement->appendChild(
+ $this->xml->createDomElement( $dom, 'src' )
+ )->nodeValue = $link->src;
+ $linkElement->appendChild(
+ $this->xml->createDomElement( $dom, 'dst' )
+ )->nodeValue = $link->dst;
+ $linkContentElements[] = $linkElement;
+ }
+
+ return $linkContentElements;
+ }
+}
+
+?>
Propchange: trunk/Webdav/src/transports/property_handler.php
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/Webdav/src/webdav_autoload.php
==============================================================================
--- trunk/Webdav/src/webdav_autoload.php [iso-8859-1] (original)
+++ trunk/Webdav/src/webdav_autoload.php [iso-8859-1] Fri Sep 28 14:22:28 2007
@@ -80,6 +80,7 @@
'ezcWebdavPropPatchRequest' =>
'Webdav/requests/proppatch.php',
'ezcWebdavPropPatchResponse' =>
'Webdav/responses/proppatch.php',
'ezcWebdavPropStatResponse' =>
'Webdav/responses/propstat.php',
+ 'ezcWebdavPropertyHandler' =>
'Webdav/transports/property_handler.php',
'ezcWebdavPutRequest' => 'Webdav/requests/put.php',
'ezcWebdavPutResponse' => 'Webdav/responses/put.php',
'ezcWebdavRequestLockInfoContent' =>
'Webdav/requests/content/lock_info.php',
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components