nextcloud/apps/files/ajax/list.php

44 lines
1.1 KiB
PHP
Raw Normal View History

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