本文整理汇总了PHP中OCA\Files\Helper::getFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::getFiles方法的具体用法?PHP Helper::getFiles怎么用?PHP Helper::getFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCA\Files\Helper
的用法示例。
在下文中一共展示了Helper::getFiles方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFileList
/**
* @NoAdminRequired
* @NoCSRFRequired
* @SSOCORS
*/
public function getFileList($dir = null, $sortby = 'name', $sort = false)
{
\OCP\JSON::checkLoggedIn();
\OC::$server->getSession()->close();
// Load the files
$dir = $dir ? (string) $dir : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
try {
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
if (!$dirInfo || !$dirInfo->getType() === 'dir') {
header('HTTP/1.0 404 Not Found');
exit;
}
$data = array();
$baseUrl = \OCP\Util::linkTo('files', 'index.php') . '?dir=';
$permissions = $dirInfo->getPermissions();
$sortDirection = $sort === 'desc';
$mimetypeFilters = '';
$files = [];
if (is_array($mimetypeFilters) && count($mimetypeFilters)) {
$mimetypeFilters = array_unique($mimetypeFilters);
if (!in_array('httpd/unix-directory', $mimetypeFilters)) {
$mimetypeFilters[] = 'httpd/unix-directory';
}
foreach ($mimetypeFilters as $mimetypeFilter) {
$files = array_merge($files, \OCA\Files\Helper::getFiles($dir, $sortby, $sortDirection, $mimetypeFilter));
}
$files = \OCA\Files\Helper::sortFiles($files, $sortby, $sortDirection);
} else {
$files = \OCA\Files\Helper::getFiles($dir, $sortby, $sortDirection);
}
$files = \OCA\Files\Helper::populateTags($files);
$data['directory'] = $dir;
$data['files'] = \OCA\Files\Helper::formatFileInfos($files);
$data['permissions'] = $permissions;
return new DataResponse(array('data' => $data, 'status' => 'success'));
} catch (\OCP\Files\StorageNotAvailableException $e) {
\OCP\Util::logException('files', $e);
return new DataResponse(array('data' => array('exception' => '\\OCP\\Files\\StorageNotAvailableException', 'message' => 'Storage not available'), 'status' => 'error'));
} catch (\OCP\Files\StorageInvalidException $e) {
\OCP\Util::logException('files', $e);
return new DataResponse(array('data' => array('exception' => '\\OCP\\Files\\StorageInvalidException', 'message' => 'Storage invalid'), 'status' => 'error'));
} catch (\Exception $e) {
\OCP\Util::logException('files', $e);
return new DataResponse(array('data' => array('exception' => '\\Exception', 'message' => 'Unknown error'), 'status' => 'error'));
}
}
示例2: isset
}
$sortAttribute = isset($_GET['sort']) ? $_GET['sort'] : 'name';
$sortDirection = isset($_GET['sortdirection']) ? $_GET['sortdirection'] === 'desc' : false;
$data = \OCA\Files_Sharing\Helper::setupFromToken($token, $relativePath, $password);
$linkItem = $data['linkItem'];
// Load the files
$dir = $data['realPath'];
$dir = \OC\Files\Filesystem::normalizePath($dir);
if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
\OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
\OCP\JSON::error(array('success' => false));
exit;
}
$data = array();
// make filelist
$files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection);
$formattedFiles = array();
foreach ($files as $file) {
$entry = \OCA\Files\Helper::formatFileInfo($file);
unset($entry['directory']);
// for now
$entry['permissions'] = \OCP\PERMISSION_READ;
$formattedFiles[] = $entry;
}
$data['directory'] = $relativePath;
$data['files'] = $formattedFiles;
$data['dirToken'] = $linkItem['token'];
$permissions = $linkItem['permissions'];
// if globally disabled
if (OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes') === 'no') {
// only allow reading
示例3: getlogo
public function getlogo()
{
$userfiles = \OCA\Files\Helper::getFiles('ProjectLogo');
foreach ($userfiles as $f => $file) {
$userfiles[$f] = \OCA\Files\Helper::formatFileInfo($file);
$userfiles[$f]['mtime'] = $userfiles[$f]['mtime'] / 1000;
}
$params = ['user' => $this->userId, 'files' => $userfiles, 'error' => null, 'errorinfo' => ''];
return new DataResponse($params);
}
示例4: isset
// Init owncloud
OCP\JSON::checkLoggedIn();
// Load the files
$dir = isset($_GET['dir']) ? (string) $_GET['dir'] : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
header("HTTP/1.0 404 Not Found");
exit;
}
$doBreadcrumb = isset($_GET['breadcrumb']);
$data = array();
$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
$permissions = \OCA\Files\Helper::getDirPermissions($dir);
// Make breadcrumb
if ($doBreadcrumb) {
$breadcrumb = \OCA\Files\Helper::makeBreadcrumb($dir);
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
$breadcrumbNav->assign('baseURL', $baseUrl);
$data['breadcrumb'] = $breadcrumbNav->fetchPage();
}
// make filelist
$files = \OCA\Files\Helper::getFiles($dir);
$list = new OCP\Template("files", "part.list", "");
$list->assign('files', $files, false);
$list->assign('baseURL', $baseUrl, false);
$list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/')));
$list->assign('isPublic', false);
$data['files'] = $list->fetchPage();
$data['permissions'] = $permissions;
OCP\JSON::success(array('data' => $data));
示例5: getfolderfiles
public function getfolderfiles($folderid)
{
$files = $this->connect->files();
$path = $files->getFolderPath($folderid, $this->userId);
//$userfiles = \OCA\Files\Helper::getFiles('../'.$path);
$userfiles = \OCA\Files\Helper::getFiles('/' . $path);
foreach ($userfiles as $f => $file) {
$userfiles[$f] = \OCA\Files\Helper::formatFileInfo($file);
$userfiles[$f]['mtime'] = $userfiles[$f]['mtime'] / 1000;
}
$params = array('files' => $userfiles, 'folder' => $userfiles, 'requesttoken' => !\OC_Util::isCallRegistered() ? '' : \OC_Util::callRegister());
$view = Helper::renderPartial($this->appName, 'api.folderfiles', $params);
//$view = "User files!";
$params = array('user' => $this->userId, 'files' => $userfiles, 'view' => $view, 'requesttoken' => !\OC_Util::isCallRegistered() ? '' : \OC_Util::callRegister());
return new DataResponse($params);
}
示例6: ListTorrentFiles
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function ListTorrentFiles()
{
\OCP\JSON::setContentTypeHeader('application/json');
try {
if (!$this->AllowProtocolBT && !\OC_User::isAdminUser($this->CurrentUID)) {
throw new \Exception((string) $this->L10N->t('You are not allowed to use the BitTorrent protocol'));
}
if (!\OC\Files\Filesystem::is_dir($this->TorrentsFolder)) {
\OC\Files\Filesystem::mkdir($this->TorrentsFolder);
}
$this->TorrentsFolder = \OC\Files\Filesystem::normalizePath($this->TorrentsFolder);
$Files = \OCA\Files\Helper::getFiles($this->TorrentsFolder, 'name', 'desc', 'application/octet-stream');
$Files = \OCA\Files\Helper::formatFileInfos($Files);
return new JSONResponse(array('ERROR' => false, 'FILES' => $Files));
} catch (Exception $E) {
return new JSONResponse(array('ERROR' => true, 'MESSAGE' => $E->getMessage()));
}
}
示例7: ListTorrentFiles
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function ListTorrentFiles()
{
\OCP\JSON::setContentTypeHeader('application/json');
try {
if (!\OC\Files\Filesystem::is_dir($this->TorrentsFolder)) {
\OC\Files\Filesystem::mkdir($this->TorrentsFolder);
}
$this->TorrentsFolder = \OC\Files\Filesystem::normalizePath($this->TorrentsFolder);
$Files = \OCA\Files\Helper::getFiles($this->TorrentsFolder, 'name', 'desc');
$Files = \OCA\Files\Helper::formatFileInfos($Files);
return new JSONResponse(array('ERROR' => false, 'FILES' => $Files));
} catch (Exception $E) {
return new JSONResponse(array('ERROR' => true, 'MESSAGE' => $E->getMessage()));
}
}
示例8: createFileListTree
public function createFileListTree($path = '/')
{
$files = \OCA\Files\Helper::getFiles($path);
if (is_array($files)) {
foreach ($files as $f => $file) {
if ($file['type'] == 'dir') {
$this->createFileListTree(substr($file['path'], 6));
} else {
$fdata = \OCA\Files\Helper::formatFileInfo($file);
$fdata['mtime'] = $file['mtime'] / 1000;
$fdata['path'] = substr($file['path'], 6);
array_push($this->listtree, $fdata);
}
}
}
return $this->listtree;
}