/**
  * Returns an ArrayCollection with the contents of the current requested folder
  *
  * @param string $folder Request foldername relative to root folder
  *
  * @return ArrayCollection|boolean Content of folder as array collection. If folder does not exist false
  * @throws \Sabre\DAV\Exception
  */
 public function getDirectoryContents($folder = '')
 {
     try {
         return $this->parsePropResult($this->client->propFind($folder, array('{DAV:}resourcetype', '{DAV:}getcontentlength', '{DAV:}getlastmodified', '{DAV:}quota-used-bytes', '{DAV:}getcontenttype'), 1));
     } catch (Exception $e) {
         return false;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function listContents($directory = '', $recursive = false)
 {
     $location = $this->applyPathPrefix($directory);
     $response = $this->client->propFind($location, ['{DAV:}displayname', '{DAV:}getcontentlength', '{DAV:}getcontenttype', '{DAV:}getlastmodified'], 1);
     array_shift($response);
     $result = [];
     foreach ($response as $path => $object) {
         $path = $this->removePathPrefix($path);
         $object = $this->normalizeObject($object, $path);
         $result[] = $object;
         if ($recursive && $object['type'] === 'dir') {
             $result = array_merge($result, $this->listContents($object['path'], true));
         }
     }
     return $result;
 }
Beispiel #3
0
 public function pingRemoteDAVPoint()
 {
     $fullPath = rtrim($this->getOcsDavUrl(), "/") . "/" . $this->getDocumentName();
     $parts = parse_url($fullPath);
     $client = new DAV\Client(array('baseUri' => $parts["scheme"] . "://" . $parts["host"], 'userName' => $this->getOcsToken(), 'password' => ''));
     try {
         $result = $client->propFind($parts["path"], ['{DAV:}getlastmodified', '{DAV:}getcontentlength', '{DAV:}resourcetype']);
     } catch (Exception\NotFound $e) {
         return false;
     } catch (Exception $e) {
         return false;
     }
     /**
      * @var \Sabre\DAV\Property\ResourceType $resType;
      */
     $resType = $result["{DAV:}resourcetype"];
     if ($resType->is("{DAV:}collection")) {
         $this->setDocumentIsLeaf(false);
     } else {
         $this->setDocumentIsLeaf(true);
     }
     $this->documentTypeResolved = true;
     return true;
 }