本文整理汇总了PHP中Sabre\HTTP\URLUtil::splitPath方法的典型用法代码示例。如果您正苦于以下问题:PHP URLUtil::splitPath方法的具体用法?PHP URLUtil::splitPath怎么用?PHP URLUtil::splitPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre\HTTP\URLUtil
的用法示例。
在下文中一共展示了URLUtil::splitPath方法的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) = \Sabre\HTTP\URLUtil::splitPath($uri);
if (is_null($parentUri)) {
$parentUri = '';
}
$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: propFind
/**
* Our PROPFIND handler
*
* Here we set a contenttype, if the node didn't already have one.
*
* @param PropFind $propFind
* @param INode $node
* @return void
*/
function propFind(PropFind $propFind, INode $node)
{
$propFind->handle('{DAV:}getcontenttype', function () use($propFind) {
list(, $fileName) = URLUtil::splitPath($propFind->getPath());
return $this->getContentType($fileName);
});
}
示例3: convertPrincipal
private function convertPrincipal($principal, $toV2)
{
list(, $name) = URLUtil::splitPath($principal);
if ($toV2) {
return "principals/users/{$name}";
}
return "principals/{$name}";
}
示例4: setName
/**
* Renames the node
*
* @param string $name The new name
* @return void
*/
function setName($name)
{
list($parentPath, ) = URLUtil::splitPath($this->path);
list(, $newName) = URLUtil::splitPath($name);
$newPath = $parentPath . '/' . $newName;
rename($this->path, $newPath);
$this->path = $newPath;
}
示例5: setName
/**
* Renames the node
*
* @param string $name The new name
* @return void
*/
public function setName($name)
{
list($parentPath, ) = URLUtil::splitPath($this->path);
list(, $newName) = URLUtil::splitPath($name);
$newPath = $parentPath . '/' . $newName;
Utils::renameObject($this->nodeId, $name);
// rename($this->path,$newPath);
$this->path = $newPath;
}
示例6: getName
public function getName()
{
if ($this->isLink) {
return $this->sharedNode->getName();
} else {
list(, $name) = \Sabre\HTTP\URLUtil::splitPath($this->linkPath);
return $name;
}
}
示例7: getAddressbookHomeForPrincipal
/**
* Returns the addressbook home for a given principal
*
* @param string $principal
* @return string
*/
protected function getAddressbookHomeForPrincipal($principal)
{
if (strrpos($principal, 'principals/users', -strlen($principal)) !== FALSE) {
list(, $principalId) = URLUtil::splitPath($principal);
return self::ADDRESSBOOK_ROOT . '/users/' . $principalId;
}
if (strrpos($principal, 'principals/system', -strlen($principal)) !== FALSE) {
list(, $principalId) = URLUtil::splitPath($principal);
return self::ADDRESSBOOK_ROOT . '/system/' . $principalId;
}
throw new \LogicException('This is not supposed to happen');
}
示例8: getCalendarsForUser
function getCalendarsForUser($principalUri)
{
/** @var Termin $termin */
$termin = Termin::model()->findByPk($this->termin_id);
if (!$termin) {
return [];
}
list(, $name) = \Sabre\HTTP\URLUtil::splitPath($principalUri);
if ($name !== 'guest') {
return [];
}
return [['id' => $this->termin_id, 'uri' => $this->termin_id, 'principaluri' => $principalUri, '{DAV:}displayname' => $termin->gremium->getName(), '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => rand(0, 100000000), '{http://sabredav.org/ns}sync-token' => '0', '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet(["VEVENT", "VJOURNAL", "VTODO"]), '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new \Sabre\CalDAV\Property\ScheduleCalendarTransp('opaque'), '{http://sabredav.org/ns}read-only' => '1']];
}
示例9: setName
/**
* Renames the node
* @param string $name The new name
* @throws \Sabre\DAV\Exception\BadRequest
* @throws \Sabre\DAV\Exception\Forbidden
*/
public function setName($name)
{
// rename is only allowed if the update privilege is granted
if (!$this->info->isUpdateable()) {
throw new \Sabre\DAV\Exception\Forbidden();
}
list($parentPath, ) = \Sabre\HTTP\URLUtil::splitPath($this->path);
list(, $newName) = \Sabre\HTTP\URLUtil::splitPath($name);
// verify path of the target
$this->verifyPath();
$newPath = $parentPath . '/' . $newName;
$this->fileView->rename($this->path, $newPath);
$this->path = $newPath;
$this->refreshInfo();
}
示例10: getChildForPrincipal
/**
* This method returns a node for a principal.
*
* The passed array contains principal information, and is guaranteed to
* at least contain a uri item. Other properties may or may not be
* supplied by the authentication backend.
*
* @param array $principal
* @return \Sabre\DAV\INode
*/
function getChildForPrincipal(array $principal)
{
$node = parent::getChildForPrincipal($principal);
/*
* Création du carnet d'adresse par défaut s'il n'existe pas
*/
if (!$node || count($node->getChildren()) == 0) {
//No addressBook. Create default one
$principalUri = $principal["uri"];
list(, $principalId) = \Sabre\HTTP\URLUtil::splitPath($principalUri);
$name = "contacts";
$properties = ['{DAV:}displayname' => $name, '{' . \Sabre\CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => "Contacts de " . $principalId];
$this->carddavBackend->createAddressBook($principalUri, $name, $properties);
$node = parent::getChildForPrincipal($principal);
}
return $node;
}
示例11: getChildForPrincipal
/**
* This method returns a node for a principal.
*
* The passed array contains principal information, and is guaranteed to
* at least contain a uri item. Other properties may or may not be
* supplied by the authentication backend.
*
* @param array $principal
* @return \Sabre\DAV\INode
*/
function getChildForPrincipal(array $principal)
{
$node = parent::getChildForPrincipal($principal);
/*
* Création du calendrier par défaut s'il n'existe pas
*/
if (!$node || count($node->getChildren()) == 0) {
//No calendar. Create default one
$principalUri = $principal["uri"];
list(, $principalId) = \Sabre\HTTP\URLUtil::splitPath($principalUri);
$name = $principalId;
$properties = ['{DAV:}displayname' => $name, '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar' => $name];
$this->caldavBackend->createCalendar($principalUri, $name, $properties);
$node = parent::getChildForPrincipal($principal);
}
return $node;
}
示例12: getPrincipalsByPrefix
/**
* Returns a list of principals based on a prefix.
*
* This prefix will often contain something like 'principals'. You are only
* expected to return principals that are in this base path.
*
* You are expected to return at least a 'uri' for every user, you can
* return any additional properties if you wish so. Common properties are:
* {DAV:}displayname
* {http://sabredav.org/ns}email-address - This is a custom SabreDAV
* field that's actualy injected in a number of other properties. If
* you have an email address, use this property.
*
* @param string $prefixPath
* @return array
*/
function getPrincipalsByPrefix($prefixPath)
{
$principals = [];
foreach ($this->allprincipals as $row) {
// Checking if the principal is in the prefix
list($rowPrefix) = URLUtil::splitPath($row['uri']);
if ($rowPrefix !== $prefixPath) {
continue;
}
$principal = ['uri' => $row['uri']];
foreach ($this->fieldMap as $key => $value) {
if ($row[$value['dbField']]) {
$principal[$key] = $row[$value['dbField']];
}
}
$principals[] = $principal;
}
return $principals;
}
示例13: getAddressBooksForUser
/**
* Returns the list of address books for a specific user.
*
* Every addressbook should have the following properties:
* id - an arbitrary unique id
* uri - the 'basename' part of the url
* principaluri - Same as the passed parameter
*
* Any additional clark-notation property may be passed besides this. Some
* common ones are :
* {DAV:}displayname
* {urn:ietf:params:xml:ns:carddav}addressbook-description
* {http://calendarserver.org/ns/}getctag
*
* @param string $principalUri
* @return array
*/
function getAddressBooksForUser($principalUri)
{
$query = $this->db->getQueryBuilder();
$query->select(['id', 'uri', 'displayname', 'principaluri', 'description', 'synctoken'])->from('addressbooks')->where($query->expr()->eq('principaluri', $query->createParameter('principaluri')))->setParameter('principaluri', $principalUri);
$addressBooks = [];
$result = $query->execute();
while ($row = $result->fetch()) {
$addressBooks[] = ['id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => $row['principaluri'], '{DAV:}displayname' => $row['displayname'], '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0'];
}
$result->closeCursor();
// query for shared calendars
$principals = $this->principalBackend->getGroupMembership($principalUri);
$principals[] = $principalUri;
$query = $this->db->getQueryBuilder();
$result = $query->select(['a.id', 'a.uri', 'a.displayname', 'a.principaluri', 'a.description', 'a.synctoken', 's.access'])->from('dav_shares', 's')->join('s', 'addressbooks', 'a', $query->expr()->eq('s.resourceid', 'a.id'))->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri')))->andWhere($query->expr()->eq('s.type', $query->createParameter('type')))->setParameter('type', 'addressbook')->setParameter('principaluri', $principals, IQueryBuilder::PARAM_STR_ARRAY)->execute();
while ($row = $result->fetch()) {
list(, $name) = URLUtil::splitPath($row['principaluri']);
$uri = $row['uri'] . '_shared_by_' . $name;
$displayName = $row['displayname'] . "({$name})";
$addressBooks[] = ['id' => $row['id'], 'uri' => $uri, 'principaluri' => $principalUri, '{DAV:}displayname' => $displayName, '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0', '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'], '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => $row['access'] === self::ACCESS_READ];
}
$result->closeCursor();
return $addressBooks;
}
示例14: getMultipleNodes
/**
* This method tells the tree system to pre-fetch and cache a list of
* children of a single parent.
*
* There are a bunch of operations in the WebDAV stack that request many
* children (based on uris), and sometimes fetching many at once can
* optimize this.
*
* This method returns an array with the found nodes. It's keys are the
* original paths. The result may be out of order.
*
* @param array $paths List of nodes that must be fetched.
* @return array
*/
function getMultipleNodes($paths)
{
// Finding common parents
$parents = [];
foreach ($paths as $path) {
list($parent, $node) = URLUtil::splitPath($path);
if (!isset($parents[$parent])) {
$parents[$parent] = [$node];
} else {
$parents[$parent][] = $node;
}
}
$result = [];
foreach ($parents as $parent => $children) {
$parentNode = $this->getNodeForPath($parent);
if ($parentNode instanceof IMultiGet) {
foreach ($parentNode->getMultipleChildren($children) as $childNode) {
$fullPath = $parent . '/' . $childNode->getName();
$result[$fullPath] = $childNode;
$this->cache[$fullPath] = $childNode;
}
} else {
foreach ($children as $child) {
$fullPath = $parent . '/' . $child;
$result[$fullPath] = $this->getNodeForPath($fullPath);
}
}
}
return $result;
}
示例15: copy
/**
* Copies a file or directory.
*
* This method must work recursively and delete the destination
* if it exists
*
* @param string $source
* @param string $destination
* @throws \Sabre\DAV\Exception\ServiceUnavailable
* @return void
*/
public function copy($source, $destination)
{
if (!$this->fileView) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
}
// this will trigger existence check
$this->getNodeForPath($source);
list($destinationDir, $destinationName) = \Sabre\HTTP\URLUtil::splitPath($destination);
try {
$this->fileView->verifyPath($destinationDir, $destinationName);
} catch (\OCP\Files\InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage());
}
try {
$this->fileView->copy($source, $destination);
} catch (StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
} catch (ForbiddenException $ex) {
throw new Forbidden($ex->getMessage(), $ex->getRetry());
} catch (LockedException $e) {
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
list($destinationDir, ) = \Sabre\HTTP\URLUtil::splitPath($destination);
$this->markDirty($destinationDir);
}