server/apps/files/ajax/list.php

49 lines
1.3 KiB
PHP
Raw Normal View History

<?php
// only need filesystem apps
$RUNTIME_APPTYPES=array('filesystem');
// Init owncloud
2012-05-03 10:23:29 +00:00
OCP\JSON::checkLoggedIn();
// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
$dir = \OC\Files\Filesystem::normalizePath($dir);
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
if (!$dirInfo->getType() === 'dir') {
header("HTTP/1.0 404 Not Found");
exit();
}
2013-08-17 21:38:26 +00:00
$doBreadcrumb = isset($_GET['breadcrumb']);
$data = array();
$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
$permissions = $dirInfo->getPermissions();
// Make breadcrumb
2012-08-28 22:50:12 +00:00
if($doBreadcrumb) {
2013-09-20 14:46:33 +00:00
$breadcrumb = \OCA\Files\Helper::makeBreadcrumb($dir);
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
$breadcrumbNav->assign('baseURL', $baseUrl);
2012-08-29 06:42:49 +00:00
$data['breadcrumb'] = $breadcrumbNav->fetchPage();
}
// make filelist
2013-09-20 14:46:33 +00:00
$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;
2012-05-03 10:23:29 +00:00
OCP\JSON::success(array('data' => $data));