本文整理汇总了PHP中Sabre_DAV_Server类的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_DAV_Server类的具体用法?PHP Sabre_DAV_Server怎么用?PHP Sabre_DAV_Server使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sabre_DAV_Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serialize
/**
* serialize
*
* @param DOMElement $prop
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $prop)
{
$doc = $prop->ownerDocument;
foreach ($this->locks as $lock) {
$activeLock = $doc->createElementNS('DAV:', 'd:activelock');
$prop->appendChild($activeLock);
$lockScope = $doc->createElementNS('DAV:', 'd:lockscope');
$activeLock->appendChild($lockScope);
$lockScope->appendChild($doc->createElementNS('DAV:', 'd:' . ($lock->scope == Sabre_DAV_Locks_LockInfo::EXCLUSIVE ? 'exclusive' : 'shared')));
$lockType = $doc->createElementNS('DAV:', 'd:locktype');
$activeLock->appendChild($lockType);
$lockType->appendChild($doc->createElementNS('DAV:', 'd:write'));
/* {DAV:}lockroot */
if (!self::$hideLockRoot) {
$lockRoot = $doc->createElementNS('DAV:', 'd:lockroot');
$activeLock->appendChild($lockRoot);
$href = $doc->createElementNS('DAV:', 'd:href');
$href->appendChild($doc->createTextNode($server->getBaseUri() . $lock->uri));
$lockRoot->appendChild($href);
}
$activeLock->appendChild($doc->createElementNS('DAV:', 'd:depth', $lock->depth == Sabre_DAV_Server::DEPTH_INFINITY ? 'infinity' : $lock->depth));
$activeLock->appendChild($doc->createElementNS('DAV:', 'd:timeout', 'Second-' . $lock->timeout));
if ($this->revealLockToken) {
$lockToken = $doc->createElementNS('DAV:', 'd:locktoken');
$activeLock->appendChild($lockToken);
$lockToken->appendChild($doc->createElementNS('DAV:', 'd:href', 'opaquelocktoken:' . $lock->token));
}
$activeLock->appendChild($doc->createElementNS('DAV:', 'd:owner', $lock->owner));
}
}
示例2: testBrief
function testBrief()
{
$httpRequest = new Sabre_HTTP_Request(array('HTTP_BRIEF' => 't'));
$server = new Sabre_DAV_Server();
$server->httpRequest = $httpRequest;
$this->assertEquals(array('strict' => false, 'lenient' => false, 'wait' => null, 'return-asynch' => false, 'return-minimal' => true, 'return-representation' => false), $server->getHTTPPrefer());
}
示例3: serialize
/**
* serialize
*
* @param Sabre_DAV_Server $server
* @param DOMElement $dom
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $dom)
{
$document = $dom->ownerDocument;
$properties = $this->responseProperties;
$xresponse = $document->createElement('d:response');
$dom->appendChild($xresponse);
$uri = Sabre_DAV_URLUtil::encodePath($this->href);
// Adding the baseurl to the beginning of the url
$uri = $server->getBaseUri() . $uri;
$xresponse->appendChild($document->createElement('d:href', $uri));
// The properties variable is an array containing properties, grouped by
// HTTP status
foreach ($properties as $httpStatus => $propertyGroup) {
// The 'href' is also in this array, and it's special cased.
// We will ignore it
if ($httpStatus == 'href') {
continue;
}
// If there are no properties in this group, we can also just carry on
if (!count($propertyGroup)) {
continue;
}
$xpropstat = $document->createElement('d:propstat');
$xresponse->appendChild($xpropstat);
$xprop = $document->createElement('d:prop');
$xpropstat->appendChild($xprop);
$nsList = $server->xmlNamespaces;
foreach ($propertyGroup as $propertyName => $propertyValue) {
$propName = null;
preg_match('/^{([^}]*)}(.*)$/', $propertyName, $propName);
// special case for empty namespaces
if ($propName[1] == '') {
$currentProperty = $document->createElement($propName[2]);
$xprop->appendChild($currentProperty);
$currentProperty->setAttribute('xmlns', '');
} else {
if (!isset($nsList[$propName[1]])) {
$nsList[$propName[1]] = 'x' . count($nsList);
}
// If the namespace was defined in the top-level xml namespaces, it means
// there was already a namespace declaration, and we don't have to worry about it.
if (isset($server->xmlNamespaces[$propName[1]])) {
$currentProperty = $document->createElement($nsList[$propName[1]] . ':' . $propName[2]);
} else {
$currentProperty = $document->createElementNS($propName[1], $nsList[$propName[1]] . ':' . $propName[2]);
}
$xprop->appendChild($currentProperty);
}
if (is_scalar($propertyValue)) {
$text = $document->createTextNode($propertyValue);
$currentProperty->appendChild($text);
} elseif ($propertyValue instanceof Sabre_DAV_PropertyInterface) {
$propertyValue->serialize($server, $currentProperty);
} elseif (!is_null($propertyValue)) {
throw new Sabre_DAV_Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName);
}
}
$xpropstat->appendChild($document->createElement('d:status', $server->httpResponse->getStatusMessage($httpStatus)));
}
}
示例4: serialize
/**
* Serializes this property.
*
* It will additionally prepend the href property with the server's base uri.
*
* @param Sabre_DAV_Server $server
* @param DOMElement $dom
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $dom)
{
$prefix = $server->xmlNamespaces['DAV:'];
$elem = $dom->ownerDocument->createElement($prefix . ':href');
$elem->nodeValue = ($this->autoPrefix ? $server->getBaseUri() : '') . $this->href;
$dom->appendChild($elem);
}
示例5: testLockEtc
function testLockEtc()
{
mkdir(SABRE_TEMPDIR . '/mstest');
$tree = new Sabre_DAV_FS_Directory(SABRE_TEMPDIR . '/mstest');
$server = new Sabre_DAV_Server($tree);
$server->debugExceptions = true;
$locksBackend = new Sabre_DAV_Locks_Backend_File(SABRE_TEMPDIR . '/locksdb');
$locksPlugin = new Sabre_DAV_Locks_Plugin($locksBackend);
$server->addPlugin($locksPlugin);
$response1 = new Sabre_HTTP_ResponseMock();
$server->httpRequest = $this->getLockRequest();
$server->httpResponse = $response1;
$server->exec();
$this->assertEquals('HTTP/1.1 201 Created', $server->httpResponse->status);
$this->assertTrue(isset($server->httpResponse->headers['Lock-Token']));
$lockToken = $server->httpResponse->headers['Lock-Token'];
//sleep(10);
$response2 = new Sabre_HTTP_ResponseMock();
$server->httpRequest = $this->getLockRequest2();
$server->httpResponse = $response2;
$server->exec();
$this->assertEquals('HTTP/1.1 201 Created', $server->httpResponse->status);
$this->assertTrue(isset($server->httpResponse->headers['Lock-Token']));
//sleep(10);
$response3 = new Sabre_HTTP_ResponseMock();
$server->httpRequest = $this->getPutRequest($lockToken);
$server->httpResponse = $response3;
$server->exec();
$this->assertEquals('HTTP/1.1 204 No Content', $server->httpResponse->status);
}
示例6: testBeforeMethodNoExport
function testBeforeMethodNoExport()
{
$p = new Sabre_CalDAV_ICSExportPlugin();
$s = new Sabre_DAV_Server();
$s->addPlugin($p);
$this->assertNull($p->beforeMethod('GET', 'UUID-123467'));
}
示例7: indexAction
public function indexAction()
{
// Set the root directory
$webdavPath = Phprojekt::getInstance()->getConfig()->webdavPath;
if (Phprojekt_Auth::isLoggedIn()) {
$project = new Project_Models_Project();
$project = $project->find(1);
$rootDirectory = new WebDAV_Models_ProjectDirectory($project);
} else {
// Some clients seem to send some queries without http auth. We need the dummy to serve those.
$rootDirectory = new WebDAV_Models_EmptyDir();
}
// The server object is responsible for making sense out of the WebDAV protocol
$server = new Sabre_DAV_Server($rootDirectory);
$server->setBaseUri($this->view->baseUrl('index.php/WebDAV/index/index/'));
// The lock manager is reponsible for making sure users don't overwrite each others changes.
// Change 'data' to a different directory, if you're storing your data somewhere else.
$lockBackend = new Sabre_DAV_Locks_Backend_File($webdavPath . 'data/locks');
$lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);
$server->addPlugin($lockPlugin);
// Authentication
$authBackend = new WebDAV_Helper_Auth();
$authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'WebDAV');
$server->addPlugin($authPlugin);
// All we need to do now, is to fire up the server
$server->exec();
}
示例8: testGetCurrentUserPrincipal
/**
* @depends testInit
*/
function testGetCurrentUserPrincipal()
{
$fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')));
$plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'realm');
$fakeServer->addPlugin($plugin);
$fakeServer->broadCastEvent('beforeMethod', array('GET', '/'));
$this->assertEquals('admin', $plugin->getCurrentUser());
}
示例9: initialize
/**
* Initializes the plugin
*
* @param Sabre_DAV_Server $server
* @return void
*/
public function initialize(Sabre_DAV_Server $server)
{
$this->server = $server;
$server->subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties'));
$server->xmlNamespaces[Sabre_CalDAV_Plugin::NS_CALDAV] = 'cal';
$server->resourceTypeMapping['Sabre_CalDAV_ICalendar'] = '{urn:ietf:params:xml:ns:caldav}calendar';
array_push($server->protectedProperties, '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}schedule-calendar-transp', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}schedule-default-calendar-URL', '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}schedule-tag');
}
示例10: initialize
/**
* This initializes the plugin.
*
* This function is called by Sabre_DAV_Server, after
* addPlugin is called.
*
* This method should set up the required event subscriptions.
*
* @param Sabre_DAV_Server $server
* @return void
*/
public function initialize(Sabre_DAV_Server $server)
{
$server->xmlNamespaces[self::NS_OWNCLOUD] = 'oc';
$server->protectedProperties[] = '{' . self::NS_OWNCLOUD . '}id';
$this->server = $server;
$this->server->subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties'));
$this->server->subscribeEvent('afterCreateFile', array($this, 'sendFileIdHeader'));
$this->server->subscribeEvent('afterWriteContent', array($this, 'sendFileIdHeader'));
}
示例11: testResourceType
function testResourceType()
{
$tree = array(new Sabre_CardDAV_DirectoryMock('directory'));
$server = new Sabre_DAV_Server($tree);
$plugin = new Sabre_CardDAV_Plugin();
$server->addPlugin($plugin);
$props = $server->getProperties('directory', array('{DAV:}resourcetype'));
$this->assertTrue($props['{DAV:}resourcetype']->is('{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}directory'));
}
示例12: testSetBadNode
public function testSetBadNode()
{
$tree = array(new Sabre_DAV_SimpleCollection('foo'));
$server = new Sabre_DAV_Server($tree);
$server->addPlugin(new Sabre_DAVACL_Plugin());
$result = $server->updateProperties('foo', array('{DAV:}group-member-set' => new Sabre_DAV_Property_HrefList(array('bar', 'baz')), '{DAV:}bar' => 'baz'));
$expected = array('href' => 'foo', '403' => array('{DAV:}group-member-set' => null), '424' => array('{DAV:}bar' => null));
$this->assertEquals($expected, $result);
}
示例13: testUpdatePropertiesEventSuccess
function testUpdatePropertiesEventSuccess()
{
$tree = array(new Sabre_DAV_SimpleDirectory('foo'));
$server = new Sabre_DAV_Server($tree);
$server->subscribeEvent('updateProperties', array($this, 'updatepropsuccess'));
$result = $server->updateProperties('foo', array('{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla'));
$expected = array('href' => 'foo', '200' => array('{DAV:}foo' => null), '201' => array('{DAV:}foo2' => null));
$this->assertEquals($expected, $result);
}
示例14: setUp
function setUp()
{
$this->backend = new Sabre_CardDAV_Backend_Mock();
$principalBackend = new Sabre_DAVACL_MockPrincipalBackend();
$tree = array(new Sabre_CardDAV_AddressBookRoot($principalBackend, $this->backend), new Sabre_DAVACL_PrincipalCollection($principalBackend));
$this->plugin = new Sabre_CardDAV_Plugin();
$this->plugin->directories = array('directory');
$this->server = new Sabre_DAV_Server($tree);
$this->server->addPlugin($this->plugin);
$this->server->debugExceptions = true;
}
示例15: testReportPassThrough
function testReportPassThrough()
{
$fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')));
$plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'realm');
$fakeServer->addPlugin($plugin);
$request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/'));
$request->setBody('<?xml version="1.0"?><s:somereport xmlns:s="http://www.rooftopsolutions.nl/NS/example" />');
$fakeServer->httpRequest = $request;
$fakeServer->httpResponse = new Sabre_HTTP_ResponseMock();
$fakeServer->exec();
$this->assertEquals('HTTP/1.1 501 Not Implemented', $fakeServer->httpResponse->status);
}