eZPublish(LegacyStack)  5.1
eZWebDAVContentBackend Class Reference

WebDAV backend for eZ Publish, based on eZ Components Webdav component. More...

+ Inheritance diagram for eZWebDAVContentBackend:
+ Collaboration diagram for eZWebDAVContentBackend:

Public Member Functions

 __construct ()
 Creates a new backend instance. More...
 
 checkDeleteRecursive ($target)
 Returns if everything below a path can be deleted recursively. More...
 
 copy (ezcWebdavCopyRequest $request)
 Serves COPY requests. More...
 
 copyRecursive ($source, $destination, $depth=ezcWebdavRequest::DEPTH_INFINITY)
 Recursively copy a file or directory. More...
 
 currentSiteFromPath ($path)
 Detects a possible/valid site-name in start of a path. More...
 
 delete (ezcWebdavDeleteRequest $request)
 Serves DELETE requests. More...
 
 get (ezcWebdavGetRequest $request)
 Serves GET requests. More...
 
 getAllProperties ($path)
 Returns all properties for a resource. More...
 
 getProperty ($path, $propertyName, $namespace= 'DAV:')
 Returns a property of a resource. More...
 
 head (ezcWebdavHeadRequest $request)
 Serves HEAD requests. More...
 
 lock ($waitTime, $timeout)
 Locks the backend. More...
 
 makeCollection (ezcWebdavMakeCollectionRequest $request)
 Serves MKCOL (make collection) requests. More...
 
 move (ezcWebdavMoveRequest $request)
 Serves MOVE requests. More...
 
 moveRecursive ($source, $destination, $depth=ezcWebdavRequest::DEPTH_INFINITY)
 Recursively move a file or directory. More...
 
 options (ezcWebdavOptionsRequest $request)
 Required method to serve OPTIONS requests. More...
 
 propFind (ezcWebdavPropFindRequest $request)
 Serves PROPFIND requests. More...
 
 propPatch (ezcWebdavPropPatchRequest $request)
 Serves PROPPATCH requests. More...
 
 put (ezcWebdavPutRequest $request)
 Serves PUT requests. More...
 
 removeProperty ($path, ezcWebdavProperty $property)
 Manually removes a property from a resource. More...
 
 resetProperties ($path, ezcWebdavPropertyStorage $storage)
 Resets the property storage for a resource. More...
 
 setCurrentSite ($site)
 Sets the current site. More...
 
 setProperty ($path, ezcWebdavProperty $property)
 Manually sets a property on a resource. More...
 
 unlock ()
 Removes the lock. More...
 

Static Public Member Functions

static appendLogEntry ($logString, $label=false)
 Logs to var/log/webdav.log AND var/<site_name>/log/webdav.log. More...
 
static virtualContentFolderName ()
 The name of the content folder in eZ Publish, translated. More...
 
static virtualMediaFolderName ()
 The name of the media folder in eZ Publish, translated. More...
 

Public Attributes

const DEFAULT_MIMETYPE = "application/octet-stream"
 Mimetype for eZ Publish objects which don't have a mimetype. More...
 
const DEFAULT_SIZE = 0
 Default size in bytes for eZ Publish objects which don't have a size. More...
 
const DIRECTORY_MIMETYPE = 'httpd/unix-directory'
 Mimetype for directories. More...
 
const VIRTUAL_CONTENT_FOLDER_NAME = 'Content'
 The name of the content folder in eZ Publish. More...
 
const VIRTUAL_MEDIA_FOLDER_NAME = 'Media'
 The name of the media folder in eZ Publish. More...
 
const WEBDAV_INI_FILE = "webdav.ini"
 The ini file which holds settings for WebDAV. More...
 

Protected Member Functions

 acquireLock ($readOnly=false)
 Wait and get lock for complete directory tree. More...
 
 copyContent ($sourceSite, $destinationSite, $sourceVFolder, $destinationVFolder, $source, $destination)
 Copies the node specified by the path $source to $destination. More...
 
 copyObject ($object, $newParentNode)
 Copies the specified object as a child to the node $newParentNode. More...
 
 copyObjectSameDirectory ($object, $newParentNode, $destinationName=null)
 Copies the specified object to the same folder, with optional $destinationName. More...
 
 copyVirtualFolder ($sourceSite, $destinationSite, $source, $destination)
 Handles copying on the virtual folder level. More...
 
 createCollection ($target)
 Creates a new collection (folder) at the given path $target. More...
 
 createFolder ($parentNode, $target)
 Creates a new folder under the given $target path. More...
 
 createResource ($path, $content=null)
 Creates a new resource. More...
 
 deleteContent ($currentSite, $virtualFolder, $target)
 Handles deletion on the content tree level. More...
 
 deleteVirtualFolder ($currentSite, $target)
 Handles deletion on the virtual folder level. More...
 
 encodeResponse (ezcWebdavResponse $response)
 Encodes the path stored in $response in order to be displayed properly in WebDAV clients. More...
 
 fetchContainerNodeInfo ($fullPath, $site, $nodeName)
 Same as fetchVirtualSiteContent(), but only one entry is returned (Content or Media). More...
 
 fetchContentList ($fullPath, &$node, $target, $depth, $properties)
 Gets and returns the content of an actual node. More...
 
 fetchNodeByTranslation ($nodePathString)
 Attempts to fetch a possible node by translating the provided string/path to a node-number. More...
 
 fetchNodeInfo ($target, &$node)
 Gathers information about a given node specified as parameter. More...
 
 fetchParentNodeByTranslation ($nodePathString)
 Attempts to fetch a possible node by translating the provided string/path to a node-number. More...
 
 fetchSiteListContent ($target, $depth, $properties)
 Builds a content-list of available sites and returns it. More...
 
 fetchVirtualSiteContent ($target, $site, $depth, $properties)
 Builds and returns the content of the virtual start folder for a site. More...
 
 fileBasename ($name)
 Returns $name without the final suffix (.jpg, .gif etc.). More...
 
 freeLock ()
 Free lock. More...
 
 getCollectionContent ($collection, $depth=false, $properties=false)
 Produces the collection content. More...
 
 getCollectionMembers ($path, $depth=ezcWebdavRequest::DEPTH_INFINITY)
 Returns members of collection. More...
 
 getContentNodeData ($result, $currentSite, $virtualFolder, $target, $fullPath)
 Handles data retrival on the content tree level. More...
 
 getContentTreeCollection ($currentSite, $virtualFolder, $collection, $fullPath, $depth, $properties)
 Handles collections on the content tree level. More...
 
 getNodeInfo ($requestUri, $source=null)
 Returns an array with information about the node with path $path. More...
 
 getNodes ($requestUri, $depth)
 Returns all child nodes. More...
 
 getPropertyStorage ($path)
 Returns the property storage for a resource. More...
 
 getResourceContents ($target)
 Returns the contents of a resource. More...
 
 getVirtualFolderCollection ($currentSite, $collection, $fullPath, $depth, $properties)
 Handles collections on the virtual folder level, if no virtual folder elements are accessed it lists the virtual folders. More...
 
 getVirtualFolderData ($result, $currentSite, $target, $fullPath)
 Handles data retrival on the virtual folder level. More...
 
 internalNodePath ($virtualFolder, $collection)
 Returns a path that corresponds to the internal path of nodes. More...
 
 isCollection ($path)
 Returns if resource is a collection. More...
 
 isObjectFolder ($object, $class)
 Returns whether $class is an folder class. More...
 
 mkcolContent ($currentSite, $virtualFolder, $target)
 Handles collection creation on the content tree level. More...
 
 mkcolVirtualFolder ($currentSite, $target)
 Handles collection creation on the virtual folder level. More...
 
 moveContent ($sourceSite, $destinationSite, $sourceVFolder, $destinationVFolder, $source, $destination, $fullSource, $fullDestination)
 Moves the node specified by the path $source to $destination. More...
 
 moveVirtualFolder ($sourceSite, $destinationSite, $source, $destination, $fullSource, $fullDestination)
 Handles moving on the virtual folder level. More...
 
 nodeExists ($path)
 Returns if a resource exists. More...
 
 performCopy ($source, $destination, $depth=ezcWebdavRequest::DEPTH_INFINITY)
 Copies resources recursively from one path to another. More...
 
 performDelete ($target)
 Deletes everything below a path. More...
 
 putContentData ($currentSite, $virtualFolder, $target, $tempFile)
 Handles data storage on the content tree level. More...
 
 putVirtualFolderData ($currentSite, $target, $tempFile)
 Handles data storage on the content tree level. More...
 
 setResourceContents ($path, $content)
 Sets the contents of a resource. More...
 
 splitFirstPathElement ($path, &$element)
 Takes the first path element from $path and removes it from the path, the extracted part will be placed in $name. More...
 
 splitLastPathElement ($path, &$element)
 Takes the last path element from $path and removes it from the path, the extracted part will be placed in $name. More...
 
 storeProperties ($path, ezcWebdavBasicPropertyStorage $storage)
 Stores properties for a resource. More...
 
 storeUploadedFile ($target, $contents)
 Stores $contents to a temporary location under the file name $target. More...
 

Static Protected Member Functions

static recode ($string, $fromCharset, $toCharset, $stop=false)
 Recodes $string from charset $fromCharset to charset $toCharset. More...
 
static tempDirectory ()
 Returns the path to the WebDAV temporary directory. More...
 

Protected Attributes

 $availableSites = array()
 
 $cachedNodes = array()
 
 $cachedProperties = array()
 
 $FolderClasses = null
 
 $handledLiveProperties
 

Static Protected Attributes

static $useLogging
 

Detailed Description

WebDAV backend for eZ Publish, based on eZ Components Webdav component.

Provides access to eZ Publish kernel using WebDAV. Based on the eZ Components Webdav component.

Todo:

Replace direct path manipulation with path factory from ezcWebdav

Fix appendLogEntry to write in only one log file

Fix using [0] for content object attributes (could be another index in some classes)

Add lock/unlock calls in setProperty and removeProperty

Use PathPrefix, PathPrefixExclude (site.ini) and StartNode (webdav.ini) in all functions where necessary

Remove all todos.

Constructor & Destructor Documentation

eZWebDAVContentBackend::__construct ( )

Creates a new backend instance.

Member Function Documentation

eZWebDAVContentBackend::acquireLock (   $readOnly = false)
protected

Wait and get lock for complete directory tree.

Acquire lock for the complete tree for read or write operations. This does not implement any priorities for operations, or check if several read operation may run in parallel. The plain locking should / could be extended by something more sophisticated.

If the tree already has been locked, the method waits until the lock can be acquired.

The optional second parameter $readOnly indicates wheather a read only lock should be acquired. This may be used by extended implementations, but it is not used in this implementation.

Parameters
bool$readOnly

Referenced by copy(), delete(), get(), head(), makeCollection(), move(), propFind(), propPatch(), and put().

static eZWebDAVContentBackend::appendLogEntry (   $logString,
  $label = false 
)
static

Logs to var/log/webdav.log AND var/<site_name>/log/webdav.log.

From eZ Publish.

Parameters
string$logStringString to record
string$labelLabel to put in front of $logString

Referenced by eZWebDAVContentBackendAuth\authenticateBasic(), eZFatalError(), fetchNodeInfo(), getContentNodeData(), moveContent(), setCurrentSite(), and setResourceContents().

eZWebDAVContentBackend::checkDeleteRecursive (   $target)

Returns if everything below a path can be deleted recursively.

Checks files and directories recursively and returns if everything can be deleted. Returns an empty array if no errors occured, and an array with the files which caused errors otherwise.

Parameters
string$source
Returns
array

Referenced by performDelete().

eZWebDAVContentBackend::copy ( ezcWebdavCopyRequest  $request)

Serves COPY requests.

The method receives a ezcWebdavCopyRequest objects containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or ezcWebdavCopyResponse on success. If only some operations failed, this method may return an instance of ezcWebdavMultistatusResponse.

This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.

Parameters
ezcWebdavCopyRequest$request
Returns
ezcWebdavResponse
eZWebDAVContentBackend::copyContent (   $sourceSite,
  $destinationSite,
  $sourceVFolder,
  $destinationVFolder,
  $source,
  $destination 
)
protected

Copies the node specified by the path $source to $destination.

Parameters
string$sourceSiteEg. 'plain_site_user'
string$destinationSiteEg. 'plain_site_user'
string$sourceVFolderEg. 'Content'
string$destinationVFolderEg. 'Content'
string$sourceEg. 'Folder1/file1.txt'
string$destinationEg. 'Folder2/file1.txt'
Returns
bool

Referenced by copyVirtualFolder().

eZWebDAVContentBackend::copyObject (   $object,
  $newParentNode 
)
protected

Copies the specified object as a child to the node $newParentNode.

Parameters
eZContentObject$object
eZContentObject$newParentNode
Returns
bool

Referenced by copyContent().

eZWebDAVContentBackend::copyObjectSameDirectory (   $object,
  $newParentNode,
  $destinationName = null 
)
protected

Copies the specified object to the same folder, with optional $destinationName.

Parameters
eZContentObject$object
eZContentObject$newParentNode
string$destinationName
Returns
bool

Referenced by copyContent().

eZWebDAVContentBackend::copyRecursive (   $source,
  $destination,
  $depth = ezcWebdavRequest::DEPTH_INFINITY 
)

Recursively copy a file or directory.

Recursively copy a file or directory in $source to the given $destination. If a $depth is given, the operation will stop as soon as the given recursion depth is reached. A depth of -1 means no limit, while a depth of 0 means, that only the current file or directory will be copied, without any recursion.

Returns an empty array if no errors occured, and an array with the files which caused errors otherwise.

Parameters
string$source
string$destination
int$depth
Returns
array

Referenced by performCopy().

eZWebDAVContentBackend::copyVirtualFolder (   $sourceSite,
  $destinationSite,
  $source,
  $destination 
)
protected

Handles copying on the virtual folder level.

It will check if the target is below a content folder in which it calls copyContent().

Parameters
string$sourceSiteEg. 'plain_site_user'
string$destinationSiteEg. 'plain_site_user'
string$sourceEg. 'Content/Folder1/file1.txt'
string$destinationEg. 'Content/Folder2/file1.txt'
Returns
bool

Referenced by copyRecursive().

eZWebDAVContentBackend::createCollection (   $target)
protected

Creates a new collection (folder) at the given path $target.

Parameters
string$targetEg. '/plain_site_user/Content/Folder1'
Returns
bool
eZWebDAVContentBackend::createFolder (   $parentNode,
  $target 
)
protected

Creates a new folder under the given $target path.

Parameters
eZContentObject$parentNode
string$targetEg. 'Folder1'
Returns
bool

Referenced by mkcolContent().

eZWebDAVContentBackend::createResource (   $path,
  $content = null 
)
protected

Creates a new resource.

Creates a new resource at the given $path, optionally with the given content. If $content is empty, an empty resource will be created.

Parameters
string$path
string$content
eZWebDAVContentBackend::currentSiteFromPath (   $path)

Detects a possible/valid site-name in start of a path.

From eZ Publish.

Parameters
string$pathEg. '/plain_site_user/Content/Folder1/file1.txt'
Returns
string The name of the site that was detected (eg. 'plain_site_user') or false if not site could be detected
Todo:
remove or move in another class?
eZWebDAVContentBackend::delete ( ezcWebdavDeleteRequest  $request)

Serves DELETE requests.

The method receives a ezcWebdavDeleteRequest objects containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or ezcWebdavDeleteResponse on success.

This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.

Parameters
ezcWebdavDeleteRequest$request
Returns
ezcWebdavResponse
eZWebDAVContentBackend::deleteContent (   $currentSite,
  $virtualFolder,
  $target 
)
protected

Handles deletion on the content tree level.

It will try to find the node with the path $target and then try to remove it (ie. move to trash) if the user is allowed.

Parameters
string$currentSiteEg. 'plain_site_user'
string$virtualFolderEg. 'Content'
string$targetEg. 'Folder1/file1.txt'
Returns
bool

Referenced by deleteVirtualFolder().

eZWebDAVContentBackend::deleteVirtualFolder (   $currentSite,
  $target 
)
protected

Handles deletion on the virtual folder level.

It will check if the target is below a content folder in which it calls deleteContent().

Parameters
string$currentSiteEg. 'plain_site_user'
string$targetEg. 'Content/Folder1/file1.txt'
Returns
bool

Referenced by performDelete().

eZWebDAVContentBackend::encodeResponse ( ezcWebdavResponse  $response)
protected

Encodes the path stored in $response in order to be displayed properly in WebDAV clients.

Parameters
ezcWebdavResponse$response
Returns
ezcWebdavResponse
eZWebDAVContentBackend::fetchContainerNodeInfo (   $fullPath,
  $site,
  $nodeName 
)
protected

Same as fetchVirtualSiteContent(), but only one entry is returned (Content or Media).

An entry in the the returned array is of this form: array( 'name' => node name (eg. 'Group picture'), 'size' => storage size of the_node in bytes (eg. 57123), 'mimetype' => mime type of the node (eg. 'image/jpeg'), 'ctime' => creation time as timestamp, 'mtime' => latest modification time as timestamp, 'href' => the path to the node (eg. '/plain_site_user/Content/Folder1/file1.jpg')

Parameters
string$fullPathEg. '/plain_site_user/Content/Folder1'
string$siteEg. 'plain_site_user'
string$nodeNameEg. 'Folder1'
Returns
array(array(string=>mixed))

Referenced by getNodeInfo().

eZWebDAVContentBackend::fetchContentList (   $fullPath,
$node,
  $target,
  $depth,
  $properties 
)
protected

Gets and returns the content of an actual node.

List of other nodes belonging to the target node (one level below it) will be returned as well.

An entry in the the returned array is of this form: array( 'name' => node name (eg. 'Content'), 'size' => storage size of the_node in bytes (eg. 4096 for collections), 'mimetype' => mime type of the node (eg. 'httpd/unix-directory'), 'ctime' => creation time as timestamp, 'mtime' => latest modification time as timestamp, 'href' => the path to the node (eg. '/plain_site_user/Content/')

Parameters
string$fullPathEg. '/plain_site_user/Content/'
eZContentObject&$nodeThe note corresponding to $fullPath
string$targetEg. 'Content'
string$depthOne of -1 (infinite), 0, 1
array(string)$properties Currently not used
Returns
array(array(string=>mixed))

Referenced by getContentTreeCollection().

eZWebDAVContentBackend::fetchNodeByTranslation (   $nodePathString)
protected

Attempts to fetch a possible node by translating the provided string/path to a node-number.

Parameters
string$nodePathStringEg. 'Folder1/file1.txt'
Returns
eZContentObject Eg. the node of 'Folder1/file1.txt'

Referenced by copyContent(), deleteContent(), getContentNodeData(), getContentTreeCollection(), mkcolContent(), moveContent(), and putContentData().

eZWebDAVContentBackend::fetchNodeInfo (   $target,
$node 
)
protected

Gathers information about a given node specified as parameter.

The format of the returned array is: array( 'name' => node name (eg. 'Group picture'), 'size' => storage size of the_node in bytes (eg. 57123), 'mimetype' => mime type of the node (eg. 'image/jpeg'), 'ctime' => creation time as timestamp, 'mtime' => latest modification time as timestamp, 'href' => the path to the node (eg. '/plain_site_user/Content/Folder1/file1.jpg')

Parameters
string$targetEg. '/plain_site_user/Content/Folder1/file1.jpg
eZContentObject&$nodeThe node corresponding to $target
Returns
array(string=>mixed)
Todo:

remove/replace .ini calls, eZContentUpload, eZMimeType, eZSys RequestURI

handle articles as files

Referenced by fetchContentList(), and getContentNodeData().

eZWebDAVContentBackend::fetchParentNodeByTranslation (   $nodePathString)
protected

Attempts to fetch a possible node by translating the provided string/path to a node-number.

The last section of the path is removed before the actual translation: hence, the PARENT node is returned.

Parameters
string$nodePathStringEg. 'Folder1/file1.txt'
Returns
eZContentObject Eg. the node of 'Folder1'

Referenced by copyContent(), mkcolContent(), moveContent(), and putContentData().

eZWebDAVContentBackend::fetchSiteListContent (   $target,
  $depth,
  $properties 
)
protected

Builds a content-list of available sites and returns it.

An entry in the the returned array is of this form: array( 'name' => node name (eg. 'plain_site_user'), 'size' => storage size of the_node in bytes (eg. 4096 for collections), 'mimetype' => mime type of the node (eg. 'httpd/unix-directory'), 'ctime' => creation time as timestamp, 'mtime' => latest modification time as timestamp, 'href' => the path to the node (eg. '/plain_site_user/')

Parameters
string$targetEg. '/'
string$depthOne of -1 (infinite), 0, 1
array(string)$properties Currently not used
Returns
array(array(string=>mixed))

Referenced by getCollectionContent(), getCollectionMembers(), and getNodeInfo().

eZWebDAVContentBackend::fetchVirtualSiteContent (   $target,
  $site,
  $depth,
  $properties 
)
protected

Builds and returns the content of the virtual start folder for a site.

The virtual startfolder is an intermediate step between the site-list and actual content. This directory contains the "content" folder which leads to the site's actual content.

An entry in the the returned array is of this form: array( 'name' => node name (eg. 'Group picture'), 'size' => storage size of the_node in bytes (eg. 57123), 'mimetype' => mime type of the node (eg. 'image/jpeg'), 'ctime' => creation time as timestamp, 'mtime' => latest modification time as timestamp, 'href' => the path to the node (eg. '/plain_site_user/Content/Folder1/file1.jpg')

Parameters
string$targetEg. '/plain_site_user/Content/Folder1'
string$siteEg. 'plain_site_user
string$depthOne of -1 (infinite), 0, 1
array(string)$properties Currently not used
Returns
array(array(string=>mixed))

Referenced by getNodeInfo(), and getVirtualFolderCollection().

eZWebDAVContentBackend::fileBasename (   $name)
protected

Returns $name without the final suffix (.jpg, .gif etc.).

Parameters
string$name
Returns
string
Todo:
remove or replace

Referenced by copyContent(), fetchNodeByTranslation(), fetchParentNodeByTranslation(), and moveContent().

eZWebDAVContentBackend::freeLock ( )
protected

Free lock.

Frees the lock after the operation has been finished.

Referenced by copy(), delete(), get(), head(), makeCollection(), move(), propFind(), propPatch(), and put().

eZWebDAVContentBackend::get ( ezcWebdavGetRequest  $request)

Serves GET requests.

The method receives a ezcWebdavGetRequest object containing all relevant information obout the clients request and will return an ezcWebdavErrorResponse instance on error or an instance of ezcWebdavGetResourceResponse or ezcWebdavGetCollectionResponse on success, depending on the type of resource that is referenced by the request.

This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.

Parameters
ezcWebdavGetRequest$request
Returns
ezcWebdavResponse
eZWebDAVContentBackend::getAllProperties (   $path)

Returns all properties for a resource.

Returns all properties for the resource identified by $path as a ezcWebdavBasicPropertyStorage.

Parameters
string$path
Returns
ezcWebdavPropertyStorage

Referenced by getCollectionMembers(), and getNodes().

eZWebDAVContentBackend::getCollectionContent (   $collection,
  $depth = false,
  $properties = false 
)
protected

Produces the collection content.

Builds either the virtual start folder with the virtual content folder in it (and additional files). OR: if we're browsing within the content folder: it gets the content of the target/given folder.

Parameters
string$collectionEg. '/plain_site_user/Content/Folder1'
int$depthOne of -1 (infinite), 0, 1
array(string)$properties Currently not used
Returns
array(string=>array())

Referenced by getNodeInfo().

eZWebDAVContentBackend::getCollectionMembers (   $path,
  $depth = ezcWebdavRequest::DEPTH_INFINITY 
)
protected

Returns members of collection.

Returns an array with the members of the collection identified by $path. The returned array can contain ezcWebdavCollection, and ezcWebdavResource instances and might also be empty, if the collection has no members.

Added $depth.

Parameters
string$path
int$depthAdded by
Returns
array(ezcWebdavResource|ezcWebdavCollection)

Referenced by copyRecursive(), getNodes(), and moveRecursive().

eZWebDAVContentBackend::getContentNodeData (   $result,
  $currentSite,
  $virtualFolder,
  $target,
  $fullPath 
)
protected

Handles data retrival on the content tree level.

The format of the returned array is the same as $result: array( 'isFile' => bool, 'isCollection' => bool, 'file' => path to the storage file which contain the contents );

Parameters
array(string=>mixed)$result
string$currentSiteEg. 'plain_site_user'
string$virtualFolderEg. 'Content'
string$targetEg. 'Folder1/file1.txt'
string$fullPathEg. '/plain_site_user/Content/Folder1/file1.txt'
Returns
array(string=>mixed) Or false if an error appeared
Todo:
remove/replace eZContentUpload

Referenced by getVirtualFolderData().

eZWebDAVContentBackend::getContentTreeCollection (   $currentSite,
  $virtualFolder,
  $collection,
  $fullPath,
  $depth,
  $properties 
)
protected

Handles collections on the content tree level.

Depending on the virtual folder we will generate a node path url and fetch the nodes for that path.

An entry in the the returned array is of this form: array( 'name' => node name (eg. 'Folder1'), 'size' => storage size of the_node in bytes (eg. 4096 for collections), 'mimetype' => mime type of the node (eg. 'httpd/unix-directory'), 'ctime' => creation time as timestamp, 'mtime' => latest modification time as timestamp, 'href' => the path to the node (eg. '/plain_site_user/Content/Folder1/')

Parameters
string$siteEg. 'plain_site_user
string$virtualFolderEg. 'Content'
string$collectionEg. 'Folder1'
string$fullPathEg. '/plain_site_user/Content/Folder1/'
string$depthOne of -1 (infinite), 0, 1
array(string)$properties Currently not used
Returns
array(array(string=>mixed))

Referenced by getVirtualFolderCollection().

eZWebDAVContentBackend::getNodeInfo (   $requestUri,
  $source = null 
)
protected

Returns an array with information about the node with path $path.

The returned array is of this form: array( 'nodeExists' => boolean, 'isCollection' => boolean )

Parameters
string$path
Returns
array(string=>boolean)

Referenced by getNodes(), getProperty(), isCollection(), and nodeExists().

eZWebDAVContentBackend::getNodes (   $requestUri,
  $depth 
)
protected

Returns all child nodes.

Get all nodes from the resource identified by $source up to the given depth. Reuses the method getCollectionMembers(), but you may want to overwrite this implementation by somethings which fits better with your backend.

Parameters
string$source
int$depth
Returns
array(ezcWebdavResource|ezcWebdavCollection)
eZWebDAVContentBackend::getProperty (   $path,
  $propertyName,
  $namespace = 'DAV:' 
)

Returns a property of a resource.

Returns the property with the given $propertyName, from the resource identified by $path. You may optionally define a $namespace to receive the property from.

Parameters
string$path
string$propertyName
string$namespace
Returns
ezcWebdavProperty

Referenced by getAllProperties().

eZWebDAVContentBackend::getPropertyStorage (   $path)
protected

Returns the property storage for a resource.

Returns the ezcWebdavPropertyStorage instance containing the properties for the resource identified by $path.

Parameters
string$path
Returns
ezcWebdavBasicPropertyStorage

Referenced by getAllProperties(), getProperty(), and performCopy().

eZWebDAVContentBackend::getResourceContents (   $target)
protected

Returns the contents of a resource.

This method returns the content of the resource identified by $path as a string.

Parameters
string$target
Returns
string
eZWebDAVContentBackend::getVirtualFolderCollection (   $currentSite,
  $collection,
  $fullPath,
  $depth,
  $properties 
)
protected

Handles collections on the virtual folder level, if no virtual folder elements are accessed it lists the virtual folders.

An entry in the the returned array is of this form: array( 'name' => node name (eg. 'Group picture'), 'size' => storage size of the_node in bytes (eg. 57123), 'mimetype' => mime type of the node (eg. 'image/jpeg'), 'ctime' => creation time as timestamp, 'mtime' => latest modification time as timestamp, 'href' => the path to the node (eg. '/plain_site_user/Content/Folder1/file1.jpg')

Parameters
string$siteEg. 'plain_site_user
string$collectionEg. 'Folder1'
string$fullPathEg. '/plain_site_user/Content/Folder1'
string$depthOne of -1 (infinite), 0, 1
array(string)$properties Currently not used
Returns
array(array(string=>mixed))

Referenced by getCollectionContent(), and getCollectionMembers().

eZWebDAVContentBackend::getVirtualFolderData (   $result,
  $currentSite,
  $target,
  $fullPath 
)
protected

Handles data retrival on the virtual folder level.

The format of the returned array is the same as $result: array( 'isFile' => bool, 'isCollection' => bool, 'file' => path to the storage file which contain the contents );

Parameters
array(string=>mixed)$result
string$currentSiteEg. 'plain_site_user'
string$targetEg. 'Content/Folder1/file1.txt'
string$fullPathEg. '/plain_site_user/Content/Folder1/file1.txt'
Returns
array(string=>mixed) Or false if an error appeared

Referenced by getResourceContents().

eZWebDAVContentBackend::head ( ezcWebdavHeadRequest  $request)

Serves HEAD requests.

The method receives a ezcWebdavHeadRequest object containing all relevant information obout the clients request and will return an ezcWebdavErrorResponse instance on error or an instance of ezcWebdavHeadResponse on success.

This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.

Parameters
ezcWebdavHeadRequest$request
Returns
ezcWebdavResponse
eZWebDAVContentBackend::internalNodePath (   $virtualFolder,
  $collection 
)
protected

Returns a path that corresponds to the internal path of nodes.

Parameters
string$virtualFolder
string$collection
Returns
string
Todo:
remove or replace

Referenced by copyContent(), deleteContent(), getContentNodeData(), getContentTreeCollection(), mkcolContent(), moveContent(), and putContentData().

eZWebDAVContentBackend::isCollection (   $path)
protected

Returns if resource is a collection.

Returns if the resource identified by $path is a collection resource (true) or a non-collection one (false).

Parameters
string$path
Returns
bool

Referenced by copyRecursive(), and moveRecursive().

eZWebDAVContentBackend::isObjectFolder (   $object,
  $class 
)
protected

Returns whether $class is an folder class.

Parameters
resource$object
resource$class

Referenced by fetchNodeInfo(), and getContentNodeData().

eZWebDAVContentBackend::lock (   $waitTime,
  $timeout 
)

Locks the backend.

Tries to lock the backend. If the lock is already owned by this process, locking is successful. If $timeout is reached before a lock could be acquired, an ezcWebdavLockTimeoutException is thrown. Waits $waitTime microseconds between attempts to lock the backend.

Parameters
int$waitTime
int$timeout
Returns
void
eZWebDAVContentBackend::makeCollection ( ezcWebdavMakeCollectionRequest  $request)

Serves MKCOL (make collection) requests.

The method receives a ezcWebdavMakeCollectionRequest objects containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or ezcWebdavMakeCollectionResponse on success.

This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.

Parameters
ezcWebdavMakeCollectionRequest$request
Returns
ezcWebdavResponse
eZWebDAVContentBackend::mkcolContent (   $currentSite,
  $virtualFolder,
  $target 
)
protected

Handles collection creation on the content tree level.

It will try to find the parent node of the wanted placement and create a new collection (folder etc.) as a child.

Parameters
string$currentSiteEg. 'plain_site_user'
string$virtualFolderEg. 'Content'
string$targetEg. 'Folder1'
Returns
bool

Referenced by mkcolVirtualFolder().

eZWebDAVContentBackend::mkcolVirtualFolder (   $currentSite,
  $target 
)
protected

Handles collection creation on the virtual folder level.

It will check if the target is below a content folder in which it calls mkcolContent().

Parameters
string$currentSiteEg. 'plain_site_user'
string$targetEg. 'Content/Folder1'
Returns
bool

Referenced by createCollection().

eZWebDAVContentBackend::move ( ezcWebdavMoveRequest  $request)

Serves MOVE requests.

The method receives a ezcWebdavMoveRequest objects containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or ezcWebdavMoveResponse on success. If only some operations failed, this method may return an instance of ezcWebdavMultistatusResponse.

This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.

Parameters
ezcWebdavMoveRequest$request
Returns
ezcWebdavResponse
eZWebDAVContentBackend::moveContent (   $sourceSite,
  $destinationSite,
  $sourceVFolder,
  $destinationVFolder,
  $source,
  $destination,
  $fullSource,
  $fullDestination 
)
protected

Moves the node specified by the path $source to $destination.

Parameters
string$sourceSiteEg. 'plain_site_user'
string$destinationSiteEg. 'plain_site_user'
string$sourceVFolderEg. 'Content'
string$destinationVFolderEg. 'Content'
string$sourceEg. 'Folder1/file1.txt'
string$destinationEg. 'Folder2/file1.txt'
Returns
bool

Referenced by moveVirtualFolder().

eZWebDAVContentBackend::moveRecursive (   $source,
  $destination,
  $depth = ezcWebdavRequest::DEPTH_INFINITY 
)

Recursively move a file or directory.

Recursively move a file or directory in $source to the given $destination. If a $depth is given, the operation will stop as soon as the given recursion depth is reached. A depth of -1 means no limit, while a depth of 0 means, that only the current file or directory will be copied, without any recursion.

Returns an empty array if no errors occured, and an array with the files which caused errors otherwise.

Parameters
string$source
string$destination
int$depth
Returns
array

Referenced by performCopy().

eZWebDAVContentBackend::moveVirtualFolder (   $sourceSite,
  $destinationSite,
  $source,
  $destination,
  $fullSource,
  $fullDestination 
)
protected

Handles moving on the virtual folder level.

It will check if the target is below a content folder in which it calls moveContent().

Parameters
string$sourceSiteEg. 'plain_site_user'
string$destinationSiteEg. 'plain_site_user'
string$sourceEg. 'Content/Folder1/file1.txt'
string$destinationEg. 'Content/Folder2/file1.txt'
Returns
bool

Referenced by moveRecursive().

eZWebDAVContentBackend::nodeExists (   $path)
protected

Returns if a resource exists.

Returns if a the resource identified by $path exists.

Parameters
string$path
Returns
bool
eZWebDAVContentBackend::options ( ezcWebdavOptionsRequest  $request)

Required method to serve OPTIONS requests.

The method receives a ezcWebdavOptionsRequest object containing all relevant information obout the clients request and should either return an error by returning an ezcWebdavErrorResponse object, or any other ezcWebdavResponse objects.

Parameters
ezcWebdavOptionsRequest$request
Returns
ezcWebdavResponse
eZWebDAVContentBackend::performCopy (   $source,
  $destination,
  $depth = ezcWebdavRequest::DEPTH_INFINITY 
)
protected

Copies resources recursively from one path to another.

Copies the resourced identified by $fromPath recursively to $toPath with the given $depth, where $depth is one of ezcWebdavRequest::DEPTH_ZERO, ezcWebdavRequest::DEPTH_ONE, ezcWebdavRequest::DEPTH_INFINITY.

Returns an array with ezcWebdavErrorResponses for all subtrees, where the copy operation failed. Errors for subsequent resources in a subtree should be ommitted.

If an empty array is return, the operation has been completed successfully.

In case performCopy() was called from a MOVE operation, do a real move operation, because the move() function from ezcWebdavSimpleBackend calls performCopy() and performDelete().

Parameters
string$fromPath
string$toPath
int$depth
Returns
array(ezcWebdavErrorResponse)
eZWebDAVContentBackend::performDelete (   $target)
protected

Deletes everything below a path.

Deletes the resource identified by $path recursively. Returns an instance of ezcWebdavErrorResponse if the deletion failed, and null on success.

In case performDelete() was called from a MOVE operation, it does not delete anything, because the move() function in ezcWebdavSimpleBackend first calls performDelete(), which deletes the destination if the source and destination are the same in URL alias terms.

Parameters
string$path
Returns
ezcWebdavErrorResponse
eZWebDAVContentBackend::propFind ( ezcWebdavPropFindRequest  $request)

Serves PROPFIND requests.

The method receives a ezcWebdavPropFindRequest object containing all relevant information obout the clients request and will either return an instance of ezcWebdavErrorResponse to indicate an error or a ezcWebdavPropFindResponse on success. If the referenced resource is a collection or if some properties produced errors, an instance of ezcWebdavMultistatusResponse may be returned.

The ezcWebdavPropFindRequest object contains a definition to find one or more properties of a given collection or non-collection resource.

This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.

This method is an overwrite of the propFind method from ezcWebdavSimpleBackend, a hack necessary to permit correct output of eZ Publish nodes. The array of ezcWebdavPropFindResponse objects returned by ezcWebdavSimpleBackend::propFind is iterated and the paths of the nodes in the ezcWebdavPropFindResponse objects are encoded properly, in order to be displayed correctly in WebDAV clients. The encoding is from the ini setting Charset in [CharacterSettings] in i18n.ini.

Parameters
ezcWebdavPropFindRequest$request
Returns
ezcWebdavResponse
eZWebDAVContentBackend::propPatch ( ezcWebdavPropPatchRequest  $request)

Serves PROPPATCH requests.

The method receives a ezcWebdavPropPatchRequest object containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or a ezcWebdavPropPatchResponse response on success. If the referenced resource is a collection or if only some properties produced errors, an instance of ezcWebdavMultistatusResponse may be returned.

This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.

Parameters
ezcWebdavPropPatchRequest$request
Returns
ezcWebdavResponse
eZWebDAVContentBackend::put ( ezcWebdavPutRequest  $request)

Serves PUT requests.

The method receives a ezcWebdavPutRequest objects containing all relevant information obout the clients request and will return an instance of ezcWebdavErrorResponse on error or ezcWebdavPutResponse on success.

This method acquires the internal lock of the backend, dispatches to ezcWebdavSimpleBackend to perform the operation and releases the lock afterwards.

Parameters
ezcWebdavPutRequest$request
Returns
ezcWebdavResponse
eZWebDAVContentBackend::putContentData (   $currentSite,
  $virtualFolder,
  $target,
  $tempFile 
)
protected

Handles data storage on the content tree level.

It will try to find the parent node of the wanted placement and create a new object with data from $tempFile.

Parameters
string$currentSiteEg. 'plain_site_user'
string$virtualFolderEg. 'Content'
string$targetEg. 'Folder1/file1.txt'
string$tempFileThe temporary file holding the contents
Returns
bool
Todo:
remove/replace eZContentUpload

Referenced by putVirtualFolderData().

eZWebDAVContentBackend::putVirtualFolderData (   $currentSite,
  $target,
  $tempFile 
)
protected

Handles data storage on the content tree level.

It will check if the target is below a content folder in which it calls putContentData().

Parameters
string$currentSiteEg. 'plain_site_user'
string$targetEg. 'Content/Folder1/file1.txt'
string$tempFileThe temporary file holding the contents
Returns
bool

Referenced by setResourceContents().

static eZWebDAVContentBackend::recode (   $string,
  $fromCharset,
  $toCharset,
  $stop = false 
)
staticprotected

Recodes $string from charset $fromCharset to charset $toCharset.

Parameters
string$string
string$fromCharset
string$toCharset
bool$stop
Returns
string
eZWebDAVContentBackend::removeProperty (   $path,
ezcWebdavProperty  $property 
)

Manually removes a property from a resource.

Removes the given $property form the resource identified by $path.

Parameters
string$path
ezcWebdavProperty$property
Returns
bool
eZWebDAVContentBackend::resetProperties (   $path,
ezcWebdavPropertyStorage  $storage 
)

Resets the property storage for a resource.

Discards the current ezcWebdavPropertyStorage of the resource identified by $path and replaces it with the given $properties.

Parameters
string$path
ezcWebdavPropertyStorage$storage
Returns
bool
eZWebDAVContentBackend::setCurrentSite (   $site)

Sets the current site.

From eZ Publish.

Parameters
string$siteEg. 'plain_site_user'
Todo:
remove or move in another class?

Referenced by moveVirtualFolder().

eZWebDAVContentBackend::setProperty (   $path,
ezcWebdavProperty  $property 
)

Manually sets a property on a resource.

Sets the given $propertyBackup for the resource identified by $path.

Parameters
string$path
ezcWebdavProperty$property
Returns
bool
eZWebDAVContentBackend::setResourceContents (   $path,
  $content 
)
protected

Sets the contents of a resource.

This method replaces the content of the resource identified by $path with the submitted $content.

Parameters
string$path
string$content
eZWebDAVContentBackend::splitFirstPathElement (   $path,
$element 
)
protected

Takes the first path element from $path and removes it from the path, the extracted part will be placed in $name.

$path = '/path/to/item/'; $newPath = self::splitFirstPathElement( $path, $root ); print( $root ); // prints 'path', $newPath is now 'to/item/' $newPath = self::splitFirstPathElement( $newPath, $second ); print( $second ); // prints 'to', $newPath is now 'item/' $newPath = self::splitFirstPathElement( $newPath, $third ); print( $third ); // prints 'item', $newPath is now ''

Parameters
string$pathA path of elements delimited by a slash, if the path ends with a slash it will be removed
string&$elementThe name of the first path element without any slashes
Returns
string The rest of the path without the ending slash
Todo:
remove or replace

Referenced by checkDeleteRecursive(), copyRecursive(), copyVirtualFolder(), createCollection(), deleteVirtualFolder(), getCollectionContent(), getCollectionMembers(), getNodeInfo(), getResourceContents(), getVirtualFolderCollection(), getVirtualFolderData(), mkcolVirtualFolder(), moveRecursive(), moveVirtualFolder(), performDelete(), putVirtualFolderData(), and setResourceContents().

eZWebDAVContentBackend::splitLastPathElement (   $path,
$element 
)
protected

Takes the last path element from $path and removes it from the path, the extracted part will be placed in $name.

$path = '/path/to/item/'; $newPath = self::splitLastPathElement( $path, $root ); print( $root ); // prints 'item', $newPath is now '/path/to' $newPath = self::splitLastPathElement( $newPath, $second ); print( $second ); // prints 'to', $newPath is now '/path' $newPath = self::splitLastPathElement( $newPath, $third ); print( $third ); // prints 'path', $newPath is now ''

Parameters
string$pathA path of elements delimited by a slash, if the path ends with a slash it will be removed
string&$elementThe name of the first path element without any slashes
Returns
string The rest of the path without the ending slash
Todo:
remove or replace

Referenced by copyContent(), fetchParentNodeByTranslation(), and moveContent().

eZWebDAVContentBackend::storeProperties (   $path,
ezcWebdavBasicPropertyStorage  $storage 
)
protected

Stores properties for a resource.

Creates a new property storage file and stores the properties given for the resource identified by $path. This depends on the affected resource and the actual properties in the property storage.

Parameters
string$path
ezcWebdavBasicPropertyStorage$storage

Referenced by performCopy(), resetProperties(), and setProperty().

eZWebDAVContentBackend::storeUploadedFile (   $target,
  $contents 
)
protected

Stores $contents to a temporary location under the file name $target.

Parameters
string$target
string$contents
Returns
string The name of the temp file or false if it failed.
Todo:
remove or replace with eZ Components functionality

Referenced by setResourceContents().

static eZWebDAVContentBackend::tempDirectory ( )
staticprotected

Returns the path to the WebDAV temporary directory.

If the directory does not exist yet, it will be created first.

Returns
string
Todo:
remove or replace with eZ Components functionality
eZWebDAVContentBackend::unlock ( )

Removes the lock.

Returns
void
static eZWebDAVContentBackend::virtualContentFolderName ( )
static

The name of the content folder in eZ Publish, translated.

Returns
string
static eZWebDAVContentBackend::virtualMediaFolderName ( )
static

The name of the media folder in eZ Publish, translated.

Returns
string

Member Data Documentation

eZWebDAVContentBackend::$availableSites = array()
protected
eZWebDAVContentBackend::$cachedNodes = array()
protected
eZWebDAVContentBackend::$cachedProperties = array()
protected
eZWebDAVContentBackend::$FolderClasses = null
protected
eZWebDAVContentBackend::$handledLiveProperties
protected
Initial value:
= array(
'getcontentlength',
'getlastmodified',
'creationdate',
'displayname',
'getetag',
'getcontenttype',
'resourcetype',
'supportedlock',
'lockdiscovery',
)

Referenced by getCollectionMembers().

eZWebDAVContentBackend::$useLogging
staticprotected
const eZWebDAVContentBackend::DEFAULT_MIMETYPE = "application/octet-stream"

Mimetype for eZ Publish objects which don't have a mimetype.

const eZWebDAVContentBackend::DEFAULT_SIZE = 0

Default size in bytes for eZ Publish objects which don't have a size.

const eZWebDAVContentBackend::DIRECTORY_MIMETYPE = 'httpd/unix-directory'

Mimetype for directories.

const eZWebDAVContentBackend::VIRTUAL_CONTENT_FOLDER_NAME = 'Content'

The name of the content folder in eZ Publish.

const eZWebDAVContentBackend::VIRTUAL_MEDIA_FOLDER_NAME = 'Media'

The name of the media folder in eZ Publish.

const eZWebDAVContentBackend::WEBDAV_INI_FILE = "webdav.ini"

The ini file which holds settings for WebDAV.


The documentation for this class was generated from the following file: