php Sabre-DAV-PropFind类(方法)实例源码

下面列出了php Sabre-DAV-PropFind 类(方法)源码代码实例,从而了解它的用法。

作者:sebbie4    项目:casebo   
/**
  * PropFind
  *
  * This method handler is invoked before any after properties for a
  * resource are fetched. This allows us to add in any CalDAV specific
  * properties.
  *
  * @param DAV\PropFind $propFind
  * @param DAV\INode $node
  * @return void
  */
 function propFind(DAV\PropFind $propFind, DAV\INode $node)
 {
     $ns = '{' . self::NS_CALDAV . '}';
     if ($node instanceof ICalendarObjectContainer) {
         $propFind->handle($ns . 'max-resource-size', $this->maxResourceSize);
         $propFind->handle($ns . 'supported-calendar-data', function () {
             return new Xml\Property\SupportedCalendarData();
         });
         $propFind->handle($ns . 'supported-collation-set', function () {
             return new Xml\Property\SupportedCollationSet();
         });
     }
     if ($node instanceof DAVACL\IPrincipal) {
         $principalUrl = $node->getPrincipalUrl();
         $propFind->handle('{' . self::NS_CALDAV . '}calendar-home-set', function () use($principalUrl) {
             $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl) . '/';
             return new Href($calendarHomePath);
         });
         // The calendar-user-address-set property is basically mapped to
         // the {DAV:}alternate-URI-set property.
         $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-address-set', function () use($node) {
             $addresses = $node->getAlternateUriSet();
             $addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl() . '/';
             return new Href($addresses, false);
         });
         // For some reason somebody thought it was a good idea to add
         // another one of these properties. We're supporting it too.
         $propFind->handle('{' . self::NS_CALENDARSERVER . '}email-address-set', function () use($node) {
             $addresses = $node->getAlternateUriSet();
             $emails = [];
             foreach ($addresses as $address) {
                 if (substr($address, 0, 7) === 'mailto:') {
                     $emails[] = substr($address, 7);
                 }
             }
             return new Xml\Property\EmailAddressSet($emails);
         });
         // These two properties are shortcuts for ical to easily find
         // other principals this principal has access to.
         $propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for';
         $propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for';
         if ($propFind->getStatus($propRead) === 404 || $propFind->getStatus($propWrite) === 404) {
             $aclPlugin = $this->server->getPlugin('acl');
             $membership = $aclPlugin->getPrincipalMembership($propFind->getPath());
             $readList = [];
             $writeList = [];
             foreach ($membership as $group) {
                 $groupNode = $this->server->tree->getNodeForPath($group);
                 $listItem = Uri\split($group)[0] . '/';
                 // If the node is either ap proxy-read or proxy-write
                 // group, we grab the parent principal and add it to the
                 // list.
                 if ($groupNode instanceof Principal\IProxyRead) {
                     $readList[] = $listItem;
                 }
                 if ($groupNode instanceof Principal\IProxyWrite) {
                     $writeList[] = $listItem;
                 }
             }
             $propFind->set($propRead, new Href($readList));
             $propFind->set($propWrite, new Href($writeList));
         }
     }
     // instanceof IPrincipal
     if ($node instanceof ICalendarObject) {
         // The calendar-data property is not supposed to be a 'real'
         // property, but in large chunks of the spec it does act as such.
         // Therefore we simply expose it as a property.
         $propFind->handle('{' . self::NS_CALDAV . '}calendar-data', function () use($node) {
             $val = $node->get();
             if (is_resource($val)) {
                 $val = stream_get_contents($val);
             }
             // Taking out \r to not screw up the xml output
             return str_replace("\r", "", $val);
         });
     }
 }

作者:BlaBlaNe    项目:hubzill   
/**
  * Fetches properties for a path.
  *
  * This method received a PropFind object, which contains all the
  * information about the properties that need to be fetched.
  *
  * Ususually you would just want to call 'get404Properties' on this object,
  * as this will give you the _exact_ list of properties that need to be
  * fetched, and haven't yet.
  *
  * However, you can also support the 'allprops' property here. In that
  * case, you should check for $propFind->isAllProps().
  *
  * @param string $path
  * @param PropFind $propFind
  * @return void
  */
 function propFind($path, PropFind $propFind)
 {
     if (!$propFind->isAllProps() && count($propFind->get404Properties()) === 0) {
         return;
     }
     $query = 'SELECT name, value, valuetype FROM ' . $this->tableName . ' WHERE path = ?';
     $stmt = $this->pdo->prepare($query);
     $stmt->execute([$path]);
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         if (gettype($row['value']) === 'resource') {
             $row['value'] = stream_get_contents($row['value']);
         }
         switch ($row['valuetype']) {
             case null:
             case self::VT_STRING:
                 $propFind->set($row['name'], $row['value']);
                 break;
             case self::VT_XML:
                 $propFind->set($row['name'], new Complex($row['value']));
                 break;
             case self::VT_OBJECT:
                 $propFind->set($row['name'], unserialize($row['value']));
                 break;
         }
     }
 }

作者:Kevin-Z    项目:vaneDis   
/**
  * Fetches properties for a path.
  *
  * @param string $path
  * @param PropFind $propFind
  * @return void
  */
 public function propFind($path, PropFind $propFind)
 {
     try {
         $node = $this->tree->getNodeForPath($path);
         if (!$node instanceof Node) {
             return;
         }
     } catch (ServiceUnavailable $e) {
         // might happen for unavailable mount points, skip
         return;
     } catch (NotFound $e) {
         // in some rare (buggy) cases the node might not be found,
         // we catch the exception to prevent breaking the whole list with a 404
         // (soft fail)
         \OC::$server->getLogger()->warning('Could not get node for path: \\"' . $path . '\\" : ' . $e->getMessage(), array('app' => 'files'));
         return;
     }
     $requestedProps = $propFind->get404Properties();
     // these might appear
     $requestedProps = array_diff($requestedProps, $this->ignoredProperties);
     if (empty($requestedProps)) {
         return;
     }
     if ($node instanceof Directory && $propFind->getDepth() !== 0) {
         // note: pre-fetching only supported for depth <= 1
         $this->loadChildrenProperties($node, $requestedProps);
     }
     $props = $this->getProperties($node, $requestedProps);
     foreach ($props as $propName => $propValue) {
         $propFind->set($propName, $propValue);
     }
 }

作者:enoch8    项目:owncloud-testserve   
/**
  * 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);
     });
 }

作者:youprofi    项目:casebo   
/**
  * Fetches properties for a path.
  *
  * This method received a PropFind object, which contains all the
  * information about the properties that need to be fetched.
  *
  * Ususually you would just want to call 'get404Properties' on this object,
  * as this will give you the _exact_ list of properties that need to be
  * fetched, and haven't yet.
  *
  * @param string $path
  * @param PropFind $propFind
  * @return void
  */
 public function propFind($path, PropFind $propFind)
 {
     $propertyNames = $propFind->get404Properties();
     if (!$propertyNames) {
         return;
     }
     // error_log("propFind: path($path), " . print_r($propertyNames, true));
     $cachedNodes = \CB\Cache::get('DAVNodes');
     // error_log("propFind: " . print_r($cachedNodes, true));
     $path = trim($path, '/');
     $path = str_replace('\\', '/', $path);
     // Node with $path is not in cached nodes, return
     if (!array_key_exists($path, $cachedNodes)) {
         return;
     }
     $node = $cachedNodes[$path];
     // while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
     //     $propFind->set($row['name'], $row['value']);
     // }
     foreach ($propertyNames as $prop) {
         if ($prop == '{DAV:}creationdate') {
             $dttm = new \DateTime($node['cdate']);
             // $dttm->getTimestamp()
             $propFind->set($prop, \Sabre\HTTP\Util::toHTTPDate($dttm));
         } elseif ($prop == '{urn:schemas-microsoft-com:office:office}modifiedby' or $prop == '{DAV:}getmodifiedby') {
             // This has to be revised, because the User.login differs from User.DisplayName
             // moreover, during an edit, Word will check for File Properties and we
             // tell Word that the file is modified by another user
             // $propFind->set($prop, \CB\User::getDisplayName($node['uid']));
         }
     }
 }

作者:MetallianFR6    项目:myroundcub   
function testPropFindNothingToDo()
 {
     $backend = $this->getBackend();
     $propFind = new PropFind('dir', ['{DAV:}displayname']);
     $propFind->set('{DAV:}displayname', 'foo');
     $backend->propFind('dir', $propFind);
     $this->assertEquals('foo', $propFind->get('{DAV:}displayname'));
 }

作者:BlaBlaNe    项目:hubzill   
function testDontTouchOtherMimeTypes()
 {
     $this->server->httpRequest = new HTTP\Request('GET', '/addressbooks/user1/book1/card1.vcf', ['User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1']);
     $propFind = new PropFind('hello', ['{DAV:}getcontenttype']);
     $propFind->set('{DAV:}getcontenttype', 'text/plain');
     $this->carddavPlugin->propFindLate($propFind, new \Sabre\DAV\SimpleCollection('foo'));
     $this->assertEquals('text/plain', $propFind->get('{DAV:}getcontenttype'));
 }

作者:MetallianFR6    项目:myroundcub   
/**
  * Called during PROPFIND operations.
  *
  * If there's any requested properties that don't have a value yet, this
  * plugin will look in the property storage backend to find them.
  *
  * @param PropFind $propFind
  * @param INode $node
  * @return void
  */
 function propFind(PropFind $propFind, INode $node)
 {
     $path = $propFind->getPath();
     $pathFilter = $this->pathFilter;
     if ($pathFilter && !$pathFilter($path)) {
         return;
     }
     $this->backend->propFind($propFind->getPath(), $propFind);
 }

作者:MetallianFR6    项目:myroundcub   
public function testPropFind()
 {
     $propName = '{http://calendarserver.org/ns/}subscribed-strip-alarms';
     $propFind = new PropFind('foo', [$propName]);
     $propFind->set($propName, null, 200);
     $plugin = new Plugin();
     $plugin->propFind($propFind, new \Sabre\DAV\SimpleCollection('hi'));
     $this->assertFalse(is_null($propFind->get($propName)));
 }

作者:bogolubo    项目:owncollab_talks-   
/**
  * This method is called after most properties have been found
  * it allows us to add in any Lock-related properties
  *
  * @param DAV\PropFind $propFind
  * @param DAV\INode $node
  * @return void
  */
 function propFind(DAV\PropFind $propFind, DAV\INode $node)
 {
     $propFind->handle('{DAV:}supportedlock', function () {
         return new DAV\Property\SupportedLock(!!$this->locksBackend);
     });
     $propFind->handle('{DAV:}lockdiscovery', function () use($propFind) {
         return new DAV\Property\LockDiscovery($this->getLocks($propFind->getPath()));
     });
 }

作者:GitHubUser423    项目:cor   
/**
  * Adds all CardDAV-specific properties
  *
  * @param PropFind $propFind
  * @param INode $node
  * @return void
  */
 function propFind(PropFind $propFind, INode $node)
 {
     $ns = '{http://owncloud.org/ns}';
     if ($node instanceof AddressBook) {
         $propFind->handle($ns . 'groups', function () use($node) {
             return new Groups($node->getContactsGroups());
         });
     }
 }

作者:jakobsac    项目:sabre-da   
/**
  * Fetches properties for a path.
  *
  * This method received a PropFind object, which contains all the
  * information about the properties that need to be fetched.
  *
  * Ususually you would just want to call 'get404Properties' on this object,
  * as this will give you the _exact_ list of properties that need to be
  * fetched, and haven't yet.
  *
  * @param string $path
  * @param PropFind $propFind
  * @return void
  */
 function propFind($path, PropFind $propFind)
 {
     if (!isset($this->data[$path])) {
         return;
     }
     foreach ($this->data[$path] as $name => $value) {
         $propFind->set($name, $value);
     }
 }

作者:BlaBlaNe    项目:hubzill   
/**
  * Triggered after properties have been fetched.
  *
  * @param PropFind $propFind
  * @param INode $node
  * @return void
  */
 function propFind(PropFind $propFind, INode $node)
 {
     // There's a bunch of properties that must appear as a self-closing
     // xml-element. This event handler ensures that this will be the case.
     $props = ['{http://calendarserver.org/ns/}subscribed-strip-alarms', '{http://calendarserver.org/ns/}subscribed-strip-attachments', '{http://calendarserver.org/ns/}subscribed-strip-todos'];
     foreach ($props as $prop) {
         if ($propFind->getStatus($prop) === 200) {
             $propFind->set($prop, '', 200);
         }
     }
 }

作者:GitHubUser423    项目:cor   
function propFind(PropFind $propFind, INode $node)
 {
     /* Overload current-user-principal */
     $propFind->handle('{DAV:}current-user-principal', function () {
         if ($url = parent::getCurrentUserPrincipal()) {
             return new Principal(Principal::HREF, $url . '/');
         } else {
             return new Principal(Principal::UNAUTHENTICATED);
         }
     });
     parent::propFind($propFind, $node);
 }

作者:krekik    项目:sambada   
public function propFind(DAV\PropFind $propFind, DAV\INode $node)
 {
     // Add extra Windows properties to the node:
     if (method_exists($node, 'getIsHidden')) {
         $propFind->set('{DAV:}ishidden', $node->getIsHidden() ? '1' : '0');
     }
     if (method_exists($node, 'getIsReadonly')) {
         $propFind->set('{DAV:}isreadonly', $node->getIsReadonly() ? '1' : '0');
     }
     if (method_exists($node, 'getWin32Props')) {
         $propFind->set('{urn:schemas-microsoft-com:}Win32FileAttributes', $node->getWin32Props());
     }
 }

作者:enoch8    项目:owncloud-testserve   
/**
  * Fetches properties for a path.
  *
  * This method received a PropFind object, which contains all the
  * information about the properties that need to be fetched.
  *
  * Ususually you would just want to call 'get404Properties' on this object,
  * as this will give you the _exact_ list of properties that need to be
  * fetched, and haven't yet.
  *
  * @param string $path
  * @param PropFind $propFind
  * @return void
  */
 function propFind($path, PropFind $propFind)
 {
     $propertyNames = $propFind->get404Properties();
     if (!$propertyNames) {
         return;
     }
     $query = 'SELECT name, value FROM propertystorage WHERE path = ?';
     $stmt = $this->pdo->prepare($query);
     $stmt->execute([$path]);
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $propFind->set($row['name'], $row['value']);
     }
 }

作者:kenw    项目:cor   
/**
  * Fetches properties for a path.
  *
  * @param string $path
  * @param PropFind $propFind
  * @return void
  */
 public function propFind($path, PropFind $propFind)
 {
     $requestedProps = $propFind->get404Properties();
     // these might appear
     $requestedProps = array_diff($requestedProps, $this->ignoredProperties);
     if (empty($requestedProps)) {
         return;
     }
     $props = $this->getProperties($path, $requestedProps);
     foreach ($props as $propName => $propValue) {
         $propFind->set($propName, $propValue);
     }
 }

作者:farukuzu    项目:core-   
/**
  * Adds tags and favorites properties to the response,
  * if requested.
  *
  * @param PropFind $propFind
  * @param \Sabre\DAV\INode $node
  * @return void
  */
 public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
 {
     if (!$node instanceof File && !$node instanceof Directory) {
         return;
     }
     $propFind->handle(self::PROPERTY_NAME_COUNT, function () use($node) {
         return $this->commentsManager->getNumberOfCommentsForObject('files', strval($node->getId()));
     });
     $propFind->handle(self::PROPERTY_NAME_HREF, function () use($node) {
         return $this->getCommentsLink($node);
     });
     $propFind->handle(self::PROPERTY_NAME_UNREAD, function () use($node) {
         return $this->getUnreadCount($node);
     });
 }

作者:stwei    项目:owncloud-cor   
/**
  * Return some dummy response for PROPFIND requests with regard to locking
  *
  * @param PropFind $propFind
  * @param INode $node
  * @return void
  */
 function propFind(PropFind $propFind, INode $node)
 {
     $propFind->handle('{DAV:}supportedlock', function () {
         return new SupportedLock(true);
     });
     $propFind->handle('{DAV:}lockdiscovery', function () use($propFind) {
         return new LockDiscovery([]);
     });
 }

作者:brunomile    项目:owncloud-cor   
/**
  * Adds all ownCloud-specific properties
  *
  * @param PropFind $propFind
  * @param \Sabre\DAV\INode $node
  * @return void
  */
 public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
 {
     if ($node instanceof \OC\Connector\Sabre\Node) {
         $propFind->handle(self::FILEID_PROPERTYNAME, function () use($node) {
             return $node->getFileId();
         });
         $propFind->handle(self::PERMISSIONS_PROPERTYNAME, function () use($node) {
             return $node->getDavPermissions();
         });
         $propFind->handle(self::GETETAG_PROPERTYNAME, function () use($node) {
             return $node->getEtag();
         });
     }
     if ($node instanceof \OC\Connector\Sabre\File) {
         $propFind->handle(self::DOWNLOADURL_PROPERTYNAME, function () use($node) {
             /** @var $node \OC\Connector\Sabre\File */
             $directDownloadUrl = $node->getDirectDownload();
             if (isset($directDownloadUrl['url'])) {
                 return $directDownloadUrl['url'];
             }
             return false;
         });
     }
     if ($node instanceof \OC\Connector\Sabre\Directory) {
         $propFind->handle(self::SIZE_PROPERTYNAME, function () use($node) {
             return $node->getSize();
         });
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号