list.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. $doBreadcrumb = isset( $_GET['breadcrumb'] ) ? true : false;
  9. $data = array();
  10. // Make breadcrumb
  11. if($doBreadcrumb){
  12. $breadcrumb = array();
  13. $pathtohere = "/";
  14. foreach( explode( "/", $dir ) as $i ){
  15. if( $i != "" ){
  16. $pathtohere .= "$i/";
  17. $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
  18. }
  19. }
  20. $breadcrumbNav = new OCP\Template( "files", "part.breadcrumb", "" );
  21. $breadcrumbNav->assign( "breadcrumb", $breadcrumb );
  22. $data['breadcrumb'] = $breadcrumbNav->fetchPage();
  23. }
  24. // make filelist
  25. $files = array();
  26. foreach( OC_Files::getdirectorycontent( $dir ) as $i ){
  27. $i["date"] = OCP\Util::formatDate($i["mtime"] );
  28. $files[] = $i;
  29. }
  30. $list = new OCP\Template( "files", "part.list", "" );
  31. $list->assign( "files", $files, false );
  32. $data = array('files' => $list->fetchPage());
  33. OCP\JSON::success(array('data' => $data));
  34. ?>