Skip to content

Instantly share code, notes, and snippets.

@beberlei
Created January 14, 2010 13:00
Show Gist options
  • Save beberlei/277138 to your computer and use it in GitHub Desktop.
Save beberlei/277138 to your computer and use it in GitHub Desktop.
abstract class Whitewashing_Webdav_SimplerBackend extends ezcWebdavSimpleBackend
{
protected $liveProperties = array(
'getcontentlength',
'getlastmodified',
'creationdate',
'displayname',
'getetag',
'getcontenttype',
'resourcetype',
'supportedlock',
'lockdiscovery',
);
public function getAllProperties($path) {
$storage = new ezcWebdavFlaggedPropertyStorage;
foreach ($this->liveProperties AS $propertyName) {
$storage->attach($this->getProperty($path, $propertyName));
}
return $storage;
}
public function getProperty($path, $propertyName, $namespace = 'DAV:') {
// Handle live properties
switch ( $propertyName )
{
case 'getcontentlength':
$property = new ezcWebdavGetContentLengthProperty();
$property->length = $this->getContentLength( $path );
return $property;
case 'getlastmodified':
$property = new ezcWebdavGetLastModifiedProperty();
$property->date = $this->getLastModifiedDate( $path );
return $property;
case 'creationdate':
$property = new ezcWebdavCreationDateProperty();
$property->date = $this->getCreationDate( $path );
return $property;
case 'displayname':
$property = new ezcWebdavDisplayNameProperty();
$property->displayName = $this->getDisplayName( $path );
return $property;
case 'getcontenttype':
$property = new ezcWebdavGetContentTypeProperty( $this->getContentType( $path ) );
return $property;
case 'getetag':
$property = new ezcWebdavGetEtagProperty();
$property->etag = $this->getETag( $path );
return $property;
case 'resourcetype':
$property = new ezcWebdavResourceTypeProperty();
$property->type = $this->isCollection( $path ) ?
ezcWebdavResourceTypeProperty::TYPE_COLLECTION :
ezcWebdavResourceTypeProperty::TYPE_RESOURCE;
return $property;
case 'supportedlock':
$property = new ezcWebdavSupportedLockProperty();
return $property;
case 'lockdiscovery':
$property = new ezcWebdavLockDiscoveryProperty();
return $property;
default:
// Handle all other live properties like dead properties
throw new Exception("Unknown Property requested!");
}
}
abstract protected function getContentLength( $path );
abstract protected function getLastModifiedDate( $path );
abstract protected function getCreationDate( $path );
abstract protected function getDisplayName( $path );
abstract protected function getContentType( $path );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment