Author: ts
Date: Fri Sep 28 00:10:54 2007
New Revision: 6314
Log:
- Refactoring: Cleaned up mess with ezcWebdavDisplayInformation.
Added:
trunk/Webdav/src/structs/display_information_empty.php (with props)
trunk/Webdav/src/structs/display_information_string.php (with props)
trunk/Webdav/src/structs/display_information_xml.php (with props)
Modified:
trunk/Webdav/design/class_diagram.png
trunk/Webdav/src/structs/display_information.php
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/structs/display_information.php
==============================================================================
--- trunk/Webdav/src/structs/display_information.php [iso-8859-1] (original)
+++ trunk/Webdav/src/structs/display_information.php [iso-8859-1] Fri Sep 28
00:10:54 2007
@@ -1,6 +1,6 @@
<?php
/**
- * File containing the class ezcWebdavDisplayInformation.
+ * File containing the ezcWebdavDisplayInformation struct.
*
* @package Webdav
* @version //autogentag//
@@ -18,7 +18,7 @@
* @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
-class ezcWebdavDisplayInformation
+abstract class ezcWebdavDisplayInformation
{
/**
@@ -28,7 +28,7 @@
* @param DOMDocument|string|null $body
* @return void
*/
- public function __construct( ezcWebdavResponse $response, $body = null )
+ public function __construct( ezcWebdavResponse $response, $body )
{
$this->response = $response;
$this->body = $body;
@@ -43,10 +43,9 @@
/**
* Representation of the response body.
- * Should be null, if no body is to be sent, an instance of DOMDocument to
- * send and XML body or a string representng the body if it is non-XML.
+ * Contents overwritten in extending structs.
*
- * @var DOMDocument|string|null
+ * @var DOMDocument|sring|null
*/
public $body;
}
Added: trunk/Webdav/src/structs/display_information_empty.php
==============================================================================
--- trunk/Webdav/src/structs/display_information_empty.php (added)
+++ trunk/Webdav/src/structs/display_information_empty.php [iso-8859-1] Fri Sep
28 00:10:54 2007
@@ -1,0 +1,43 @@
+<?php
+/**
+ * File containing the ezcWebdavDisplayInformation struct.
+ *
+ * @package Webdav
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * Display information.
+ *
+ * Used by [EMAIL PROTECTED] ezcWebdavTransport} to transport information on
displaying a
+ * response to the browser.
+ *
+ * @version //autogentag//
+ * @package Webdav
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+class ezcWebdavDisplayInformationEmpty extends ezcWebdavDisplayInformation
+{
+
+ /**
+ * Creates a new struct.
+ *
+ * @param ezcWebdavResponse $response
+ * @return void
+ */
+ public function __construct( ezcWebdavResponse $response )
+ {
+ $this->response = $response;
+ }
+
+ /**
+ * Response object to extract headers from.
+ *
+ * @var ezcWebdavResponse
+ */
+ public $response;
+}
+
+?>
Propchange: trunk/Webdav/src/structs/display_information_empty.php
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/Webdav/src/structs/display_information_string.php
==============================================================================
--- trunk/Webdav/src/structs/display_information_string.php (added)
+++ trunk/Webdav/src/structs/display_information_string.php [iso-8859-1] Fri
Sep 28 00:10:54 2007
@@ -1,0 +1,52 @@
+<?php
+/**
+ * File containing the ezcWebdavDisplayInformation struct.
+ *
+ * @package Webdav
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * Display information.
+ *
+ * Used by [EMAIL PROTECTED] ezcWebdavTransport} to transport information on
displaying a
+ * response to the browser.
+ *
+ * @version //autogentag//
+ * @package Webdav
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+class ezcWebdavDisplayInformationString extends ezcWebdavDisplayInformation
+{
+
+ /**
+ * Creates a new struct.
+ *
+ * @param ezcWebdavResponse $response
+ * @param string $body
+ * @return void
+ */
+ public function __construct( ezcWebdavResponse $response, $body )
+ {
+ $this->response = $response;
+ $this->body = $body;
+ }
+
+ /**
+ * Response object to extract headers from.
+ *
+ * @var ezcWebdavResponse
+ */
+ public $response;
+
+ /**
+ * Representation of the response body.
+ *
+ * @var string
+ */
+ public $body;
+}
+
+?>
Propchange: trunk/Webdav/src/structs/display_information_string.php
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/Webdav/src/structs/display_information_xml.php
==============================================================================
--- trunk/Webdav/src/structs/display_information_xml.php (added)
+++ trunk/Webdav/src/structs/display_information_xml.php [iso-8859-1] Fri Sep
28 00:10:54 2007
@@ -1,0 +1,54 @@
+<?php
+/**
+ * File containing the ezcWebdavDisplayInformation struct.
+ *
+ * @package Webdav
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * Display information.
+ *
+ * Used by [EMAIL PROTECTED] ezcWebdavTransport} to transport information on
displaying a
+ * response to the browser.
+ *
+ * @version //autogentag//
+ * @package Webdav
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+class ezcWebdavDisplayInformationXml extends ezcWebdavDisplayInformation
+{
+
+ /**
+ * Creates a new struct.
+ *
+ * @param ezcWebdavResponse $response
+ * @param DOMDocument $body
+ * @return void
+ */
+ public function __construct( ezcWebdavResponse $response, DOMDOcument
$body )
+ {
+ $this->response = $response;
+ $this->body = $body;
+ }
+
+ /**
+ * Response object to extract headers from.
+ *
+ * @var ezcWebdavResponse
+ */
+ public $response;
+
+ /**
+ * Representation of the response body.
+ * Should be null, if no body is to be sent, an instance of DOMDocument to
+ * send and XML body or a string representng the body if it is non-XML.
+ *
+ * @var DOMDocument|string|null
+ */
+ public $body;
+}
+
+?>
Propchange: trunk/Webdav/src/structs/display_information_xml.php
------------------------------------------------------------------------------
svn:eol-style = native
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 00:10:54 2007
@@ -251,7 +251,7 @@
{
switch ( true )
{
- case ( $info->body instanceof DOMDocument ):
+ case ( $info instanceof ezcWebdavDisplayInformationXml ):
$info->body->formatOutput = true;
// Explicitly set txt/xml content type
if ( $info->response->getHeader( 'Content-Type' ) === null )
@@ -261,15 +261,15 @@
$result = $info->body->saveXML( $info->body );
break;
- case ( is_string( $info->body ) ):
+ case ( $info instanceof ezcWebdavDisplayInformationString ):
if ( $info->response->getHeader( 'Content-Type' ) === null )
{
throw new ezcWebdavMissingHeaderException( 'ContentType' );
}
$result = $info->body;
break;
- case ( $info->body === null ):
-
+
+ case ( $info instanceof ezcWebdavDisplayInformationEmpty ):
default:
if ( ( $contenTypeHeader = $info->response->getHeader(
'Content-Type' ) ) !== null )
{
@@ -1164,7 +1164,7 @@
* Returns an XML representation of the given response object.
*
* @param ezcWebdavMultiStatusResponse $response
- * @return DOMDocument
+ * @return ezcWebdavDisplayInformationXml
*/
protected function processMultiStatusResponse(
ezcWebdavMultiStatusResponse $response )
{
@@ -1184,14 +1184,14 @@
);
}
- return new ezcWebdavDisplayInformation( $response, $dom );
+ return new ezcWebdavDisplayInformationXml( $response, $dom );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavPropFindResponse $response
- * @return DOMDocument
+ * @return ezcWebdavDisplayInformationXml
*/
protected function processPropFindResponse( ezcWebdavPropFindResponse
$response )
{
@@ -1211,51 +1211,51 @@
$dom->importNode( $this->processPropStatResponse( $propStat
)->body->documentElement, true )
);
}
- return new ezcWebdavDisplayInformation( $response, $dom );
+ return new ezcWebdavDisplayInformationXml( $response, $dom );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavPropPatchResponse $response
- * @return DOMDocument
+ * @return ezcWebdavDisplayInformationEmpty
*/
protected function processPropPatchResponse( ezcWebdavPropPatchResponse
$response )
{
- return new ezcWebdavDisplayInformation( $response, null );
+ return new ezcWebdavDisplayInformationEmpty( $response );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavCopyResponse $response
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationEmpty
*/
protected function processCopyResponse( ezcWebdavCopyResponse $response )
{
- return new ezcWebdavDisplayInformation( $response, null );
+ return new ezcWebdavDisplayInformationEmpty( $response );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavMoveResponse $response
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationEmpty
*/
protected function processMoveResponse( ezcWebdavMoveResponse $response )
{
- return new ezcWebdavDisplayInformation( $response, null );
+ return new ezcWebdavDisplayInformationEmpty( $response );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavDeleteResponse $response
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationEmpty
*/
protected function processDeleteResponse( ezcWebdavDeleteResponse
$response )
{
- return new ezcWebdavDisplayInformation( $response, null );
+ return new ezcWebdavDisplayInformationEmpty( $response );
}
/**
@@ -1263,11 +1263,11 @@
*
* @param ezcWebdavErrorResponse $response
* @param bool $xml DOMDocument in result only generated of true.
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationXml|ezcWebdavDisplayInformationEmpty
*/
protected function processErrorResponse( ezcWebdavErrorResponse $response,
$xml = false )
{
- $dom = null;
+ $res = new ezcWebdavDisplayInformationEmpty( $response );
if ( $xml === true )
{
$dom = $this->xml->createDomDocument();
@@ -1282,27 +1282,27 @@
$responseElement->appendChild(
$this->xml->createDomElement( $dom, 'status' )
)->nodeValue = (string) $response;
-
- }
- return new ezcWebdavDisplayInformation( $response, $dom );
+ $res = new ezcWebdavDisplayInformationXml( $response, $dom );
+ }
+ return $res;
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavGetCollectionResponse $response
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationEmpty
*/
protected function processGetCollectionResponse(
ezcWebdavGetCollectionResponse $response )
{
- return new ezcWebdavDisplayInformation( $response, null );
+ return new ezcWebdavDisplayInformationEmpty( $response );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavGetResourceResponse $response
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationString
* @todo Do we need to set more headers here?
*/
protected function processGetResourceResponse(
ezcWebdavGetResourceResponse $response )
@@ -1315,32 +1315,26 @@
'; charset="' . ( $contentTypeProperty->charset !== null ?
$contentTypeProperty->charset : 'utf-8' ) . '"';
$response->setHeader( 'Content-Type', $contentTypeHeader );
}
- // Generate Content-Length header if necessary
- /*
- if ( $response->getHeader( 'Content-Length' ) === null )
- {
- $response->setHeader( 'Content-Length', ( strlen(
$response->resource->content ) + 1 ) );
- }
- */
- return new ezcWebdavDisplayInformation( $response,
$response->resource->content );
+ // Content-Length automatically send by web server
+ return new ezcWebdavDisplayInformationString( $response,
$response->resource->content );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavPutResponse $response
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationEmpty
*/
protected function processPutResponse( ezcWebdavPutResponse $response )
{
- return new ezcWebdavDisplayInformation( $response, $response );
+ return new ezcWebdavDisplayInformationEmpty( $response );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavHeadResponse $response
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationEmpty
* @todo Do we need to set more headers here?
*/
protected function processHeadResponse( ezcWebdavHeadResponse $response )
@@ -1358,36 +1352,36 @@
{
$response->setHeader( 'Content-Length', ( strlen(
$response->resource->content ) + 1 ) );
}
- return new ezcWebdavDisplayInformation( $response,
$response->resource->content );
+ return new ezcWebdavDisplayInformationEmpty( $response );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavMakeCollectionResponse $response
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationEmpty
*/
protected function processMakeCollectionResponse(
ezcWebdavMakeCollectionResponse $response )
{
- return new ezcWebdavDisplayInformation( $response, null );
+ return new ezcWebdavDisplayInformationEmpty( $response );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavOptionsResponse $response
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationEmpty
*/
protected function processOptionsResponse( ezcWebdavOptionsResponse
$response )
{
- return new ezcWebdavDisplayInformation( $response, null );
+ return new ezcWebdavDisplayInformationEmpty( $response );
}
/**
* Returns an XML representation of the given response object.
*
* @param ezcWebdavPropStatResponse $response
- * @return DOMDocument|null
+ * @return ezcWebdavDisplayInformationXml
*/
protected function processPropStatResponse( ezcWebdavPropStatResponse
$response )
{
@@ -1409,7 +1403,7 @@
)
)->nodeValue = (string) $response;
- return new ezcWebdavDisplayInformation( $response, $dom );
+ return new ezcWebdavDisplayInformationXml( $response, $dom );
}
/**
@@ -1417,7 +1411,7 @@
* Attaches all properties of the $storage to the $parentElement XML
* element.
*
- * @param new ezcWebdavBasicPropertyStorage $storage
+ * @param new ezcWebdavPropertyStorage $storage
* @param DOMElement $parentElement
* @return void
*/
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 00:10:54 2007
@@ -28,17 +28,18 @@
'ezcWebdavBackendMakeCollection' =>
'Webdav/interfaces/backend/make_collection.php',
'ezcWebdavBackendPut' =>
'Webdav/interfaces/backend/put.php',
'ezcWebdavLiveProperty' =>
'Webdav/interfaces/property_live.php',
- 'ezcWebdavPathFactory' =>
'Webdav/interfaces/path_factory.php',
'ezcWebdavPropertyStorage' =>
'Webdav/interfaces/property_storage.php',
'ezcWebdavResponse' =>
'Webdav/interfaces/response.php',
- 'ezcWebdavBasicPathFactory' =>
'Webdav/path_factories/basic.php',
'ezcWebdavBasicPropertyStorage' =>
'Webdav/property_storages/basic.php',
'ezcWebdavCopyResponse' => 'Webdav/responses/copy.php',
+ 'ezcWebdavDisplayInformation' =>
'Webdav/structs/display_information.php',
+ 'ezcWebdavPathFactory' =>
'Webdav/interfaces/path_factory.php',
'ezcWebdavPropFindResponse' =>
'Webdav/responses/propfind.php',
'ezcWebdavRequest' =>
'Webdav/interfaces/request.php',
'ezcWebdavSimpleBackend' => 'Webdav/backends/simple.php',
'ezcWebdavSupportedLockPropertyLockentry' =>
'Webdav/properties/supportedlock_lockentry.php',
'ezcWebdavAutomaticPathFactory' =>
'Webdav/path_factories/automatic.php',
+ 'ezcWebdavBasicPathFactory' =>
'Webdav/path_factories/basic.php',
'ezcWebdavCollection' =>
'Webdav/structs/collection.php',
'ezcWebdavCopyRequest' => 'Webdav/requests/copy.php',
'ezcWebdavCreationDateProperty' =>
'Webdav/properties/creationdate.php',
@@ -46,7 +47,9 @@
'ezcWebdavDeadProperty' => 'Webdav/properties/dead.php',
'ezcWebdavDeleteRequest' => 'Webdav/requests/delete.php',
'ezcWebdavDeleteResponse' =>
'Webdav/responses/delete.php',
- 'ezcWebdavDisplayInformation' =>
'Webdav/structs/display_information.php',
+ 'ezcWebdavDisplayInformationEmpty' =>
'Webdav/structs/display_information_empty.php',
+ 'ezcWebdavDisplayInformationString' =>
'Webdav/structs/display_information_string.php',
+ 'ezcWebdavDisplayInformationXml' =>
'Webdav/structs/display_information_xml.php',
'ezcWebdavDisplayNameProperty' =>
'Webdav/properties/displayname.php',
'ezcWebdavErrorResponse' => 'Webdav/responses/error.php',
'ezcWebdavFileBackend' => 'Webdav/backends/file.php',
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components