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


PHP HTTP\URLUtil类代码示例

本文整理汇总了PHP中Sabre\HTTP\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) = \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;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:37,代码来源:quotaplugin.php

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

示例3: convertPrincipal

 private function convertPrincipal($principal, $toV2)
 {
     list(, $name) = URLUtil::splitPath($principal);
     if ($toV2) {
         return "principals/users/{$name}";
     }
     return "principals/{$name}";
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:8,代码来源:LegacyDAVACL.php

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

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

示例6: getName

 public function getName()
 {
     if ($this->isLink) {
         return $this->sharedNode->getName();
     } else {
         list(, $name) = \Sabre\HTTP\URLUtil::splitPath($this->linkPath);
         return $name;
     }
 }
开发者ID:afterlogic,项目名称:dav,代码行数:9,代码来源:Directory.php

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

示例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']];
 }
开发者ID:CatoTH,项目名称:Muenchen-Transparent,代码行数:13,代码来源:TermineCalDAVCalendarBackend.php

示例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();
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:21,代码来源:node.php

示例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;
 }
开发者ID:vmire,项目名称:SabreServer,代码行数:27,代码来源:AddressBookRoot.php

示例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;
 }
开发者ID:vmire,项目名称:SabreServer,代码行数:27,代码来源:CalendarRoot.php

示例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;
 }
开发者ID:Befox,项目名称:cdav,代码行数:35,代码来源:PrincipalsDolibarr.php

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

示例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;
 }
开发者ID:mattes,项目名称:sabre-dav,代码行数:44,代码来源:Tree.php

示例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);
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:36,代码来源:objecttree.php


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