当前位置: 首页>>代码示例>>PHP>>正文


PHP URLUtil::splitPath方法代码示例

本文整理汇总了PHP中Sabre\DAV\URLUtil::splitPath方法的典型用法代码示例。如果您正苦于以下问题:PHP URLUtil::splitPath方法的具体用法?PHP URLUtil::splitPath怎么用?PHP URLUtil::splitPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sabre\DAV\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) = 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;
 }
开发者ID:Combustible,项目名称:core,代码行数:34,代码来源:quotaplugin.php

示例2: 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;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:14,代码来源:Node.php

示例3: getName

 public function getName()
 {
     if ($this->isLink) {
         return $this->sharedItem->getName();
     } else {
         list(, $name) = \Sabre\DAV\URLUtil::splitPath($this->linkPath);
         return $name;
     }
 }
开发者ID:hallnewman,项目名称:webmail-lite,代码行数:9,代码来源:SharedDirectory.php

示例4: 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);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:17,代码来源:Principals.php

示例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']);
         }
     }
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:18,代码来源:GuessContentType.php

示例6: 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);
         }
     }
 }
开发者ID:nbey,项目名称:Emergence-Skeleton,代码行数:12,代码来源:ServerPlugin.php

示例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);
     }
 }
开发者ID:kossamums,项目名称:horde,代码行数:18,代码来源:Backend.php

示例8: 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;
 }
开发者ID:Romua1d,项目名称:core,代码行数:20,代码来源:principal.php

示例9: 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;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:22,代码来源:Backend.php

示例10: 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;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:16,代码来源:server.php

示例11: 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);
         }
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:27,代码来源:filesplugin.php

示例12: 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;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:12,代码来源:File.php

示例13: getName

 /**
  * Returns this principals name.
  *
  * @return string
  */
 public function getName()
 {
     $uri = $this->principalProperties['uri'];
     list(, $name) = DAV\URLUtil::splitPath($uri);
     return $name;
 }
开发者ID:samj1912,项目名称:repo,代码行数:11,代码来源:Principal.php

示例14: getRawPathInfo

 /**
  * get Path info from request, not urldecoded
  * @throws Exception
  * @return string Path info or false when not found
  */
 public static function getRawPathInfo()
 {
     $requestUri = $_SERVER['REQUEST_URI'];
     // remove too many leading slashes - can be caused by reverse proxy configuration
     if (strpos($requestUri, '/') === 0) {
         $requestUri = '/' . ltrim($requestUri, '/');
     }
     // Remove the query string from REQUEST_URI
     if ($pos = strpos($requestUri, '?')) {
         $requestUri = substr($requestUri, 0, $pos);
     }
     $scriptName = $_SERVER['SCRIPT_NAME'];
     $path_info = $requestUri;
     // strip off the script name's dir and file name
     list($path, $name) = \Sabre\DAV\URLUtil::splitPath($scriptName);
     if (!empty($path)) {
         if ($path === $path_info || strpos($path_info, $path . '/') === 0) {
             $path_info = substr($path_info, strlen($path));
         } else {
             throw new Exception("The requested uri({$requestUri}) cannot be processed by the script '{$scriptName}')");
         }
     }
     if (strpos($path_info, '/' . $name) === 0) {
         $path_info = substr($path_info, strlen($name) + 1);
     }
     if (strpos($path_info, $name) === 0) {
         $path_info = substr($path_info, strlen($name));
     }
     if ($path_info === '/') {
         return '';
     } else {
         return $path_info;
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:39,代码来源:request.php

示例15: createCollection

 /**
  * Use this method to create a new collection
  *
  * The {DAV:}resourcetype is specified using the resourceType array.
  * At the very least it must contain {DAV:}collection.
  *
  * The properties array can contain a list of additional properties.
  *
  * @param string $uri The new uri
  * @param array $resourceType The resourceType(s)
  * @param array $properties A list of properties
  * @return array|null
  */
 public function createCollection($uri, array $resourceType, array $properties)
 {
     list($parentUri, $newName) = URLUtil::splitPath($uri);
     // Making sure {DAV:}collection was specified as resourceType
     if (!in_array('{DAV:}collection', $resourceType)) {
         throw new Exception\InvalidResourceType('The resourceType for this collection must at least include {DAV:}collection');
     }
     // Making sure the parent exists
     try {
         $parent = $this->tree->getNodeForPath($parentUri);
     } catch (Exception\NotFound $e) {
         throw new Exception\Conflict('Parent node does not exist');
     }
     // Making sure the parent is a collection
     if (!$parent instanceof ICollection) {
         throw new Exception\Conflict('Parent node is not a collection');
     }
     // Making sure the child does not already exist
     try {
         $parent->getChild($newName);
         // If we got here.. it means there's already a node on that url, and we need to throw a 405
         throw new Exception\MethodNotAllowed('The resource you tried to create already exists');
     } catch (Exception\NotFound $e) {
         // This is correct
     }
     if (!$this->broadcastEvent('beforeBind', array($uri))) {
         return;
     }
     // There are 2 modes of operation. The standard collection
     // creates the directory, and then updates properties
     // the extended collection can create it directly.
     if ($parent instanceof IExtendedCollection) {
         $parent->createExtendedCollection($newName, $resourceType, $properties);
     } else {
         // No special resourcetypes are supported
         if (count($resourceType) > 1) {
             throw new Exception\InvalidResourceType('The {DAV:}resourcetype you specified is not supported here.');
         }
         $parent->createDirectory($newName);
         $rollBack = false;
         $exception = null;
         $errorResult = null;
         if (count($properties) > 0) {
             try {
                 $errorResult = $this->updateProperties($uri, $properties);
                 if (!isset($errorResult[200])) {
                     $rollBack = true;
                 }
             } catch (Exception $e) {
                 $rollBack = true;
                 $exception = $e;
             }
         }
         if ($rollBack) {
             if (!$this->broadcastEvent('beforeUnbind', array($uri))) {
                 return;
             }
             $this->tree->delete($uri);
             // Re-throwing exception
             if ($exception) {
                 throw $exception;
             }
             return $errorResult;
         }
     }
     $this->tree->markDirty($parentUri);
     $this->broadcastEvent('afterBind', array($uri));
 }
开发者ID:floffel03,项目名称:pydio-core,代码行数:81,代码来源:Server.php


注:本文中的Sabre\DAV\URLUtil::splitPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。