Skip to content

Commit

Permalink
MDL-23116, added file type icon to private file block, stop using the…
Browse files Browse the repository at this point in the history
… short file name from filemanager
  • Loading branch information
Dongsheng Cai committed Jul 8, 2010
1 parent dd0566e commit 1230b9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
9 changes: 7 additions & 2 deletions blocks/private_files/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,23 @@ public function render_private_files_tree(private_files_tree $tree) {
*/
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>';

Expand Down
10 changes: 0 additions & 10 deletions lib/filelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions lib/form/filemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>';
Expand Down

0 comments on commit 1230b9c

Please sign in to comment.