server/files/ajax/list.php

44 lines
992 B
PHP
Raw Normal View History

<?php
// Init owncloud
require_once('../../lib/base.php');
OC_JSON::checkLoggedIn();
// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
$doBreadcrumb = isset( $_GET['breadcrumb'] ) ? true : false;
$data = array();
// Make breadcrumb
if($doBreadcrumb){
$breadcrumb = array();
$pathtohere = "/";
foreach( explode( "/", $dir ) as $i ){
if( $i != "" ){
$pathtohere .= "$i/";
$breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
}
}
2011-07-29 19:36:03 +00:00
$breadcrumbNav = new OC_Template( "files", "part.breadcrumb", "" );
$breadcrumbNav->assign( "breadcrumb", $breadcrumb );
$data['breadcrumb'] = $breadcrumbNav->fetchPage();
}
// make filelist
$files = array();
2011-07-29 19:36:03 +00:00
foreach( OC_Files::getdirectorycontent( $dir ) as $i ){
$i["date"] = OC_Util::formatDate($i["mtime"] );
$files[] = $i;
}
2011-07-29 19:36:03 +00:00
$list = new OC_Template( "files", "part.list", "" );
$list->assign( "files", $files );
$data = array('files' => $list->fetchPage());
OC_JSON::success(array('data' => $data));
?>