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