2012-04-02 21:39:24 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// only need filesystem apps
|
|
|
|
$RUNTIME_APPTYPES=array('filesystem');
|
|
|
|
|
|
|
|
// Init owncloud
|
2012-04-17 21:31:29 +04:00
|
|
|
|
2012-08-29 02:50:12 +04:00
|
|
|
require_once 'lib/template.php';
|
2012-04-02 21:39:24 +04:00
|
|
|
|
2012-05-03 14:23:29 +04:00
|
|
|
OCP\JSON::checkLoggedIn();
|
2012-04-02 21:39:24 +04:00
|
|
|
|
|
|
|
// Load the files
|
|
|
|
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
|
2013-09-05 20:40:55 +04:00
|
|
|
$mimetypes = isset($_GET['mimetypes']) ? array_unique(json_decode($_GET['mimetypes'], true)) : '';
|
2012-04-02 21:39:24 +04:00
|
|
|
|
|
|
|
// make filelist
|
|
|
|
$files = array();
|
2013-05-17 06:54:08 +04:00
|
|
|
// If a type other than directory is requested first load them.
|
2013-09-05 20:40:55 +04:00
|
|
|
if($mimetypes && !in_array('httpd/unix-directory', $mimetypes)) {
|
2013-05-17 06:54:08 +04:00
|
|
|
foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, 'httpd/unix-directory' ) as $i ) {
|
|
|
|
$i["date"] = OCP\Util::formatDate($i["mtime"] );
|
2013-09-05 20:40:55 +04:00
|
|
|
$i['mimetype_icon'] = ($i['type'] == 'dir')
|
|
|
|
? \mimetype_icon('dir')
|
|
|
|
: \mimetype_icon($i['mimetype']);
|
2013-05-17 06:54:08 +04:00
|
|
|
$files[] = $i;
|
|
|
|
}
|
|
|
|
}
|
2013-09-05 18:54:12 +04:00
|
|
|
|
2013-09-05 20:40:55 +04:00
|
|
|
if (is_array($mimetypes) && count($mimetypes)) {
|
|
|
|
foreach ($mimetypes as $mimetype) {
|
2013-09-05 18:54:12 +04:00
|
|
|
foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, $mimetype ) as $i ) {
|
|
|
|
$i["date"] = OCP\Util::formatDate($i["mtime"]);
|
|
|
|
$i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']);
|
|
|
|
$files[] = $i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2013-09-05 20:40:55 +04:00
|
|
|
foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $i ) {
|
|
|
|
$i["date"] = OCP\Util::formatDate($i["mtime"]);
|
2013-09-05 18:54:12 +04:00
|
|
|
$i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']);
|
|
|
|
$files[] = $i;
|
|
|
|
}
|
2012-04-02 21:39:24 +04:00
|
|
|
}
|
|
|
|
|
2013-09-05 20:40:55 +04:00
|
|
|
OC_JSON::success(array('data' => $files));
|