本文整理汇总了PHP中Sabre\DAV\URLUtil类的典型用法代码示例。如果您正苦于以下问题:PHP URLUtil类的具体用法?PHP URLUtil怎么用?PHP URLUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了URLUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkQuota
/**
* This method is called before any HTTP method and validates there is enough free space to store the file
*
* @param string $uri
* @param null $data
* @throws \Sabre\DAV\Exception\InsufficientStorage
* @return bool
*/
public function checkQuota($uri, $data = null)
{
$length = $this->getLength();
if ($length) {
if (substr($uri, 0, 1) !== '/') {
$uri = '/' . $uri;
}
list($parentUri, $newName) = URLUtil::splitPath($uri);
$req = $this->server->httpRequest;
if ($req->getHeader('OC-Chunked')) {
$info = OC_FileChunking::decodeName($newName);
$chunkHandler = new OC_FileChunking($info);
// subtract the already uploaded size to see whether
// there is still enough space for the remaining chunks
$length -= $chunkHandler->getCurrentSize();
}
$freeSpace = $this->getFreeSpace($parentUri);
if ($freeSpace !== \OCP\Files\FileInfo::SPACE_UNKNOWN && $length > $freeSpace) {
if (isset($chunkHandler)) {
$chunkHandler->cleanup();
}
throw new \Sabre\DAV\Exception\InsufficientStorage();
}
}
return true;
}
示例2: serialize
/**
* serialize
*
* @param DAV\Server $server
* @param \DOMElement $dom
* @return void
*/
public function serialize(DAV\Server $server, \DOMElement $dom)
{
$document = $dom->ownerDocument;
$properties = $this->responseProperties;
$xresponse = $document->createElement('d:response');
$dom->appendChild($xresponse);
$uri = 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 DAV\PropertyInterface) {
$propertyValue->serialize($server, $currentProperty);
} elseif (!is_null($propertyValue)) {
throw new DAV\Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName);
}
}
$xpropstat->appendChild($document->createElement('d:status', $server->httpResponse->getStatusMessage($httpStatus)));
}
}
示例3: setName
/**
* Renames the node
*
* @param string $name The new name
* @return void
*/
public function setName($name)
{
list($parentPath, ) = DAV\URLUtil::splitPath($this->path);
list(, $newName) = DAV\URLUtil::splitPath($name);
$newPath = $parentPath . '/' . $newName;
rename($this->path, $newPath);
$this->path = $newPath;
}
示例4: getName
public function getName()
{
if ($this->isLink) {
return $this->sharedItem->getName();
} else {
list(, $name) = \Sabre\DAV\URLUtil::splitPath($this->linkPath);
return $name;
}
}
示例5: afterGetProperties
/**
* Handler for teh afterGetProperties event
*
* @param string $path
* @param array $properties
* @return void
*/
public function afterGetProperties($path, &$properties)
{
if (array_key_exists('{DAV:}getcontenttype', $properties[404])) {
list(, $fileName) = DAV\URLUtil::splitPath($path);
$contentType = $this->getContentType($fileName);
if ($contentType) {
$properties[200]['{DAV:}getcontenttype'] = $contentType;
unset($properties[404]['{DAV:}getcontenttype']);
}
}
}
示例6: getPrincipalByPath
/**
* Returns a specific principal, specified by it's path.
*
* @param string $path
* @return array
*/
public function getPrincipalByPath($path)
{
list($prefix, $user) = DAV\URLUtil::splitPath($path);
if ($prefix != 'principals') {
throw new DAV\Exception\NotFound('Invalid principal prefix path ' . $prefix);
}
if ($this->_auth->hasCapability('list') && !$this->_auth->exists($user) && $user != '-system-') {
throw new DAV\Exception\NotFound('User ' . $user . ' does not exist');
}
return $this->_getUserInfo($user);
}
示例7: getAddressBooksForUser
/**
* Returns the list of addressbooks for a specific user.
*
* @param string $principalUri
* @return array
*/
public function getAddressBooksForUser($principalUri)
{
list($prefix, $user) = DAV\URLUtil::splitPath($principalUri);
if ($prefix != 'principals') {
throw new DAV\Exception\NotFound('Invalid principal prefix path ' . $prefix);
}
try {
return $this->_registry->callAppMethod($this->_contacts(), 'davGetCollections', array('args' => array($user)));
} catch (Horde_Exception $e) {
throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
}
}
示例8: beforeCreateFile
public function beforeCreateFile($uri, $data)
{
list($dir, $name) = \Sabre\DAV\URLUtil::splitPath($uri);
$currentNode = null;
foreach (explode('/', trim($dir, '/')) as $pathPart) {
$parentNode = $currentNode;
$currentNode = \SiteCollection::getByHandle($pathPart, $parentNode ? $parentNode->ID : null);
if (!$currentNode) {
$currentNode = \SiteCollection::create($pathPart, $parentNode);
}
}
}
示例9: serialize
/**
* Serializes this property.
*
* It will additionally prepend the href property with the server's base uri.
*
* @param DAV\Server $server
* @param \DOMElement $dom
* @return void
*/
function serialize(DAV\Server $server, \DOMElement $dom)
{
$prefix = $server->xmlNamespaces['DAV:'];
$elem = $dom->ownerDocument->createElement($prefix . ':href');
if ($this->autoPrefix) {
$value = $server->getBaseUri() . DAV\URLUtil::encodePath($this->href);
} else {
$value = $this->href;
}
$elem->appendChild($dom->ownerDocument->createTextNode($value));
$dom->appendChild($elem);
}
示例10: getGroupMembership
/**
* Returns the list of groups a principal is a member of
*
* @param string $principal
* @return array
*/
public function getGroupMembership($principal)
{
list($prefix, $name) = \Sabre\DAV\URLUtil::splitPath($principal);
$group_membership = array();
if ($prefix == 'principals') {
$principal = $this->getPrincipalByPath($principal);
if (!$principal) {
throw new \Sabre\DAV\Exception('Principal not found');
}
// TODO: for now the user principal has only its own groups
return array('principals/' . $name . '/calendar-proxy-read', 'principals/' . $name . '/calendar-proxy-write');
}
return $group_membership;
}
示例11: checkPreconditions
public function checkPreconditions($handleAsGET = false)
{
// chunked upload handling
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
$filePath = parent::getRequestUri();
list($path, $name) = \Sabre\DAV\URLUtil::splitPath($filePath);
$info = OC_FileChunking::decodeName($name);
if (!empty($info)) {
$filePath = $path . '/' . $info['name'];
$this->overLoadedUri = $filePath;
}
}
$result = parent::checkPreconditions($handleAsGET);
$this->overLoadedUri = null;
return $result;
}
示例12: getCalendarsForUser
/**
* Returns a list of calendars for a principal.
*
* @param string $principalUri
* @return array
*/
public function getCalendarsForUser($principalUri)
{
list($prefix, $user) = DAV\URLUtil::splitPath($principalUri);
if ($prefix != 'principals') {
throw new DAV\Exception\NotFound('Invalid principal prefix path ' . $prefix);
}
$collections = array();
foreach ($this->_interfaces as $interface) {
try {
$collections = array_merge($collections, (array) $this->_registry->callAppMethod($interface, 'davGetCollections', array('args' => array($user))));
} catch (Horde_Exception $e) {
throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
}
}
return $collections;
}
示例13: sendFileIdHeader
/**
* @param string $filePath
* @param \Sabre\DAV\INode $node
* @throws \Sabre\DAV\Exception\BadRequest
*/
public function sendFileIdHeader($filePath, \Sabre\DAV\INode $node = null)
{
// chunked upload handling
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
list($path, $name) = \Sabre\DAV\URLUtil::splitPath($filePath);
$info = OC_FileChunking::decodeName($name);
if (!empty($info)) {
$filePath = $path . '/' . $info['name'];
}
}
// we get the node for the given $filePath here because in case of afterCreateFile $node is the parent folder
if (!$this->server->tree->nodeExists($filePath)) {
return;
}
$node = $this->server->tree->getNodeForPath($filePath);
if ($node instanceof OC_Connector_Sabre_Node) {
$fileId = $node->getFileId();
if (!is_null($fileId)) {
$this->server->httpResponse->setHeader('OC-FileId', $fileId);
}
}
}
示例14: setName
/**
* Renames the node
*
* @param string $name The new name
* @return void
*/
public function setName($name)
{
list($parentPath, ) = DAV\URLUtil::splitPath($this->path);
list(, $newName) = DAV\URLUtil::splitPath($name);
$newPath = $parentPath . '/' . $newName;
// We're deleting the existing resourcedata, and recreating it
// for the new path.
$resourceData = $this->getResourceData();
$this->deleteResourceData();
rename($this->path, $newPath);
$this->path = $newPath;
$this->putResourceData($resourceData);
}
示例15: getName
/**
* Returns the name of the node.
*
* This is used to generate the url.
*
* @return string
*/
public function getName()
{
list($dir, $base) = DAV\URLUtil::splitPath($this->_path);
return $base;
}