list.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // only need filesystem apps
  3. $RUNTIME_APPTYPES=array('filesystem');
  4. // Init owncloud
  5. OCP\JSON::checkLoggedIn();
  6. // Load the files
  7. $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
  8. $dir = \OC\Files\Filesystem::normalizePath($dir);
  9. $dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
  10. if (!$dirInfo->getType() === 'dir') {
  11. header("HTTP/1.0 404 Not Found");
  12. exit();
  13. }
  14. $doBreadcrumb = isset($_GET['breadcrumb']);
  15. $data = array();
  16. $baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
  17. $permissions = $dirInfo->getPermissions();
  18. // Make breadcrumb
  19. if($doBreadcrumb) {
  20. $breadcrumb = \OCA\Files\Helper::makeBreadcrumb($dir);
  21. $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
  22. $breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
  23. $breadcrumbNav->assign('baseURL', $baseUrl);
  24. $data['breadcrumb'] = $breadcrumbNav->fetchPage();
  25. }
  26. // make filelist
  27. $files = \OCA\Files\Helper::getFiles($dir);
  28. $list = new OCP\Template("files", "part.list", "");
  29. $list->assign('files', $files, false);
  30. $list->assign('baseURL', $baseUrl, false);
  31. $list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/')));
  32. $list->assign('isPublic', false);
  33. $data['files'] = $list->fetchPage();
  34. $data['permissions'] = $permissions;
  35. OCP\JSON::success(array('data' => $data));