/** * Returns a list of files for a folder. * * @param string $path * * @return array|null */ protected function getFiles($path) { if (!$this->getFile($path)) { return null; } //todo, create new option 'show hidden files' in user settings and depend on that $files = $this->webFilesystem->getFiles($path); return $this->prepareFiles($files); }
/** * {@inheritDoc} */ public function getBranch($pk = null, Condition $condition = null, $depth = 1, $scope = null, $options = null) { if ($pk) { $path = $this->getPathFromPK($pk); } else { $path = '/'; } if ($depth === null) { $depth = 1; } try { $files = $this->webFilesystem->getFiles($path); } catch (NotADirectoryException $e) { return null; } $c = 0; // $offset = $options['offset']; // $limit = $options['limit']; $result = array(); $blacklistedFiles = array(); $showHiddenFiles = false; //todo foreach ($files as $file) { $file = $file->toArray(); if (isset($blacklistedFiles[$file['path']]) | (!$showHiddenFiles && substr($file['name'], 0, 1) == '.')) { continue; } if ($condition && $condition->hasRules() && !$condition->satisfy($file, 'jarves/file')) { continue; } $file['writeAccess'] = $this->acl->isUpdatable('jarves/file', array('path' => $file['path'])); $c++; // if ($offset && $offset >= $c) { // continue; // } // if ($limit && $limit < $c) { // break; // } if ($depth > 0) { $children = array(); if ($file['type'] == 'dir') { try { $children = self::getBranch(array('path' => $file['path']), $condition, $depth - 1); } catch (FileNotFoundException $e) { $children = null; } } $file['_childrenCount'] = count($children); if ($depth > 1 && $file['type'] == 'dir') { $file['_children'] = $children; } } $result[] = $file; } return $result; }