2011-03-04 01:08:54 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Init owncloud
|
|
|
|
require_once('../../lib/base.php');
|
2011-04-17 17:59:06 +04:00
|
|
|
require_once('../../lib/template.php');
|
2011-03-04 01:08:54 +03:00
|
|
|
|
|
|
|
// We send json data
|
|
|
|
header( "Content-Type: application/jsonrequest" );
|
|
|
|
|
|
|
|
// Check if we are a user
|
|
|
|
if( !OC_USER::isLoggedIn()){
|
|
|
|
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load the files
|
|
|
|
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
|
2011-04-17 17:59:06 +04:00
|
|
|
$doBreadcrumb = isset( $_GET['breadcrumb'] ) ? true : false;
|
|
|
|
$data = array();
|
2011-03-04 01:08:54 +03:00
|
|
|
|
2011-04-17 17:59:06 +04:00
|
|
|
// Make breadcrumb
|
|
|
|
if($doBreadcrumb){
|
|
|
|
$breadcrumb = array();
|
|
|
|
$pathtohere = "/";
|
|
|
|
foreach( explode( "/", $dir ) as $i ){
|
|
|
|
if( $i != "" ){
|
|
|
|
$pathtohere .= "$i/";
|
|
|
|
$breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$breadcrumbNav = new OC_TEMPLATE( "files", "part.breadcrumb", "" );
|
|
|
|
$breadcrumbNav->assign( "breadcrumb", $breadcrumb );
|
|
|
|
|
|
|
|
$data['breadcrumb'] = $breadcrumbNav->fetchPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
// make filelist
|
2011-03-04 01:08:54 +03:00
|
|
|
$files = array();
|
|
|
|
foreach( OC_FILES::getdirectorycontent( $dir ) as $i ){
|
2011-04-17 17:59:06 +04:00
|
|
|
$i["date"] = OC_UTIL::formatDate($i["mtime"] );
|
2011-03-04 01:08:54 +03:00
|
|
|
$files[] = $i;
|
|
|
|
}
|
|
|
|
|
2011-04-17 17:59:06 +04:00
|
|
|
$list = new OC_TEMPLATE( "files", "part.list", "" );
|
|
|
|
$list->assign( "files", $files );
|
|
|
|
$data = array('files' => $list->fetchPage());
|
2011-03-04 01:08:54 +03:00
|
|
|
|
2011-04-17 17:59:06 +04:00
|
|
|
echo json_encode( array( "status" => "success", "data" => $data));
|
2011-03-04 01:08:54 +03:00
|
|
|
|
|
|
|
?>
|