/** * @return string */ public function getDavPermissions() { $p = ''; if ($this->info->isShared()) { $p .= 'S'; } if ($this->info->isShareable()) { $p .= 'R'; } if ($this->info->isMounted()) { $p .= 'M'; } if ($this->info->isDeletable()) { $p .= 'D'; } if ($this->info->isDeletable()) { $p .= 'NV'; // Renameable, Moveable } if ($this->info->getType() === \OCP\Files\FileInfo::TYPE_FILE) { if ($this->info->isUpdateable()) { $p .= 'W'; } } else { if ($this->info->isCreatable()) { $p .= 'CK'; } } return $p; }
/** * Determine icon for a given file * * @param \OCP\Files\FileInfo $file file info * @return string icon URL */ public static function determineIcon($file) { if ($file['type'] === 'dir') { $icon = \OC_Helper::mimetypeIcon('dir'); // TODO: move this part to the client side, using mountType if ($file->isShared()) { $icon = \OC_Helper::mimetypeIcon('dir-shared'); } elseif ($file->isMounted()) { $icon = \OC_Helper::mimetypeIcon('dir-external'); } } else { $icon = \OC_Helper::mimetypeIcon($file->getMimetype()); } return substr($icon, 0, -3) . 'svg'; }
/** * Formats the file info to be returned as JSON to the client. * * @param \OCP\Files\FileInfo $i * @return array formatted file info */ public static function formatFileInfo(FileInfo $i) { $entry = array(); $entry['id'] = $i['fileid']; $entry['parentId'] = $i['parent']; $entry['mtime'] = $i['mtime'] * 1000; // only pick out the needed attributes $entry['name'] = $i->getName(); $entry['permissions'] = $i['permissions']; $entry['mimetype'] = $i['mimetype']; $entry['size'] = $i['size']; $entry['type'] = $i['type']; $entry['etag'] = $i['etag']; if (isset($i['tags'])) { $entry['tags'] = $i['tags']; } if (isset($i['displayname_owner'])) { $entry['shareOwner'] = $i['displayname_owner']; } if (isset($i['is_share_mount_point'])) { $entry['isShareMountPoint'] = $i['is_share_mount_point']; } $mountType = null; if ($i->isShared()) { $mountType = 'shared'; } else { if ($i->isMounted()) { $mountType = 'external'; } } if ($mountType !== null) { if ($i->getInternalPath() === '') { $mountType .= '-root'; } $entry['mountType'] = $mountType; } if (isset($i['extraData'])) { $entry['extraData'] = $i['extraData']; } return $entry; }