本文整理汇总了PHP中Sabre_DAV_Server::broadcastEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_DAV_Server::broadcastEvent方法的具体用法?PHP Sabre_DAV_Server::broadcastEvent怎么用?PHP Sabre_DAV_Server::broadcastEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre_DAV_Server
的用法示例。
在下文中一共展示了Sabre_DAV_Server::broadcastEvent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAfterGetProperties
function testAfterGetProperties()
{
$properties = array('href' => 'foo', '200' => array('{DAV:}displayname' => 'foo', '{DAV:}getcontentlength' => 500), '404' => array('{DAV:}bar' => null), '403' => array('{DAV:}owner' => null));
$expected = array('href' => 'foo', '200' => array('{DAV:}displayname' => 'foo', '{DAV:}getcontentlength' => 500), '404' => array('{DAV:}bar' => null), '403' => array('{DAV:}owner' => null));
$r = $this->server->broadcastEvent('afterGetProperties', array('testdir', &$properties));
$this->assertTrue($r);
$this->assertEquals($expected, $properties);
}
示例2: unlockNode
/**
* Unlocks a uri
*
* This method removes a lock from a uri. It is assumed all the supplied information is correct and verified
*
* @param string $uri
* @param Sabre_DAV_Locks_LockInfo $lockInfo
* @return bool
*/
public function unlockNode($uri, Sabre_DAV_Locks_LockInfo $lockInfo)
{
if (!$this->server->broadcastEvent('beforeUnlock', array($uri, $lockInfo))) {
return;
}
if ($this->locksBackend) {
return $this->locksBackend->unlock($uri, $lockInfo);
}
}
示例3: testBeforeGetPropertiesNoListing
function testBeforeGetPropertiesNoListing()
{
$this->plugin->hideNodesFromListings = true;
$requestedProperties = array('{DAV:}displayname', '{DAV:}getcontentlength', '{DAV:}bar', '{DAV:}owner');
$returnedProperties = array();
$arguments = array('testdir', new Sabre_DAV_SimpleCollection('testdir'), &$requestedProperties, &$returnedProperties);
$r = $this->server->broadcastEvent('beforeGetProperties', $arguments);
$this->assertFalse($r);
}
示例4: testBrowserPostAction
function testBrowserPostAction()
{
$r = $this->server->broadcastEvent('onBrowserPostAction', array('calendars/user1', 'mkcalendar', array('name' => 'NEWCALENDAR', '{DAV:}displayname' => 'foo')));
$this->assertFalse($r);
$calendars = $this->caldavBackend->getCalendarsForUser('principals/user1');
$this->assertEquals(3, count($calendars));
$newCalendar = null;
foreach ($calendars as $calendar) {
if ($calendar['uri'] === 'NEWCALENDAR') {
$newCalendar = $calendar;
break;
}
}
if (!$newCalendar) {
$this->fail('Could not find newly created calendar');
}
}
示例5: unlockNode
/**
* Unlocks a uri
*
* This method removes a lock from a uri. It is assumed all the supplied information is correct and verified
*
* @param string $uri
* @param Sabre_DAV_Locks_LockInfo $lockInfo
* @return void
*/
public function unlockNode($uri, Sabre_DAV_Locks_LockInfo $lockInfo)
{
if (!$this->server->broadcastEvent('beforeUnlock', array($uri, $lockInfo))) {
return;
}
try {
$node = $this->server->tree->getNodeForPath($uri);
if ($node instanceof Sabre_DAV_ILockable) {
return $node->unlock($lockInfo);
}
} catch (Sabre_DAV_Exception_FileNotFound $e) {
// In case the node didn't exist, this could be a lock-null request
}
if ($this->locksBackend) {
return $this->locksBackend->unlock($uri, $lockInfo);
}
}
示例6: httpPatch
/**
* Patch an uri
*
* The WebDAV patch request can be used to modify only a part of an
* existing resource. If the resource does not exist yet and the first
* offset is not 0, the request fails
*
* @param string $uri
* @return void
*/
protected function httpPatch($uri)
{
// Get the node. Will throw a 404 if not found
$node = $this->server->tree->getNodeForPath($uri);
if (!$node instanceof Sabre_DAV_PartialUpdate_IFile) {
throw new Sabre_DAV_Exception_MethodNotAllowed('The target resource does not support the PATCH method.');
}
$range = $this->getHTTPUpdateRange();
if (!$range) {
throw new Sabre_DAV_Exception_BadRequest('No valid "X-Update-Range" found in the headers');
}
$contentType = strtolower($this->server->httpRequest->getHeader('Content-Type'));
if ($contentType != 'application/x-sabredav-partialupdate') {
throw new Sabre_DAV_Exception_UnsupportedMediaType('Unknown Content-Type header "' . $contentType . '"');
}
$len = $this->server->httpRequest->getHeader('Content-Length');
// Load the begin and end data
$start = $range[0] ? $range[0] : 0;
$end = $range[1] ? $range[1] : $len - 1;
// Check consistency
if ($end < $start) {
throw new Sabre_DAV_Exception_RequestedRangeNotSatisfiable('The end offset (' . $range[1] . ') is lower than the start offset (' . $range[0] . ')');
}
if ($end - $start + 1 != $len) {
throw new Sabre_DAV_Exception_RequestedRangeNotSatisfiable('Actual data length (' . $len . ') is not consistent with begin (' . $range[0] . ') and end (' . $range[1] . ') offsets');
}
// Checking If-None-Match and related headers.
if (!$this->server->checkPreconditions()) {
return;
}
if (!$this->server->broadcastEvent('beforeWriteContent', array($uri, $node, null))) {
return;
}
$body = $this->server->httpRequest->getBody();
$etag = $node->putRange($body, $start - 1);
$this->server->broadcastEvent('afterWriteContent', array($uri, $node));
$this->server->httpResponse->setHeader('Content-Length', '0');
if ($etag) {
$this->server->httpResponse->setHeader('ETag', $etag);
}
$this->server->httpResponse->sendStatus(204);
return false;
}
示例7: generateDirectoryIndex
/**
* Generates the html directory index for a given url
*
* @param string $path
* @return string
*/
public function generateDirectoryIndex($path)
{
$version = '';
if (Sabre_DAV_Server::$exposeVersion) {
$version = Sabre_DAV_Version::VERSION . "-" . Sabre_DAV_Version::STABILITY;
}
$html = "<html>\n<head>\n <title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . $version . "</title>\n <style type=\"text/css\">\n body { Font-family: arial}\n h1 { font-size: 150% }\n </style>\n ";
if ($this->enableAssets) {
$html .= '<link rel="shortcut icon" href="' . $this->getAssetUrl('favicon.ico') . '" type="image/vnd.microsoft.icon" />';
}
$html .= "</head>\n<body>\n <h1>Index for " . $this->escapeHTML($path) . "/</h1>\n <table>\n <tr><th width=\"24\"></th><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>\n <tr><td colspan=\"5\"><hr /></td></tr>";
$files = $this->server->getPropertiesForPath($path, array('{DAV:}displayname', '{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified'), 1);
$parent = $this->server->tree->getNodeForPath($path);
if ($path) {
list($parentUri) = Sabre_DAV_URLUtil::splitPath($path);
$fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
$icon = $this->enableAssets ? '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="Parent" /></a>' : '';
$html .= "<tr>\n <td>{$icon}</td>\n <td><a href=\"{$fullPath}\">..</a></td>\n <td>[parent]</td>\n <td></td>\n <td></td>\n </tr>";
}
foreach ($files as $file) {
// This is the current directory, we can skip it
if (rtrim($file['href'], '/') == $path) {
continue;
}
list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']);
$type = null;
if (isset($file[200]['{DAV:}resourcetype'])) {
$type = $file[200]['{DAV:}resourcetype']->getValue();
// resourcetype can have multiple values
if (!is_array($type)) {
$type = array($type);
}
foreach ($type as $k => $v) {
// Some name mapping is preferred
switch ($v) {
case '{DAV:}collection':
$type[$k] = 'Collection';
break;
case '{DAV:}principal':
$type[$k] = 'Principal';
break;
case '{urn:ietf:params:xml:ns:carddav}addressbook':
$type[$k] = 'Addressbook';
break;
case '{urn:ietf:params:xml:ns:caldav}calendar':
$type[$k] = 'Calendar';
break;
case '{urn:ietf:params:xml:ns:caldav}schedule-inbox':
$type[$k] = 'Schedule Inbox';
break;
case '{urn:ietf:params:xml:ns:caldav}schedule-outbox':
$type[$k] = 'Schedule Outbox';
break;
case '{http://calendarserver.org/ns/}calendar-proxy-read':
$type[$k] = 'Proxy-Read';
break;
case '{http://calendarserver.org/ns/}calendar-proxy-write':
$type[$k] = 'Proxy-Write';
break;
}
}
$type = implode(', ', $type);
}
// If no resourcetype was found, we attempt to use
// the contenttype property
if (!$type && isset($file[200]['{DAV:}getcontenttype'])) {
$type = $file[200]['{DAV:}getcontenttype'];
}
if (!$type) {
$type = 'Unknown';
}
$size = isset($file[200]['{DAV:}getcontentlength']) ? (int) $file[200]['{DAV:}getcontentlength'] : '';
$lastmodified = isset($file[200]['{DAV:}getlastmodified']) ? $file[200]['{DAV:}getlastmodified']->getTime()->format(DateTime::ATOM) : '';
$fullPath = Sabre_DAV_URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path ? $path . '/' : '') . $name, '/'));
$displayName = isset($file[200]['{DAV:}displayname']) ? $file[200]['{DAV:}displayname'] : $name;
$displayName = $this->escapeHTML($displayName);
$type = $this->escapeHTML($type);
$icon = '';
if ($this->enableAssets) {
$node = $this->server->tree->getNodeForPath(($path ? $path . '/' : '') . $name);
foreach (array_reverse($this->iconMap) as $class => $iconName) {
if ($node instanceof $class) {
$icon = '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl($iconName . $this->iconExtension) . '" alt="" width="24" /></a>';
break;
}
}
}
$html .= "<tr>\n <td>{$icon}</td>\n <td><a href=\"{$fullPath}\">{$displayName}</a></td>\n <td>{$type}</td>\n <td>{$size}</td>\n <td>{$lastmodified}</td>\n </tr>";
}
$html .= "<tr><td colspan=\"5\"><hr /></td></tr>";
$output = '';
if ($this->enablePost) {
$this->server->broadcastEvent('onHTMLActionsPanel', array($parent, &$output));
}
//.........这里部分代码省略.........
示例8: dav_create_server
/**
* @param bool $force_authentication
* @param bool $needs_caldav
* @param bool $needs_carddav
* @return Sabre_DAV_Server
*/
function dav_create_server($force_authentication = false, $needs_caldav = true, $needs_carddav = true)
{
$arr = array(new Sabre_DAV_SimpleCollection('principals', array(new Sabre_CalDAV_Principal_Collection(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), "principals/users"))));
if ($needs_caldav) {
$arr[] = dav_createRootCalendarNode();
}
if ($needs_carddav) {
$arr[] = dav_createRootContactsNode();
}
$tree = new Sabre_DAV_SimpleCollection('root', $arr);
// The object tree needs in turn to be passed to the server class
$server = new Sabre_DAV_Server($tree);
if (CALDAV_URL_PREFIX != "") {
$server->setBaseUri(CALDAV_URL_PREFIX);
}
$authPlugin = new Sabre_DAV_Auth_Plugin(Sabre_DAV_Auth_Backend_Std::getInstance(), DAV_APPNAME);
$server->addPlugin($authPlugin);
if ($needs_caldav) {
$caldavPlugin = new Sabre_CalDAV_Plugin();
$server->addPlugin($caldavPlugin);
}
if ($needs_carddav) {
$carddavPlugin = new Sabre_CardDAV_Plugin();
$server->addPlugin($carddavPlugin);
}
if ($GLOBALS["CALDAV_ACL_PLUGIN_CLASS"] != "") {
$aclPlugin = new $GLOBALS["CALDAV_ACL_PLUGIN_CLASS"]();
$aclPlugin->defaultUsernamePath = "principals/users";
$server->addPlugin($aclPlugin);
} else {
$aclPlugin = new Sabre_DAVACL_Plugin();
$aclPlugin->defaultUsernamePath = "principals/users";
$server->addPlugin($aclPlugin);
}
if ($force_authentication) {
$server->broadcastEvent('beforeMethod', array("GET", "/"));
}
// Make it authenticate
return $server;
}