mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-24295, Course files display should show more information, like Moodle 1.x
This commit is contained in:
parent
ce5dc36e38
commit
0b259d91a9
@ -45,43 +45,41 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
public function render_files_tree_viewer(files_tree_viewer $tree) {
|
||||
|
||||
$html = $this->output->heading_with_help(get_string('coursefiles'), 'courselegacyfiles', 'moodle');
|
||||
$html .= '<div class="file-tree-breadcrumb">';
|
||||
|
||||
$html .= $this->output->container_start('coursefilesbreadcrumb');
|
||||
foreach($tree->path as $path) {
|
||||
$html .= $path;
|
||||
$html .= ' / ';
|
||||
}
|
||||
$html .= '</div>';
|
||||
$html .= $this->output->container_end();
|
||||
|
||||
$html .= '<div id="course-file-tree-view" class="filemanager-container">';
|
||||
if (empty($tree->tree)) {
|
||||
$html .= get_string('nofilesavailable', 'repository');
|
||||
} else {
|
||||
$this->page->requires->js_init_call('M.core_filetree.init');
|
||||
$html .= '<ul>';
|
||||
foreach($tree->tree as $node) {
|
||||
$link_attributes = array();
|
||||
if (!empty($node['isdir'])) {
|
||||
$class = ' class="file-tree-folder"';
|
||||
$icon = $this->output->pix_icon('f/folder', 'icon');
|
||||
} else {
|
||||
$class = ' class="file-tree-file"';
|
||||
$icon = $this->output->pix_icon('f/'.mimeinfo('icon', $node['filename']), get_string('icon'));
|
||||
$link_attributes['target'] = '_blank';
|
||||
}
|
||||
$html .= '<li '.$class.' yuiConfig="{\'type\':\'HTMLNode\'}">';
|
||||
$html .= '<div>';
|
||||
$html .= $icon;
|
||||
$html .= ' ';
|
||||
$html .= html_writer::link($node['url'], $node['filename'], $link_attributes);
|
||||
$html .= '</div>';
|
||||
$html .= '</li>';
|
||||
$html .= $this->output->box_start();
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('filename', 'backup'), get_string('time'), get_string('size'));
|
||||
$table->align = array('left', 'left', 'left');
|
||||
$table->width = '100%';
|
||||
$table->data = array();
|
||||
|
||||
foreach ($tree->tree as $file) {
|
||||
if (!empty($file['isdir'])) {
|
||||
$table->data[] = array(
|
||||
html_writer::link($file['url'], $this->output->pix_icon('f/folder', 'icon') . ' ' . $file['filename']),
|
||||
$file['filedate'],
|
||||
'',
|
||||
);
|
||||
} else {
|
||||
$table->data[] = array(
|
||||
html_writer::link($file['url'], $this->output->pix_icon('f/'.mimeinfo('icon', $file['filename']), get_string('icon')) . ' ' . $file['filename']),
|
||||
$file['filedate'],
|
||||
display_size($file['filesize']),
|
||||
);
|
||||
}
|
||||
$html .= '</ul>';
|
||||
}
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= html_writer::table($table);
|
||||
$html .= $this->output->single_button(new moodle_url('/files/coursefilesedit.php', array('contextid'=>$tree->context->id)), get_string('coursefilesedit'), 'get');
|
||||
$html .= $this->output->box_end();
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@ -111,39 +109,42 @@ class files_tree_viewer implements renderable {
|
||||
$this->options = (array)$options;
|
||||
$this->context = $options['context'];
|
||||
|
||||
if (isset($this->options['visible_areas'])) {
|
||||
$visible_areas = (array)$this->options['visible_areas'];
|
||||
} else {
|
||||
$visible_areas = false;
|
||||
}
|
||||
|
||||
$this->tree = array();
|
||||
$children = $file_info->get_children();
|
||||
$current_file_params = $file_info->get_params();
|
||||
$parent_info = $file_info->get_parent();
|
||||
$level = $parent_info;
|
||||
$this->path = array();
|
||||
while ($level) {
|
||||
$params = $level->get_params();
|
||||
$context = get_context_instance_by_id($params['contextid']);
|
||||
if ($context->id != $this->context->id) {
|
||||
// $this->context is current context
|
||||
if ($context->id != $this->context->id or empty($params['filearea'])) {
|
||||
break;
|
||||
}
|
||||
// unset unused parameters
|
||||
unset($params['component']);
|
||||
unset($params['filearea']);
|
||||
unset($params['filename']);
|
||||
unset($params['itemid']);
|
||||
$url = new moodle_url('/files/index.php', $params);
|
||||
$this->path[] = html_writer::link($url, $level->get_visible_name());
|
||||
$level = $level->get_parent();
|
||||
}
|
||||
$this->path = array_reverse($this->path);
|
||||
$this->path[] = $file_info->get_visible_name();
|
||||
if ($current_file_params['filepath'] != '/') {
|
||||
$this->path[] = $file_info->get_visible_name();
|
||||
}
|
||||
|
||||
foreach ($children as $child) {
|
||||
$filedate = $child->get_timemodified();
|
||||
$filesize = $child->get_filesize();
|
||||
$mimetype = $child->get_mimetype();
|
||||
$params = $child->get_params();
|
||||
unset($params['component']);
|
||||
unset($params['filearea']);
|
||||
unset($params['filename']);
|
||||
unset($params['itemid']);
|
||||
$fileitem = array(
|
||||
'params' => $params,
|
||||
'filename' => $child->get_visible_name(),
|
||||
@ -154,11 +155,6 @@ class files_tree_viewer implements renderable {
|
||||
if ($child->is_directory()) {
|
||||
$fileitem['isdir'] = true;
|
||||
$fileitem['url'] = $url->out(false);
|
||||
if ($visible_areas !== false) {
|
||||
if (!isset($visible_areas[$params['component']][$params['filearea']])) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$fileitem['url'] = $child->get_url();
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ h2.headingblock {font-size:1.1em;}
|
||||
.files .file,
|
||||
.files .folder {font-size: 0.9em;}
|
||||
.files .folder .size {font-weight: bold;}
|
||||
.coursefilesbreadcrumb {margin: .5em 0; padding: .5em 0;}
|
||||
|
||||
a.useredit,
|
||||
a:hover.useredit,
|
||||
|
Loading…
x
Reference in New Issue
Block a user