MDL-31901: Allow FileManager to re-use FilePicker JS code for view modes:

- when loading core_filepicker we extend the Node element with functions necessary to display files list in different view modes;
- repository/filepicker.js is changed to use those functions;
- FileManager now has three different view modes (icon view, tree view and table view), JS code is re-used from FilePicker;
- files in FileManager no longer have context menu, they have one popup Widget with different actions instead;
- Added more templates for JS code to FileManager, use similar CSS class names as FilePicker;
- lib/filelib.php : fixed double slashes in path, return more data about files;
- lib/form/filemanager.php : pass information to FileManager about available licenses and default author;
- repository/draftfiles_ajax.php : return information about directory tree for file moving UI in FileManager, return formatted information;
- repository/lib.php : function repository::prepare_listing() now can work also with draftarea files listing;
This commit is contained in:
Marina Glancy
2012-05-21 11:57:52 +08:00
parent d1d186917c
commit e709ddd29c
11 changed files with 1110 additions and 792 deletions
+9 -2
View File
@@ -566,13 +566,13 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
$data->path[] = array('name'=>get_string('files'), 'path'=>'/');
// will be used to build breadcrumb
$trail = '';
$trail = '/';
if ($filepath !== '/') {
$filepath = file_correct_filepath($filepath);
$parts = explode('/', $filepath);
foreach ($parts as $part) {
if ($part != '' && $part != null) {
$trail .= ('/'.$part.'/');
$trail .= ($part.'/');
$data->path[] = array('name'=>$part, 'path'=>$trail);
}
}
@@ -587,11 +587,16 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
$item->filepath = $file->get_filepath();
$item->fullname = trim($item->filename, '/');
$filesize = $file->get_filesize();
$item->size = $filesize ? $filesize : null;
$item->filesize = $filesize ? display_size($filesize) : '';
$icon = mimeinfo_from_type('icon', $file->get_mimetype());
$item->icon = $OUTPUT->pix_url('f/' . $icon)->out();
$item->sortorder = $file->get_sortorder();
$item->author = $file->get_author();
$item->license = $file->get_license();
$item->datemodified = $file->get_timemodified();
$item->datecreated = $file->get_timecreated();
if ($icon == 'zip') {
$item->type = 'zip';
@@ -605,9 +610,11 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
$item->type = 'folder';
$foldername = explode('/', trim($item->filepath, '/'));
$item->fullname = trim(array_pop($foldername), '/');
$item->thumbnail = $OUTPUT->pix_url('f/folder-32')->out(false);
} else {
// do NOT use file browser here!
$item->url = moodle_url::make_draftfile_url($draftitemid, $item->filepath, $item->filename)->out();
$item->thumbnail = $OUTPUT->pix_url(file_extension_icon($item->filename, 32))->out(false);
}
$list[] = $item;
}