Browse files

MDL-34338: renderer for mod_folder should not use file_info

  • Loading branch information...
1 parent 71e12dc commit f4671476ff0fcc6202d867caa051e56215014424 @marinaglancy marinaglancy committed Sep 4, 2012
Showing with 11 additions and 9 deletions.
  1. +11 −9 mod/folder/renderer.php
View
20 mod/folder/renderer.php
@@ -60,24 +60,26 @@ protected function htmllize_tree($tree, $dir) {
$result = '<ul>';
foreach ($dir['subdirs'] as $subdir) {
$image = $this->output->pix_icon(file_folder_icon(24), $subdir['dirname'], 'moodle');
- $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', s($subdir['dirname']), array('class' => 'fp-filename'));
+ $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')).
+ html_writer::tag('span', s($subdir['dirname']), array('class' => 'fp-filename'));
$filename = html_writer::tag('div', $filename, array('class' => 'fp-filename-icon'));
$result .= html_writer::tag('li', $filename. $this->htmllize_tree($tree, $subdir));
}
foreach ($dir['files'] as $file) {
- $fileinfo = $browser->get_file_info($tree->context, $file->get_component(),
- $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());
- $url = $fileinfo->get_url(true);
$filename = $file->get_filename();
- if ($imageinfo = $fileinfo->get_imageinfo()) {
- $fileurl = new moodle_url($fileinfo->get_url());
- $image = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $fileinfo->get_timemodified()));
+ $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(),
+ $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $filename, false);
+ if (file_extension_in_typegroup($filename, 'web_image')) {
+ $image = $url->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified()));
$image = html_writer::empty_tag('img', array('src' => $image));
} else {
$image = $this->output->pix_icon(file_file_icon($file, 24), $filename, 'moodle');
}
- $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', $filename, array('class' => 'fp-filename'));
- $filename = html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'fp-filename-icon'));
+ $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')).
+ html_writer::tag('span', $filename, array('class' => 'fp-filename'));
+ $filename = html_writer::tag('span',
+ html_writer::link($url->out(false, array('forcedownload' => 1)), $filename),
+ array('class' => 'fp-filename-icon'));
$result .= html_writer::tag('li', $filename);
}
$result .= '</ul>';

0 comments on commit f467147

Please sign in to comment.