Created
January 14, 2010 13:00
-
-
Save beberlei/277138 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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