本文整理汇总了PHP中Sabre_DAV_Server::getBaseUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_DAV_Server::getBaseUri方法的具体用法?PHP Sabre_DAV_Server::getBaseUri怎么用?PHP Sabre_DAV_Server::getBaseUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre_DAV_Server
的用法示例。
在下文中一共展示了Sabre_DAV_Server::getBaseUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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)));
}
}
示例3: 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));
}
}
示例4: generateDirectoryIndex
/**
* Generates the html directory index for a given url
*
* @param string $path
* @return string
*/
public function generateDirectoryIndex($path)
{
$html = "<html>\n<head>\n <title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . Sabre_DAV_Version::VERSION . "</title>\n <style type=\"text/css\"> body { Font-family: arial}</style>\n</head>\n<body>\n <h1>Index for " . $this->escapeHTML($path) . "/</h1>\n <table>\n <tr><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>\n <tr><td colspan=\"4\"><hr /></td></tr>";
$files = $this->server->getPropertiesForPath($path, array('{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified'), 1);
foreach ($files as $k => $file) {
// This is the current directory, we can skip it
if (rtrim($file['href'], '/') == $path) {
continue;
}
list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']);
$name = $this->escapeHTML($name);
$type = null;
if (isset($file[200]['{DAV:}resourcetype'])) {
$type = $file[200]['{DAV:}resourcetype']->getValue();
// resourcetype can have multiple values
if (is_array($type)) {
$type = implode(', ', $type);
}
// Some name mapping is preferred
switch ($type) {
case '{DAV:}collection':
$type = 'Collection';
break;
}
}
// 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';
}
$type = $this->escapeHTML($type);
$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, '/'));
$html .= "<tr>\n<td><a href=\"{$fullPath}\">{$name}</a></td>\n<td>{$type}</td>\n<td>{$size}</td>\n<td>{$lastmodified}</td>\n</tr>";
}
$html .= "<tr><td colspan=\"4\"><hr /></td></tr>";
if ($this->enablePost) {
$html .= '<tr><td><form method="post" action="">
<h3>Create new folder</h3>
<input type="hidden" name="action" value="mkcol" />
Name: <input type="text" name="name" /><br />
<input type="submit" value="create" />
</form>
<form method="post" action="" enctype="multipart/form-data">
<h3>Upload file</h3>
<input type="hidden" name="action" value="put" />
Name (optional): <input type="text" name="name" /><br />
File: <input type="file" name="file" /><br />
<input type="submit" value="upload" />
</form>
</td></tr>';
}
$html .= "</table>\n <address>Generated by SabreDAV " . Sabre_DAV_Version::VERSION . "-" . Sabre_DAV_Version::STABILITY . " (c)2007-2010 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address>\n</body>\n</html>";
return $html;
}
示例5: afterGetProperties
/**
* afterGetProperties
*
* This method handler is invoked after properties for a specific resource
* are received. This allows us to add any properties that might have been
* missing.
*
* @param string $path
* @param array $properties
* @return void
*/
public function afterGetProperties($path, &$properties)
{
// Find out if we are currently looking at a principal resource
$currentNode = $this->server->tree->getNodeForPath($path);
if ($currentNode instanceof Sabre_DAVACL_IPrincipal) {
// calendar-home-set property
$calHome = '{' . self::NS_CALDAV . '}calendar-home-set';
if (array_key_exists($calHome, $properties[404])) {
$principalId = $currentNode->getName();
$calendarHomePath = self::CALENDAR_ROOT . '/' . $principalId . '/';
unset($properties[404][$calHome]);
$properties[200][$calHome] = new Sabre_DAV_Property_Href($calendarHomePath);
}
// calendar-user-address-set property
$calProp = '{' . self::NS_CALDAV . '}calendar-user-address-set';
if (array_key_exists($calProp, $properties[404])) {
$addresses = $currentNode->getAlternateUriSet();
$addresses[] = $this->server->getBaseUri() . $currentNode->getPrincipalUrl();
$properties[200][$calProp] = new Sabre_DAV_Property_HrefList($addresses, false);
unset($properties[404][$calProp]);
}
// These two properties are shortcuts for ical to easily find
// other principals this principal has access to.
$propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for';
$propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for';
if (array_key_exists($propRead, $properties[404]) || array_key_exists($propWrite, $properties[404])) {
$membership = $currentNode->getGroupMembership();
$readList = array();
$writeList = array();
foreach ($membership as $group) {
$groupNode = $this->server->tree->getNodeForPath($group);
// If the node is either ap proxy-read or proxy-write
// group, we grab the parent principal and add it to the
// list.
if ($groupNode instanceof Sabre_CalDAV_Principal_ProxyRead) {
list($readList[]) = Sabre_DAV_URLUtil::splitPath($group);
}
if ($groupNode instanceof Sabre_CalDAV_Principal_ProxyWrite) {
list($writeList[]) = Sabre_DAV_URLUtil::splitPath($group);
}
}
if (array_key_exists($propRead, $properties[404])) {
unset($properties[404][$propRead]);
$properties[200][$propRead] = new Sabre_DAV_Property_HrefList($readList);
}
if (array_key_exists($propWrite, $properties[404])) {
unset($properties[404][$propWrite]);
$properties[200][$propWrite] = new Sabre_DAV_Property_HrefList($writeList);
}
}
}
}
示例6: generateDirectoryIndex
/**
* Generates the html directory index for a given url
*
* @param string $path
* @return string
*/
public function generateDirectoryIndex($path)
{
ob_start();
echo "<html>\n<head>\n <title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . Sabre_DAV_Version::VERSION . "</title>\n <style type=\"text/css\"> body { Font-family: arial}</style>\n</head>\n<body>\n <h1>Index for " . $this->escapeHTML($path) . "/</h1>\n <table>\n <tr><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>\n <tr><td colspan=\"4\"><hr /></td></tr>";
$files = $this->server->getPropertiesForPath($path, array('{DAV:}resourcetype', '{DAV:}getcontenttype', '{DAV:}getcontentlength', '{DAV:}getlastmodified'), 1);
foreach ($files as $k => $file) {
// This is the current directory, we can skip it
if ($file['href'] == $path) {
continue;
}
$name = $this->escapeHTML(basename($file['href']));
if (isset($file[200]['{DAV:}resourcetype'])) {
$type = $file[200]['{DAV:}resourcetype']->getValue();
if ($type == '{DAV:}collection') {
$type = 'Directory';
} elseif ($type == '') {
if (isset($file[200]['{DAV:}getcontenttype'])) {
$type = $file[200]['{DAV:}getcontenttype'];
} else {
$type = 'Unknown';
}
} elseif (is_array($type)) {
$type = implode(', ', $type);
}
}
$type = $this->escapeHTML($type);
$size = isset($file[200]['{DAV:}getcontentlength']) ? (int) $file[200]['{DAV:}getcontentlength'] : '';
$lastmodified = isset($file[200]['{DAV:}getlastmodified']) ? date(DATE_ATOM, $file[200]['{DAV:}getlastmodified']->getTime()) : '';
$fullPath = '/' . trim($this->server->getBaseUri() . ($path ? $this->escapeHTML($path) . '/' : '') . $name, '/');
echo "<tr>\n<td><a href=\"{$fullPath}\">{$name}</a></td>\n<td>{$type}</td>\n<td>{$size}</td>\n<td>{$lastmodified}</td>\n</tr>";
}
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
if ($this->enablePost) {
echo '<tr><td><form method="post" action="">
<h3>Create new folder</h3>
<input type="hidden" name="action" value="mkcol" />
Name: <input type="text" name="name" /><br />
<input type="submit" value="create" />
</form>
<form method="post" action="" enctype="multipart/form-data">
<h3>Upload file</h3>
<input type="hidden" name="action" value="put" />
Name (optional): <input type="text" name="name" /><br />
File: <input type="file" name="file" /><br />
<input type="submit" value="upload" />
</form>
</td></tr>';
}
echo "</table>\n <address>Generated by SabreDAV " . Sabre_DAV_Version::VERSION . "-" . Sabre_DAV_Version::STABILITY . " (c)2007-2010 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address>\n</body>\n</html>";
return ob_get_clean();
}
示例7: serialize
/**
* Adds in extra information in the xml response.
*
* This method adds the {DAV:}need-privileges element as defined in rfc3744
*
* @param Sabre_DAV_Server $server
* @param DOMElement $errorNode
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $errorNode)
{
$doc = $errorNode->ownerDocument;
$np = $doc->createElementNS('DAV:', 'd:need-privileges');
$errorNode->appendChild($np);
foreach ($this->privileges as $privilege) {
$resource = $doc->createElementNS('DAV:', 'd:resource');
$np->appendChild($resource);
$resource->appendChild($doc->createElementNS('DAV:', 'd:href', $server->getBaseUri() . $this->uri));
$priv = $doc->createElementNS('DAV:', 'd:privilege');
$resource->appendChild($priv);
preg_match('/^{([^}]*)}(.*)$/', $privilege, $privilegeParts);
$priv->appendChild($doc->createElementNS($privilegeParts[1], 'd:' . $privilegeParts[2]));
}
}
示例8: getAssetUrl
/**
* This method takes a path/name of an asset and turns it into url
* suiteable for http access.
*
* @param string $assetName
* @return string
*/
protected function getAssetUrl($assetName)
{
return $this->server->getBaseUri() . '?sabreAction=asset&assetName=' . urlencode($assetName);
}
示例9: beforeGetProperties
/**
* beforeGetProperties
*
* This method handler is invoked before any after properties for a
* resource are fetched. This allows us to add in any CalDAV specific
* properties.
*
* @param string $path
* @param Sabre_DAV_INode $node
* @param array $requestedProperties
* @param array $returnedProperties
* @return void
*/
public function beforeGetProperties($path, Sabre_DAV_INode $node, &$requestedProperties, &$returnedProperties)
{
if ($node instanceof Sabre_DAVACL_IPrincipal) {
// calendar-home-set property
$calHome = '{' . self::NS_CALDAV . '}calendar-home-set';
if (in_array($calHome, $requestedProperties)) {
$principalId = $node->getName();
$calendarHomePath = self::CALENDAR_ROOT . '/' . $principalId . '/';
unset($requestedProperties[$calHome]);
$returnedProperties[200][$calHome] = new Sabre_DAV_Property_Href($calendarHomePath);
}
// schedule-outbox-URL property
$scheduleProp = '{' . self::NS_CALDAV . '}schedule-outbox-URL';
if (in_array($scheduleProp, $requestedProperties)) {
$principalId = $node->getName();
$outboxPath = self::CALENDAR_ROOT . '/' . $principalId . '/outbox';
unset($requestedProperties[$scheduleProp]);
$returnedProperties[200][$scheduleProp] = new Sabre_DAV_Property_Href($outboxPath);
}
// calendar-user-address-set property
$calProp = '{' . self::NS_CALDAV . '}calendar-user-address-set';
if (in_array($calProp, $requestedProperties)) {
$addresses = $node->getAlternateUriSet();
$addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl();
unset($requestedProperties[$calProp]);
$returnedProperties[200][$calProp] = new Sabre_DAV_Property_HrefList($addresses, false);
}
// These two properties are shortcuts for ical to easily find
// other principals this principal has access to.
$propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for';
$propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for';
if (in_array($propRead, $requestedProperties) || in_array($propWrite, $requestedProperties)) {
$membership = $node->getGroupMembership();
$readList = array();
$writeList = array();
foreach ($membership as $group) {
$groupNode = $this->server->tree->getNodeForPath($group);
// If the node is either ap proxy-read or proxy-write
// group, we grab the parent principal and add it to the
// list.
if ($groupNode instanceof Sabre_CalDAV_Principal_ProxyRead) {
list($readList[]) = Sabre_DAV_URLUtil::splitPath($group);
}
if ($groupNode instanceof Sabre_CalDAV_Principal_ProxyWrite) {
list($writeList[]) = Sabre_DAV_URLUtil::splitPath($group);
}
}
if (in_array($propRead, $requestedProperties)) {
unset($requestedProperties[$propRead]);
$returnedProperties[200][$propRead] = new Sabre_DAV_Property_HrefList($readList);
}
if (in_array($propWrite, $requestedProperties)) {
unset($requestedProperties[$propWrite]);
$returnedProperties[200][$propWrite] = new Sabre_DAV_Property_HrefList($writeList);
}
}
}
// instanceof IPrincipal
if ($node instanceof Sabre_CalDAV_ICalendarObject) {
// The calendar-data property is not supposed to be a 'real'
// property, but in large chunks of the spec it does act as such.
// Therefore we simply expose it as a property.
$calDataProp = '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data';
if (in_array($calDataProp, $requestedProperties)) {
unset($requestedProperties[$calDataProp]);
$val = $node->get();
if (is_resource($val)) {
$val = stream_get_contents($val);
}
// Taking out \r to not screw up the xml output
$returnedProperties[200][$calDataProp] = str_replace("\r", "", $val);
}
}
}
示例10: serializeAce
/**
* Serializes a single access control entry.
*
* @param DOMDocument $doc
* @param DOMElement $node
* @param array $ace
* @param Sabre_DAV_Server $server
* @return void
*/
private function serializeAce($doc, $node, $ace, $server)
{
$xace = $doc->createElementNS('DAV:', 'd:ace');
$node->appendChild($xace);
$principal = $doc->createElementNS('DAV:', 'd:principal');
$xace->appendChild($principal);
$principal->appendChild($doc->createElementNS('DAV:', 'd:href', ($this->prefixBaseUrl ? $server->getBaseUri() : '') . $ace['principal'] . '/'));
$grant = $doc->createElementNS('DAV:', 'd:grant');
$xace->appendChild($grant);
$privParts = null;
preg_match('/^{([^}]*)}(.*)$/', $ace['privilege'], $privParts);
$xprivilege = $doc->createElementNS('DAV:', 'd:privilege');
$grant->appendChild($xprivilege);
$xprivilege->appendChild($doc->createElementNS($privParts[1], 'd:' . $privParts[2]));
if (isset($ace['protected']) && $ace['protected']) {
$xace->appendChild($doc->createElement('d:protected'));
}
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:27,代码来源:owncloud_3rdparty_Sabre_DAVACL_Property_Acl.php
示例11: 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->createElementNS('DAV:', 'd:response');
$dom->appendChild($xresponse);
$uri = explode('/', rtrim($this->href, '/'));
// Decoding the uri part-by-part, for instance to make sure we got spaces, and not %20
foreach ($uri as $k => $item) {
$uri[$k] = rawurlencode($item);
}
$uri = implode('/', $uri);
// TODO: we need a better way to do this
if ($uri != '' && isset($properties[200]['{DAV:}resourcetype']) && $properties[200]['{DAV:}resourcetype']->getValue() == '{DAV:}collection') {
$uri .= '/';
}
// Adding the baseurl to the beginning of the url
$uri = $server->getBaseUri() . $uri;
$xresponse->appendChild($document->createElementNS('DAV:', '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->createElementNS('DAV:', 'd:propstat');
$xresponse->appendChild($xpropstat);
$xprop = $document->createElementNS('DAV:', '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)) {
$currentProperty->nodeValue = htmlentities($propertyValue);
} elseif ($propertyValue instanceof Sabre_DAV_Property) {
$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->createElementNS('DAV:', 'd:status', $server->httpResponse->getStatusMessage($httpStatus)));
}
}
示例12: 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)
{
$elem = $dom->ownerDocument->createElementNS('DAV:', 'd:href');
$elem->nodeValue = $server->getBaseUri() . $this->href;
$dom->appendChild($elem);
}
示例13: serialize
/**
* Serializes the property into a DOMElement.
*
* @param Sabre_DAV_Server $server
* @param DOMElement $node
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $node)
{
$prefix = $server->xmlNamespaces['DAV:'];
switch ($this->type) {
case self::UNAUTHENTICATED:
$node->appendChild($node->ownerDocument->createElement($prefix . ':unauthenticated'));
break;
case self::AUTHENTICATED:
$node->appendChild($node->ownerDocument->createElement($prefix . ':authenticated'));
break;
case self::HREF:
$href = $node->ownerDocument->createElement($prefix . ':href');
$href->nodeValue = $server->getBaseUri() . $this->href;
$node->appendChild($href);
break;
}
}
示例14: serializeBody
/**
* This method serializes the entire notification, as it is used in the
* response body.
*
* @param Sabre_DAV_Server $server
* @param DOMElement $node
* @return void
*/
public function serializeBody(Sabre_DAV_Server $server, \DOMElement $node)
{
$doc = $node->ownerDocument;
$dt = $doc->createElement('cs:dtstamp');
$this->dtStamp->setTimezone(new \DateTimezone('GMT'));
$dt->appendChild($doc->createTextNode($this->dtStamp->format('Ymd\\THis\\Z')));
$node->appendChild($dt);
$prop = $doc->createElement('cs:invite-notification');
$node->appendChild($prop);
$uid = $doc->createElement('cs:uid');
$uid->appendChild($doc->createTextNode($this->id));
$prop->appendChild($uid);
$href = $doc->createElement('d:href');
$href->appendChild($doc->createTextNode($this->href));
$prop->appendChild($href);
$nodeName = null;
switch ($this->type) {
case SharingPlugin::STATUS_ACCEPTED:
$nodeName = 'cs:invite-accepted';
break;
case SharingPlugin::STATUS_DECLINED:
$nodeName = 'cs:invite-declined';
break;
case SharingPlugin::STATUS_DELETED:
$nodeName = 'cs:invite-deleted';
break;
case SharingPlugin::STATUS_NORESPONSE:
$nodeName = 'cs:invite-noresponse';
break;
}
$prop->appendChild($doc->createElement($nodeName));
$hostHref = $doc->createElement('d:href', $server->getBaseUri() . $this->hostUrl);
$hostUrl = $doc->createElement('cs:hosturl');
$hostUrl->appendChild($hostHref);
$prop->appendChild($hostUrl);
$access = $doc->createElement('cs:access');
if ($this->readOnly) {
$access->appendChild($doc->createElement('cs:read'));
} else {
$access->appendChild($doc->createElement('cs:read-write'));
}
$prop->appendChild($access);
$organizerHref = $doc->createElement('d:href', $server->getBaseUri() . $this->organizer);
$organizerUrl = $doc->createElement('cs:organizer');
if ($this->commonName) {
$commonName = $doc->createElement('cs:common-name');
$commonName->appendChild($doc->createTextNode($this->commonName));
$organizerUrl->appendChild($commonName);
}
$organizerUrl->appendChild($organizerHref);
$prop->appendChild($organizerUrl);
if ($this->summary) {
$summary = $doc->createElement('cs:summary');
$summary->appendChild($doc->createTextNode($this->summary));
$prop->appendChild($summary);
}
if ($this->supportedComponents) {
$xcomp = $doc->createElement('cal:supported-calendar-component-set');
$this->supportedComponents->serialize($server, $xcomp);
$prop->appendChild($xcomp);
}
}
示例15: serializeBody
/**
* This method serializes the entire notification, as it is used in the
* response body.
*
* @param Sabre_DAV_Server $server
* @param DOMElement $node
* @return void
*/
public function serializeBody(Sabre_DAV_Server $server, \DOMElement $node)
{
$doc = $node->ownerDocument;
$dt = $doc->createElement('cs:dtstamp');
$this->dtStamp->setTimezone(new \DateTimezone('GMT'));
$dt->appendChild($doc->createTextNode($this->dtStamp->format('Ymd\\THis\\Z')));
$node->appendChild($dt);
$prop = $doc->createElement('cs:invite-reply');
$node->appendChild($prop);
$uid = $doc->createElement('cs:uid');
$uid->appendChild($doc->createTextNode($this->id));
$prop->appendChild($uid);
$inReplyTo = $doc->createElement('cs:in-reply-to');
$inReplyTo->appendChild($doc->createTextNode($this->inReplyTo));
$prop->appendChild($inReplyTo);
$href = $doc->createElement('d:href');
$href->appendChild($doc->createTextNode($this->href));
$prop->appendChild($href);
$nodeName = null;
switch ($this->type) {
case SharingPlugin::STATUS_ACCEPTED:
$nodeName = 'cs:invite-accepted';
break;
case SharingPlugin::STATUS_DECLINED:
$nodeName = 'cs:invite-declined';
break;
}
$prop->appendChild($doc->createElement($nodeName));
$hostHref = $doc->createElement('d:href', $server->getBaseUri() . $this->hostUrl);
$hostUrl = $doc->createElement('cs:hosturl');
$hostUrl->appendChild($hostHref);
$prop->appendChild($hostUrl);
if ($this->summary) {
$summary = $doc->createElement('cs:summary');
$summary->appendChild($doc->createTextNode($this->summary));
$prop->appendChild($summary);
}
}