Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-32639 files: Improved File Manager download and zip support

Conflicts:

	lib/filestorage/zip_packer.php
  • Loading branch information...
commit aa0cd4a7ef2329cee1c4cc2ae394a34dd37a14e7 1 parent 785e3de
@FMCorz FMCorz authored
View
2  lib/form/filemanager.js
@@ -220,9 +220,9 @@ M.form_filemanager.init = function(Y, options) {
params: {'filepath':filepath},
callback: function(id, obj, args) {
scope.filecount = obj.filecount;
- scope.check_buttons();
scope.options = obj;
scope.lazyloading = {};
+ scope.check_buttons();
scope.render(obj);
}
}, true);
View
9 repository/draftfiles_ajax.php
@@ -219,7 +219,7 @@
$file = $fs->get_file($user_context->id, 'user', 'draft', $draftid, $filepath, '.');
$parent_path = $file->get_parent_directory()->get_filepath();
-
+
$filepath = explode('/', trim($file->get_filepath(), '/'));
$filepath = array_pop($filepath);
@@ -245,11 +245,10 @@
$stored_file = $fs->get_file($user_context->id, 'user', 'draft', $draftid, $filepath, '.');
if ($filepath === '/') {
- $parent_path = '/';
$filename = get_string('files').'.zip';
} else {
- $parent_path = $stored_file->get_parent_directory()->get_filepath();
- $filename = trim($filepath, '/').'.zip';
+ $filename = explode('/', trim($filepath, '/'));
+ $filename = array_pop($filename) . '.zip';
}
// archive compressed file to an unused draft area
@@ -257,7 +256,7 @@
if ($newfile = $zipper->archive_to_storage(array('/' => $stored_file), $user_context->id, 'user', 'draft', $newdraftitemid, '/', $filename, $USER->id)) {
$return = new stdClass();
$return->fileurl = moodle_url::make_draftfile_url($newdraftitemid, '/', $filename)->out();
- $return->filepath = $parent_path;
+ $return->filepath = $filepath;
echo json_encode($return);
} else {
echo json_encode(false);
View
24 repository/draftfiles_manager.php
@@ -139,17 +139,17 @@
$zipper = new zip_packer();
$file = $fs->get_file($user_context->id, 'user', 'draft', $itemid, $draftpath, '.');
- if ($file->get_parent_directory()) {
- $parent_path = $file->get_parent_directory()->get_filepath();
- $filename = trim($draftpath, '/').'.zip';
- } else {
- $parent_path = '/';
+ if ($draftpath === '/') {
$filename = get_string('files').'.zip';
+ } else {
+ $filename = explode('/', trim($draftpath, '/'));
+ $filename = array_pop($filename) . '.zip';
}
- if ($newfile = $zipper->archive_to_storage(array('/' => $file), $user_context->id, 'user', 'draft', $itemid, $parent_path, $filename, $USER->id)) {
- $fileurl = moodle_url::make_draftfile_url($itemid, '/', $filename)->out();
- header('Location: ' . $fileurl );
+ $newdraftitemid = file_get_unused_draft_itemid();
+ if ($newfile = $zipper->archive_to_storage(array('/' => $file), $user_context->id, 'user', 'draft', $newdraftitemid, '/', $filename, $USER->id)) {
+ $fileurl = moodle_url::make_draftfile_url($newdraftitemid, '/', $filename)->out();
+ header('Location: ' . $fileurl);
} else {
print_error('cannotdownloaddir', 'repository');
}
@@ -271,7 +271,7 @@
$path = '/' . trim($draftpath, '/') . '/';
$parts = explode('/', $path);
foreach ($parts as $part) {
- if (!empty($part)) {
+ if ($part != '') {
$trail .= ('/'.$part.'/');
$data->path[] = array('name'=>$part, 'path'=>$trail);
$home_url->param('draftpath', $trail);
@@ -297,8 +297,10 @@
$home_url->param('action', 'mkdirform');
echo ' <a href="'.$home_url->out().'">'.get_string('makeafolder', 'moodle').'</a>';
}
- $home_url->param('action', 'downloaddir');
- echo html_writer::link($home_url, get_string('downloadfolder', 'repository'), array('target'=>'_blank'));
+ if (!empty($files->list)) {
+ $home_url->param('action', 'downloaddir');
+ echo ' ' . html_writer::link($home_url, get_string('downloadfolder', 'repository'), array('target'=>'_blank'));
+ }
}
echo '</div>';
View
1  theme/base/style/filemanager.css
@@ -268,6 +268,7 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
.filemanager.fm-loaded .filemanager-loading {display:none;}
.filemanager.fm-maxfiles .fp-btn-add {display:none;}
.filemanager.fm-maxfiles .dndupload-message {display:none;}
+.filemanager.fm-noitems .fp-btn-download,
.filemanager.fm-nofiles .fp-btn-download {display:none;}
.filemanager .fm-empty-container {display:none;}
.filemanager.fm-noitems .filemanager-container .fp-content {display:none;}
Please sign in to comment.
Something went wrong with that request. Please try again.