/** * Returns the path which goes from the file, up to the root folder of the Gallery: * current_folder/my_file * * That root folder changes when folders are shared publicly * * @param File|Folder $node * * @return string */ public function getPathFromVirtualRoot($node) { $path = $node->getPath(); $nodeType = $node->getType(); // Needed because fromRootToFolder always ends with a slash if ($nodeType === 'dir') { $path .= '/'; } $path = str_replace($this->fromRootToFolder, '', $path); $path = rtrim($path, '/'); return $path; }
/** * test if file is a note * * @param \OCP\Files\File $file * @return bool */ private function isNote($file) { $allowedExtensions = ['txt', 'org', 'markdown', 'md', 'note']; if ($file->getType() !== 'file') { return false; } if (!in_array(pathinfo($file->getName(), PATHINFO_EXTENSION), $allowedExtensions)) { return false; } return true; }