nextcloud/apps/files/ajax/list.php

45 lines
1.0 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'] : '';
$doBreadcrumb = isset( $_GET['breadcrumb'] ) ? true : false;
$data = array();
// Make breadcrumb
2012-08-29 02:50:12 +04:00
if($doBreadcrumb) {
$breadcrumb = array();
$pathtohere = "/";
2012-09-07 17:22:01 +04:00
foreach( explode( "/", $dir ) as $i ) {
2012-08-29 02:50:12 +04:00
if( $i != "" ) {
$pathtohere .= "$i/";
$breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
}
}
2012-08-29 10:42:49 +04:00
2012-05-07 01:00:36 +04:00
$breadcrumbNav = new OCP\Template( "files", "part.breadcrumb", "" );
$breadcrumbNav->assign( "breadcrumb", $breadcrumb );
2012-08-29 10:42:49 +04:00
$data['breadcrumb'] = $breadcrumbNav->fetchPage();
}
// make filelist
$files = array();
2012-10-27 01:05:02 +04:00
foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $i ) {
2012-05-01 23:07:08 +04:00
$i["date"] = OCP\Util::formatDate($i["mtime"] );
$files[] = $i;
}
2012-05-07 01:00:36 +04:00
$list = new OCP\Template( "files", "part.list", "" );
2012-06-11 21:07:51 +04:00
$list->assign( "files", $files, false );
$data = array('files' => $list->fetchPage());
2012-05-03 14:23:29 +04:00
OCP\JSON::success(array('data' => $data));