Skip to content

Commit

Permalink
MDL-24295, Course files display should show more information, like Mo…
Browse files Browse the repository at this point in the history
…odle 1.x
  • Loading branch information
Dongsheng Cai committed Sep 20, 2010
1 parent ce5dc36 commit 0b259d9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 41 deletions.
78 changes: 37 additions & 41 deletions files/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,43 +45,41 @@ public function files_tree_viewer(file_info $file_info, array $options = null) {
}

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 .= '&nbsp;';
$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;
}
}
Expand Down Expand Up @@ -111,39 +109,42 @@ public function __construct(file_info $file_info, array $options = null) {
$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(),
Expand All @@ -154,11 +155,6 @@ public function __construct(file_info $file_info, array $options = null) {
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();
}
Expand Down
1 change: 1 addition & 0 deletions theme/standard/style/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0b259d9

Please sign in to comment.