• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Sabre_DAV_URLUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Sabre_DAV_URLUtil的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_DAV_URLUtil类的具体用法?PHP Sabre_DAV_URLUtil怎么用?PHP Sabre_DAV_URLUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Sabre_DAV_URLUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: checkQuota

 /**
  * This method is called before any HTTP method and validates there is enough free space to store the file
  *
  * @param string $method
  * @throws Sabre_DAV_Exception
  * @return bool
  */
 public function checkQuota($uri, $data = null)
 {
     $length = $this->getLength();
     if ($length) {
         if (substr($uri, 0, 1) !== '/') {
             $uri = '/' . $uri;
         }
         list($parentUri, $newName) = Sabre_DAV_URLUtil::splitPath($uri);
         $req = $this->server->httpRequest;
         if ($req->getHeader('OC-Chunked')) {
             $info = OC_FileChunking::decodeName($newName);
             $chunkHandler = new OC_FileChunking($info);
             // substract 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 !== \OC\Files\SPACE_UNKNOWN && $length > $freeSpace) {
             if (isset($chunkHandler)) {
                 $chunkHandler->cleanup();
             }
             throw new Sabre_DAV_Exception_InsufficientStorage();
         }
     }
     return true;
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:33,代码来源:quotaplugin.php


示例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)));
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:67,代码来源:Response.php


示例3: testSplitPath

 function testSplitPath()
 {
     $strings = array('/foo/bar' => array('/foo', 'bar'), '/foo/bar/' => array('/foo', 'bar'), 'foo/bar/' => array('foo', 'bar'), 'foo/bar' => array('foo', 'bar'), 'foo/bar/baz' => array('foo/bar', 'baz'), 'foo/bar/baz/' => array('foo/bar', 'baz'), 'foo' => array('', 'foo'), 'foo/' => array('', 'foo'), '/foo/' => array('', 'foo'), '/foo' => array('', 'foo'), '' => array(null, null), "/àfoó/bar" => array("/àfoó", 'bar'), "/àfoo/bür/" => array("/àfoo", "bür"), "foo/àür" => array("foo", "àür"));
     foreach ($strings as $input => $expected) {
         $output = Sabre_DAV_URLUtil::splitPath($input);
         $this->assertEquals($expected, $output, 'The expected output for \'' . $input . '\' was incorrect');
     }
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:8,代码来源:URLUtilTest.php


示例4: setName

 /**
  * Renames the node
  *
  * @param string $name The new name
  * @return void
  */
 public function setName($name)
 {
     list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path);
     list(, $newName) = Sabre_DAV_URLUtil::splitPath($name);
     $newPath = $parentPath . '/' . $newName;
     rename($this->path, $newPath);
     $this->path = $newPath;
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:14,代码来源:Node.php


示例5: setName

 /**
  * Renames the node
  * 
  * @throws Sabre_DAV_Exception_Forbidden
  * @param string $name The new name
  * @return void
  */
 public function setName($name)
 {
     self::checkForbiddenFile($name);
     if (!Tinebase_Core::getUser()->hasGrant($this->_getContainer(), Tinebase_Model_Grants::GRANT_EDIT)) {
         throw new Sabre_DAV_Exception_Forbidden('Forbidden to rename file: ' . $this->_path);
     }
     list($dirname, $basename) = Sabre_DAV_URLUtil::splitPath($this->_path);
     Tinebase_FileSystem::getInstance()->rename($this->_path, $dirname . '/' . $name);
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:16,代码来源:Node.php


示例6: nodeExists

 /**
  * This function allows you to check if a node exists.
  *
  * @param string $path 
  * @return bool 
  */
 public function nodeExists($path)
 {
     try {
         list($parent, $base) = Sabre_DAV_URLUtil::splitPath($path);
         $parentNode = $this->getNodeForPath($parent);
         return $parentNode->childExists($base);
     } catch (Sabre_DAV_Exception_FileNotFound $e) {
         return false;
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:16,代码来源:ObjectTree.php


示例7: setName

 /**
  * Renames the node
  *
  * @param string $name The new name
  * @return void
  */
 public function setName($name)
 {
     list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path);
     list(, $newName) = Sabre_DAV_URLUtil::splitPath($name);
     $newPath = $parentPath . '/' . $newName;
     $oldPath = $this->path;
     OC_Filesystem::rename($this->path, $newPath);
     $this->path = $newPath;
     $query = OC_DB::prepare('UPDATE *PREFIX*properties SET propertypath = ? WHERE userid = ? AND propertypath = ?');
     $query->execute(array($newPath, OC_User::getUser(), $oldPath));
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:17,代码来源:owncloud_lib_connector_sabre_node.php


示例8: 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) = Sabre_DAV_URLUtil::splitPath($path);
         $contentType = $this->getContentType($fileName);
         if ($contentType) {
             $properties[200]['{DAV:}getcontenttype'] = $contentType;
             unset($properties[404]['{DAV:}getcontenttype']);
         }
     }
 }
开发者ID:mover5,项目名称:imobackup,代码行数:18,代码来源:GuessContentType.php


示例9: move

 /**
  * Moves a file from one location to another 
  * 
  * @param string $sourcePath The path to the file which should be moved 
  * @param string $destinationPath The full destination path, so not just the destination parent node
  * @return int
  */
 public function move($sourcePath, $destinationPath)
 {
     list($sourceDir, $sourceName) = Sabre_DAV_URLUtil::splitPath($sourcePath);
     list($destinationDir, $destinationName) = Sabre_DAV_URLUtil::splitPath($destinationPath);
     if ($sourceDir === $destinationDir) {
         $renameable = $this->getNodeForPath($sourcePath);
         $renameable->setName($destinationName);
     } else {
         $this->copy($sourcePath, $destinationPath);
         $this->getNodeForPath($sourcePath)->delete();
     }
 }
开发者ID:jtietema,项目名称:Fizzy,代码行数:19,代码来源:Tree.php


示例10: getPrincipalByPath

 /**
  * Returns a specific principal, specified by it's path.
  * The returned structure should be the exact same as from
  * getPrincipalsByPrefix.
  *
  * @param string $path
  * @return array
  */
 public function getPrincipalByPath($path)
 {
     list($prefixPath, $userName) = Sabre_DAV_URLUtil::splitPath($path);
     // This backend only support principals in one collection
     if ($prefixPath !== $this->prefix) {
         return null;
     }
     $r = q("SELECT `nickname` FROM `user` WHERE `nickname` = '%s'", escape_tags($userName));
     if (count($r) == 0) {
         return array();
     }
     return array('uri' => $this->prefix . '/' . strtolower($r[0]['nickname']), '{DAV:}displayname' => $r[0]['nickname']);
 }
开发者ID:robhell,项目名称:friendica-addons,代码行数:21,代码来源:dav_friendica_principal.inc.php


示例11: 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:jaeindia,项目名称:ownCloud-Enhancements,代码行数:20,代码来源:principal.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 
  */
 public function getPrincipalsByPrefix($prefixPath)
 {
     $result = $this->pdo->query('SELECT uri, email, displayname FROM `' . $this->tableName . '`');
     $principals = array();
     while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
         // Checking if the principal is in the prefix
         list($rowPrefix) = Sabre_DAV_URLUtil::splitPath($row['uri']);
         if ($rowPrefix !== $prefixPath) {
             continue;
         }
         $principals[] = array('uri' => $row['uri'], '{DAV:}displayname' => $row['displayname'] ? $row['displayname'] : basename($row['uri']), '{http://sabredav.org/ns}email-address' => $row['email']);
     }
     return $principals;
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:30,代码来源:owncloud_3rdparty_Sabre_DAVACL_PrincipalBackend_PDO.php


示例13: checkQuota

 /**
  * This method is called before any HTTP method and validates there is enough free space to store the file
  *
  * @param string $method
  * @throws Sabre_DAV_Exception
  * @return bool
  */
 public function checkQuota($uri, $data = null)
 {
     $length = $this->getLength();
     if ($length) {
         if (substr($uri, 0, 1) !== '/') {
             $uri = '/' . $uri;
         }
         list($parentUri, $newName) = Sabre_DAV_URLUtil::splitPath($uri);
         $freeSpace = $this->getFreeSpace($parentUri);
         if ($freeSpace !== \OC\Files\SPACE_UNKNOWN && $length > $freeSpace) {
             throw new Sabre_DAV_Exception_InsufficientStorage();
         }
     }
     return true;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:22,代码来源:quotaplugin.php


示例14: getHTTPMethods

 /**
  * Use this method to tell the server this plugin defines additional
  * HTTP methods.
  *
  * This method is passed a uri. It should only return HTTP methods that are 
  * available for the specified uri.
  *
  * @param string $uri
  * @return array 
  */
 public function getHTTPMethods($uri)
 {
     // The MKCALENDAR is only available on unmapped uri's, whose
     // parents extend IExtendedCollection
     list($parent, $name) = Sabre_DAV_URLUtil::splitPath($uri);
     $node = $this->server->tree->getNodeForPath($parent);
     if ($node instanceof Sabre_DAV_IExtendedCollection) {
         try {
             $node->getChild($name);
         } catch (Sabre_DAV_Exception_FileNotFound $e) {
             return array('MKCALENDAR');
         }
     }
     return array();
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:25,代码来源:Plugin.php


示例15: 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
  *
  * @param string $prefixPath
  * @return array
  */
 public function getPrincipalsByPrefix($prefixPath)
 {
     $query = OC_DB::prepare('SELECT * FROM *PREFIX*principals');
     $result = $query->execute();
     $principals = array();
     while ($row = $result->fetchRow()) {
         // Checking if the principal is in the prefix
         list($rowPrefix) = Sabre_DAV_URLUtil::splitPath($row['uri']);
         if ($rowPrefix !== $prefixPath) {
             continue;
         }
         $principals[] = array('uri' => $row['uri'], '{DAV:}displayname' => $row['displayname'] ? $row['displayname'] : basename($row['uri']));
     }
     return $principals;
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:28,代码来源:owncloud_lib_connector_sabre_principal.php


示例16: setName

 /**
  * @brief Renames the node
  * @param string $name The new name
  * @return void
  */
 public function setName($name)
 {
     // rename is only allowed if the update privilege is granted
     if (!\OC\Files\Filesystem::isUpdatable($this->path)) {
         throw new \Sabre_DAV_Exception_Forbidden();
     }
     list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path);
     list(, $newName) = Sabre_DAV_URLUtil::splitPath($name);
     $newPath = $parentPath . '/' . $newName;
     $oldPath = $this->path;
     \OC\Files\Filesystem::rename($this->path, $newPath);
     $this->path = $newPath;
     $query = OC_DB::prepare('UPDATE `*PREFIX*properties` SET `propertypath` = ?' . ' WHERE `userid` = ? AND `propertypath` = ?');
     $query->execute(array($newPath, OC_User::getUser(), $oldPath));
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:20,代码来源:node.php


示例17: checkQuota

 /**
  * This method is called before any HTTP method and forces users to be authenticated
  *
  * @param string $method
  * @throws Sabre_DAV_Exception
  * @return bool
  */
 public function checkQuota($uri, $data = null)
 {
     $expected = $this->server->httpRequest->getHeader('X-Expected-Entity-Length');
     $length = $expected ? $expected : $this->server->httpRequest->getHeader('Content-Length');
     if ($length) {
         if (substr($uri, 0, 1) !== '/') {
             $uri = '/' . $uri;
         }
         list($parentUri, $newName) = Sabre_DAV_URLUtil::splitPath($uri);
         if ($length > OC_Filesystem::free_space($parentUri)) {
             throw new Sabre_DAV_Exception('Quota exceeded. File is too big.');
         }
     }
     return true;
 }
开发者ID:ryanshoover,项目名称:core,代码行数:22,代码来源:quotaplugin.php


示例18: getCalendarsForUser

 /**
  * Returns a list of calendars for a principal.
  *
  * Every project is an array with the following keys:
  *  * id, a unique id that will be used by other functions to modify the
  *    calendar. This can be the same as the uri or a database key.
  *  * uri, which the basename of the uri with which the calendar is
  *    accessed.
  *  * principaluri. The owner of the calendar. Almost always the same as
  *    principalUri passed to this method.
  *
  * Furthermore it can contain webdav properties in clark notation. A very
  * common one is '{DAV:}displayname'.
  *
  * @param string $principalUri
  * @return array
  */
 public function getCalendarsForUser($principalUri)
 {
     list(, $name) = Sabre_DAV_URLUtil::splitPath($principalUri);
     $user_id = dav_compat_username2id($name);
     $cals = q("SELECT * FROM %s%scalendars WHERE `uid`=%d AND `namespace` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $user_id, $this->getNamespace());
     $ret = array();
     foreach ($cals as $cal) {
         $dat = array("id" => $cal["namespace"] . "-" . $cal["namespace_id"], "uri" => $this->getCalUrlPrefix() . "-" . $cal["namespace_id"], "principaluri" => $principalUri, '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $cal['ctag'] ? $cal['ctag'] : '0', "calendar_class" => "Sabre_CalDAV_Calendar");
         foreach ($this->propertyMap as $key => $field) {
             $dat[$key] = $cal[$field];
         }
         $ret[] = $dat;
     }
     return $ret;
 }
开发者ID:robhell,项目名称:friendica-addons,代码行数:32,代码来源:dav_caldav_backend_common.inc.php


示例19: checkQuota

 /**
  * This method is called before any HTTP method and forces users to be authenticated
  *
  * @param string $method
  * @throws Sabre_DAV_Exception
  * @return bool
  */
 public function checkQuota($uri, $data = null)
 {
     $expected = $this->server->httpRequest->getHeader('X-Expected-Entity-Length');
     $length = $expected ? $expected : $this->server->httpRequest->getHeader('Content-Length');
     if ($length) {
         if (substr($uri, 0, 1) !== '/') {
             $uri = '/' . $uri;
         }
         list($parentUri, $newName) = Sabre_DAV_URLUtil::splitPath($uri);
         $freeSpace = \OC\Files\Filesystem::free_space($parentUri);
         if ($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN && $length > $freeSpace) {
             throw new Sabre_DAV_Exception_InsufficientStorage();
         }
     }
     return true;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:23,代码来源:quotaplugin.php


示例20: nodeExists

 /**
  * This function allows you to check if a node exists.
  *
  * @param string $path
  * @return bool
  */
 public function nodeExists($path)
 {
     try {
         // The root always exists
         if ($path === '') {
             return true;
         }
         list($parent, $base) = Sabre_DAV_URLUtil::splitPath($path);
         $parentNode = $this->getNodeForPath($parent);
         if (!$parentNode instanceof Sabre_DAV_ICollection) {
             return false;
         }
         return $parentNode->childExists($base);
     } catch (Sabre_DAV_Exception_NotFound $e) {
         return false;
     }
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:23,代码来源:ObjectTree.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Sabre_DAV_XMLUtil类代码示例发布时间:2022-05-23
下一篇:
PHP Sabre_DAV_Server类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap