mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-23116, added file type icon to private file block, stop using the short file name from filemanager
This commit is contained in:
parent
dd0566ebaf
commit
1230b9c96e
@ -52,18 +52,23 @@ class block_private_files_renderer extends plugin_renderer_base {
|
||||
*/
|
||||
protected function htmllize_tree($tree, $dir) {
|
||||
global $CFG;
|
||||
$yuiconfig = array();
|
||||
$yuiconfig['type'] = 'html';
|
||||
|
||||
if (empty($dir['subdirs']) and empty($dir['files'])) {
|
||||
return '';
|
||||
}
|
||||
$result = '<ul>';
|
||||
foreach ($dir['subdirs'] as $subdir) {
|
||||
$result .= '<li>'.s($subdir['dirname']).' '.$this->htmllize_tree($tree, $subdir).'</li>';
|
||||
$image = $this->output->pix_icon("/f/folder", $subdir['dirname'], 'moodle', array('class'=>'icon'));
|
||||
$result .= '<li yuiConfig=\''.json_encode($yuiconfig).'\'><div>'.$image.' '.s($subdir['dirname']).'</div> '.$this->htmllize_tree($tree, $subdir).'</li>';
|
||||
}
|
||||
foreach ($dir['files'] as $file) {
|
||||
$url = file_encode_url("$CFG->wwwroot/pluginfile.php", '/'.$tree->context->id.'/user/private'.$file->get_filepath().$file->get_filename(), true);
|
||||
$filename = $file->get_filename();
|
||||
$result .= '<li><span>'.html_writer::link($url, $filename).'</span></li>';
|
||||
$icon = substr(mimeinfo("icon", $filename), 0, -4);
|
||||
$image = $this->output->pix_icon("/f/$icon", $filename, 'moodle', array('class'=>'icon'));
|
||||
$result .= '<li yuiConfig=\''.json_encode($yuiconfig).'\'><div>'.$image.' '.html_writer::link($url, $filename).'</div></li>';
|
||||
}
|
||||
$result .= '</ul>';
|
||||
|
||||
|
@ -611,11 +611,6 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
|
||||
$item->fullname = trim($item->filename, '/');
|
||||
$filesize = $file->get_filesize();
|
||||
$item->filesize = $filesize ? display_size($filesize) : '';
|
||||
if (strlen($item->fullname) >= $maxlength) {
|
||||
$item->shortname = trim(substr($item->fullname, 0, $maxlength)).'...';
|
||||
} else {
|
||||
$item->shortname = $item->fullname;
|
||||
}
|
||||
|
||||
$icon = mimeinfo_from_type('icon', $file->get_mimetype());
|
||||
$icon = str_replace('.gif', '', $icon);
|
||||
@ -634,11 +629,6 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
|
||||
$item->type = 'folder';
|
||||
$foldername = explode('/', trim($item->filepath, '/'));
|
||||
$item->fullname = trim(array_pop($foldername), '/');
|
||||
if (strlen($item->fullname) >= $maxlength) {
|
||||
$item->shortname = trim(substr($item->fullname, 0, $maxlength)).'...';
|
||||
} else {
|
||||
$item->shortname = $item->fullname;
|
||||
}
|
||||
} else {
|
||||
// do NOT use file browser here!
|
||||
$item->url = file_draftfile_url($draftitemid, $item->filepath, $item->filename);
|
||||
|
@ -386,12 +386,11 @@ M.form_filemanager.init = function(Y, options) {
|
||||
break;
|
||||
}
|
||||
var fullname = list[i].fullname;
|
||||
var shorten = list[i].shortname;
|
||||
|
||||
if (list[i].sortorder == 1) {
|
||||
html = html.replace('___fullname___', '<strong><a title="'+fullname+'" href="'+url+'" id="'+fileid+'"><img src="'+list[i].icon+'" /> ' + shorten + '</a></strong>');
|
||||
html = html.replace('___fullname___', '<strong><a title="'+fullname+'" href="'+url+'" id="'+fileid+'"><img src="'+list[i].icon+'" /> ' + fullname + '</a></strong>');
|
||||
} else {
|
||||
html = html.replace('___fullname___', '<a title="'+fullname+'" href="'+url+'" id="'+fileid+'"><img src="'+list[i].icon+'" /> ' + shorten + '</a>');
|
||||
html = html.replace('___fullname___', '<a title="'+fullname+'" href="'+url+'" id="'+fileid+'"><img src="'+list[i].icon+'" /> ' + fullname + '</a>');
|
||||
}
|
||||
html = html.replace('___action___', '<span class="fm-menuicon" id="'+action+'"><img alt="▶" src="'+M.util.image_url('i/menu')+'" /></span>');
|
||||
html = '<li id="'+htmlid+'">'+html+'</li>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user