# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/files/index.php
--- moodle/files/index.php Base (1.157)
+++ moodle/files/index.php Locally Modified (Based On 1.157)
@@ -27,14 +27,15 @@
 require('../config.php');
 require_once($CFG->libdir.'/filelib.php');
 require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->dirroot.'/files/lib.php');
 
 $courseid   = optional_param('id', 0, PARAM_INT);
 
 $contextid  = optional_param('contextid', SYSCONTEXTID, PARAM_INT);
-$filearea   = optional_param('filearea', '', PARAM_ALPHAEXT);
+$filearea   = optional_param('filearea', null, PARAM_ALPHAEXT);
 $itemid     = optional_param('itemid', -1, PARAM_INT);
-$filepath   = optional_param('filepath', '', PARAM_PATH);
-$filename   = optional_param('filename', '', PARAM_FILE);
+$filepath   = optional_param('filepath', null, PARAM_PATH);
+$filename   = optional_param('filename', null, PARAM_FILE);
 
 $newdirname = optional_param('newdirname', '', PARAM_FILE);
 $delete     = optional_param('delete', 0, PARAM_BOOL);
@@ -52,26 +53,24 @@
 if ($context->contextlevel == CONTEXT_MODULE) {
     $cm = get_coursemodule_from_id(null, $context->instanceid, 0, false, MUST_EXIST);
     $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
+    $heading = $cm->name;
 } else if ($context->contextlevel == CONTEXT_COURSE) {
     $course = $DB->get_record('course', array('id'=>$context->instanceid), '*', MUST_EXIST);
+    $heading = $course->fullname;
 }
 
+$PAGE->set_pagelayout('admin');
 require_login($course, false, $cm);
 require_capability('moodle/course:managefiles', $context);
 
-if ($filearea === '') {
-    $filearea = null;
+if ($course == null && $cm == null) {
+    $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
 }
 
 if ($itemid < 0) {
     $itemid = null;
 }
-
-if ($filepath === '') {
-    $filepath = null;
-}
-
-if ($filename === '') {
+if (empty($filename) || $filename=='.') {
     $filename = null;
 }
 
@@ -80,9 +79,10 @@
 $browser = get_file_browser();
 
 $file_info = $browser->get_file_info($context, $filearea, $itemid, $filepath, $filename);
+if ($file_info) {
 
 /// process actions
-if ($file_info and $file_info->is_directory() and $file_info->is_writable() and $newdirname !== '' and data_submitted() and confirm_sesskey()) {
+    if ($file_info->is_directory() and $file_info->is_writable() and $newdirname !== '' and data_submitted() and confirm_sesskey()) {
     if ($newdir_info = $file_info->create_directory($newdirname, $USER->id)) {
         $params = $newdir_info->get_params();
         redirect(new moodle_url('index.php', $params));
@@ -91,7 +91,7 @@
     }
 }
 
-if ($file_info and $file_info->is_directory() and $file_info->is_writable() and isset($_FILES['newfile']) and data_submitted() and confirm_sesskey()) {
+    if ($file_info->is_directory() and $file_info->is_writable() and isset($_FILES['newfile']) and data_submitted() and confirm_sesskey()) {
     $file = $_FILES['newfile'];
     $newfilename = clean_param($file['name'], PARAM_FILE);
     if (is_uploaded_file($_FILES['newfile']['tmp_name'])) {
@@ -99,7 +99,6 @@
             if ($newfile = $file_info->create_file_from_pathname($newfilename, $_FILES['newfile']['tmp_name'], $USER->id)) {
                 $params = $file_info->get_params();
                 redirect(new moodle_url('index.php', $params));
-
             } else {
                 $error = "Could not create upload file"; // TODO: localise
             }
@@ -109,7 +108,7 @@
     }
 }
 
-if ($file_info and $delete) {
+    if ($delete) {
     if (!data_submitted() or !confirm_sesskey()) {
         $params = $file_info->get_params();
         $params = array_merge($params, array('delete'=>1));
@@ -136,206 +135,35 @@
         redirect(new moodle_url('index.php', $params));
     }
 }
-
-
-/// print dir listing
-html_header($context, $file_info);
-
-if ($error !== '') {
-    echo $OUTPUT->notification($error);
+    $PAGE->set_url(new moodle_url('/files/index.php', $file_info->get_params()));
+} else {
+    $PAGE->set_url(new moodle_url('/files/index.php', array('contextid'=>$contextid, 'filearea'=>$filearea, 'itemid'=>$itemid)));
 }
 
-displaydir($file_info);
+$PAGE->set_title("$SITE->shortname: ".get_string("files"));
+$PAGE->set_heading($heading);
 
-if ($file_info and $file_info->is_directory() and $file_info->is_writable()) {
-    echo '<br />';
-
-    echo '<form action="index.php" method="post"><div>';
-    echo '<input type="hidden" name="contextid" value="'.$contextid.'" />';
-    echo '<input type="hidden" name="filearea" value="'.$filearea.'" />';
-    echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
-    echo '<input type="hidden" name="filepath" value="'.s($filepath).'" />';
-    echo '<input type="hidden" name="filename" value="'.s($filename).'" />';
-    echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
-    echo '<input type="text" name="newdirname" value="" />';
-    echo '<input type="submit" value="'.get_string('makeafolder').'" />';
-    echo '</div></form>';
-
-    echo '<br />';
-
-    echo '<form enctype="multipart/form-data" method="post" action="index.php"><div>';
-    echo '<input type="hidden" name="contextid" value="'.$contextid.'" />';
-    echo '<input type="hidden" name="filearea" value="'.$filearea.'" />';
-    echo '<input type="hidden" name="itemid" value="'.$itemid.'" />';
-    echo '<input type="hidden" name="filepath" value="'.s($filepath).'" />';
-    echo '<input type="hidden" name="filename" value="'.s($filename).'" />';
-    echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
-    echo '<input name="newfile" type="file" />';
-    echo '<input type="submit" value="'.get_string('uploadafile').'" />';
-    echo '</div></form>';
+if ($context->contextlevel == CONTEXT_COURSE) {
+    files_fix_active_course_navigation();
 }
+$renderer = $PAGE->get_renderer('core_files');
 
-html_footer();
-
-/// UI functions /////////////////////////
-
-function html_footer() {
-    global $OUTPUT;
-    echo '</td></tr></table>';
-    echo $OUTPUT->footer();
-}
-
-function html_header($context, $file_info){
-    global $CFG, $SITE, $PAGE, $OUTPUT;
-
-    $strfiles = get_string("files");
-    if ($context->contextlevel == CONTEXT_MODULE) {
-        $PAGE->set_pagelayout('incourse');
-    } else if ($context->contextlevel == CONTEXT_COURSE) {
-        $PAGE->set_pagelayout('course');
-    } else {
-        $PAGE->set_pagelayout('admin');
-    }
-    $PAGE->navbar->add($strfiles);
-    $PAGE->set_url("/files/index.php", $file_info->get_params());
-    $PAGE->set_title("$SITE->shortname: $strfiles");
     echo $OUTPUT->header();
-
-    echo "<table border=\"0\" style=\"margin-left:auto;margin-right:auto\" cellspacing=\"3\" cellpadding=\"3\" width=\"740\">";
-    echo "<tr>";
-    echo "<td colspan=\"2\">";
+echo $OUTPUT->box_start('', 'filebrowser');
+if ($error !== '') {
+    echo $OUTPUT->notification($error);
 }
-
-/// FILE FUNCTIONS ///////////////////////////////////////////////////////////
-
-function print_cell($alignment='center', $text='&nbsp;', $class='') {
-    if ($class) {
-        $class = ' class="'.$class.'"';
+if ($file_info) {
+    echo $renderer->file_path(file_get_browseable_path($file_info, $context->contextlevel));
+    echo $renderer->file_browser($file_info);
+    if ($file_info && $file_info->is_directory() && $file_info->is_writable()) {
+        echo $OUTPUT->box_start('generalbox filemanagement');
+        echo $renderer->upload_file_form($contextid, $filearea, $itemid, $filepath, $filename);
+        echo $renderer->create_folder_form($contextid, $filearea, $itemid, $filepath, $filename);
+        echo $OUTPUT->box_end();
     }
-    echo '<td align="'.$alignment.'" style="white-space:nowrap "'.$class.'>'.$text.'</td>';
-}
-
-function displaydir($file_info) {
-    global $CFG, $OUTPUT;
-
-    $children = $file_info->get_children();
-    $parent_info = $file_info->get_parent();
-
-    $strname     = get_string('name');
-    $strsize     = get_string('size');
-    $strmodified = get_string('modified');
-    $strfolder   = get_string('folder');
-    $strfile     = get_string('file');
-    $strdownload = get_string('download');
-    $strdelete   = get_string('delete');
-    $straction   = get_string('action');
-
-    $path = array();
-    $params = $file_info->get_params_rawencoded();
-    $params = implode('&amp;', $params);
-    $path[] = $file_info->get_visible_name();
-
-    $level = $parent_info;
-    while ($level) {
-        $params = $level->get_params_rawencoded();
-        $params = implode('&amp;', $params);
-        $path[] = '<a href="index.php?'.$params.'">'.$level->get_visible_name().'</a>';
-        $level = $level->get_parent();
-    }
-
-    $path = array_reverse($path);
-
-    $path = implode (' / ', $path);
-    echo $path. ' /';
-
-    echo "<div>";
-    echo "<hr/>";
-    echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"740\" class=\"files\">";
-    echo "<tr>";
-    echo "<th class=\"header\" scope=\"col\"></th>";
-    echo "<th class=\"header name\" scope=\"col\">$strname</th>";
-    echo "<th class=\"header size\" scope=\"col\">$strsize</th>";
-    echo "<th class=\"header date\" scope=\"col\">$strmodified</th>";
-    echo "<th class=\"header commands\" scope=\"col\">$straction</th>";
-    echo "</tr>\n";
-
-    $parentwritable = $file_info->is_writable();
-
-    if ($parent_info) {
-        $params = $parent_info->get_params_rawencoded();
-        $params = implode('&amp;', $params);
-
-        echo "<tr class=\"folder\">";
-        print_cell();
-        print_cell('left', '<a href="index.php?'.$params.'"><img src="'.$OUTPUT->pix_url('f/parent') . '" class="icon" alt="" />&nbsp;'.get_string('parentfolder').'</a>', 'name');
-        print_cell();
-        print_cell();
-        print_cell();
-
-        echo "</tr>";
-    }
-
-    if ($children) {
-        foreach ($children as $child_info) {
-            $filename = $child_info->get_visible_name();
-            $filesize = $child_info->get_filesize();
-            $filesize = $filesize ? display_size($filesize) : '';
-            $filedate = $child_info->get_timemodified();
-            $filedate = $filedate ? userdate($filedate) : '';
-
-            $mimetype = $child_info->get_mimetype();
-
-            $params = $child_info->get_params_rawencoded();
-            $params = implode('&amp;', $params);
-
-            if ($child_info->is_directory()) {
-
-                echo "<tr class=\"folder\">";
-                print_cell();
-                print_cell("left", "<a href=\"index.php?$params\"><img src=\"" . $OUTPUT->pix_url('f/folder') . "\" class=\"icon\" alt=\"$strfolder\" />&nbsp;".s($filename)."</a>", 'name');
-                print_cell("right", $filesize, 'size');
-                print_cell("right", $filedate, 'date');
-                if ($parentwritable) {
-                    print_cell("right", "<a href=\"index.php?$params&amp;sesskey=".sesskey()."&amp;delete=1\"><img src=\"" . $OUTPUT->pix_url('t/delete') . "\" class=\"iconsmall\" alt=\"$strdelete\" /></a>", 'command');
                 } else {
-                    print_cell();
+    echo $OUTPUT->notification(get_string('filenotfound', 'error'));
                 }
-                echo "</tr>";
-
-            } else {
-
-                if ($downloadurl = $child_info->get_url(true)) {
-                    $downloadurl = "&nbsp;<a href=\"$downloadurl\" title=\"" . get_string('downloadfile') . "\"><img src=\"" . $OUTPUT->pix_url('t/down') . "\" class=\"iconsmall\" alt=\"$strdownload\" /></a>";
-                } else {
-                    $downloadurl = '';
-                }
-
-                if ($viewurl = $child_info->get_url()) {
-                    $viewurl = "&nbsp;".$OUTPUT->action_link($viewurl, "<img src=\"" . $OUTPUT->pix_url('t/preview') . "\" class=\"iconsmall\" alt=\"$strfile\" />&nbsp;",
-                        new popup_action('click', $viewurl, 'display', array('height' => 480, 'width' => 640)));
-                } else {
-                    $viewurl = '';
-                }
-
-
-
-                echo "<tr class=\"file\">";
-                print_cell();
-                print_cell("left", "<img src=\"" . $OUTPUT->pix_url(file_mimetype_icon($mimetype)) . "\" class=\"icon\" alt=\"$strfile\" />&nbsp;".s($filename).$downloadurl.$viewurl, 'name');
-                print_cell("right", $filesize, 'size');
-                print_cell("right", $filedate, 'date');
-                if ($parentwritable) {
-                    print_cell("right", "<a href=\"index.php?$params&amp;sesskey=".sesskey()."&amp;delete=1\"><img src=\"" . $OUTPUT->pix_url('t/delete') . "\" class=\"iconsmall\" alt=\"$strdelete\" /></a>", 'command');
-                } else {
-                    print_cell();
-                }
-                echo "</tr>";
-            }
-        }
-    }
-
-    echo "</table>";
-    echo "</div>";
-    echo "<hr/>";
-
-}
+echo $OUTPUT->box_end('div');
+echo $OUTPUT->footer();
\ No newline at end of file
Index: moodle/files/lib.php
--- moodle/files/lib.php No Base Revision
+++ moodle/files/lib.php Locally New
@@ -0,0 +1,63 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Temporary file manager lib file
+ *
+ * @package    moodlecore
+ * @subpackage file
+ * @copyright  2010 Sam Hemelryk
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * Gets the browseable path to the given file.
+ *
+ * Optionally a context level can also be supplied to limit what is shown to just those
+ * files that are within the specified context.
+ *
+ * @param file_info $file
+ * @param int $contextlimit
+ * @return array
+ */
+function file_get_browseable_path(file_info $file, $contextlimit = null) {
+    $path = array(array('name'=>$file->get_visible_name()));
+    $level = $file->get_parent();
+    while ($level && ($contextlimit == null || $level->get_context()->contextlevel >= $contextlimit)) {
+        $path[] = array('link'=>new moodle_url('/files/index.php', $level->get_params()), 'name'=>$level->get_visible_name());
+        $level = $level->get_parent();
+    }
+    $path = array_reverse($path);
+    return $path;
+}
+
+/**
+ * Fixes the navigation for the course by finding the files link in the course settings
+ * and making it active.
+ * 
+ * @global moodle_page $PAGE
+ */
+function files_fix_active_course_navigation() {
+    global $PAGE;
+    $course = $PAGE->settingsnav->get('courseadmin', navigation_node::TYPE_COURSE);
+    if ($course) {
+        $files = $course->get('coursefiles', navigation_node::TYPE_SETTING);
+        if ($files) {
+            $files->make_active();
+        }
+    }
+}
\ No newline at end of file
Index: moodle/files/renderer.php
--- moodle/files/renderer.php No Base Revision
+++ moodle/files/renderer.php Locally New
@@ -0,0 +1,177 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Temporary file manager renderer
+ *
+ * @package    moodlecore
+ * @subpackage file
+ * @copyright  2010 Sam Hemelryk
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * The renderer for the file manager
+ */
+class core_files_renderer extends plugin_renderer_base {
+
+    /**
+     * Given an array of path bits this function produces formatted html
+     *
+     * @param array $bits
+     * @return string
+     */
+    public function file_path(array $bits) {
+        foreach ($bits as &$bit) {
+            if (!empty($bit['link'])) {
+                $bit = html_writer::link($bit['link'], $bit['name']);
+            } else {
+                $bit = html_writer::tag('span', $bit['name']);
+            }
+        }
+        return html_writer::tag('div', implode('/', $bits).'/', array('class'=>'file_path_navigation'));
+    }
+
+    /**
+     * Produces a form to create a new folder with the given args
+     *
+     * @param int $contextid
+     * @param string $filearea
+     * @param int $itemid
+     * @param string $filepath
+     * @param string $filename
+     * @return string
+     */
+    public function create_folder_form($contextid, $filearea, $itemid=null, $filepath=null, $filename=null) {
+        $content = html_writer::start_tag('div', array('id'=>'createfolder'));
+        $content .= html_writer::start_tag('form', array('action'=>new moodle_url('/files/index.php'), 'method'=>'post'));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'contextid', 'value'=>$contextid));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'filearea', 'value'=>$filearea));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'itemid', 'value'=>$itemid));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'filepath', 'value'=>s($filepath)));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'filename', 'value'=>s($filename)));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
+        $content .= html_writer::empty_tag('input', array('type'=>'text', 'name'=>'newdirname', 'value'=>''));
+        $content .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('makeafolder')));
+        $content .= html_writer::end_tag('form');
+        $content .= html_writer::end_tag('div');
+        return $content;
+    }
+
+    /**
+     * Produces a form to upload a file within the given directory
+     *
+     * @param int $contextid
+     * @param string $filearea
+     * @param int $itemid
+     * @param string $filepath
+     * @param string $filename
+     * @return string
+     */
+    public function upload_file_form($contextid, $filearea, $itemid, $filepath, $filename) {
+        $content = html_writer::start_tag('div', array('id'=>'uploadfile'));
+        $content .= html_writer::start_tag('form', array('action'=>new moodle_url('/files/index.php'), 'method'=>'post', 'enctype'=>'multipart/form-data'));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'contextid', 'value'=>$contextid));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'filearea', 'value'=>$filearea));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'itemid', 'value'=>$itemid));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'filepath', 'value'=>s($filepath)));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'filename', 'value'=>s($filename)));
+        $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
+        $content .= html_writer::empty_tag('input', array('type'=>'file', 'size'=>'50', 'name'=>'newfile'));
+        $content .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('uploadafile')));
+        $content .= html_writer::end_tag('form');
+        $content .= html_writer::end_tag('div');
+        return $content;
+    }
+
+    /**
+     * Produces a view of the given file or directory.
+     *
+     * @param file_info $file
+     * @return string
+     */
+    public function file_browser(file_info $file) {
+        $table = new html_table();
+        $table->id = 'filebrowsertable';
+        $table->attributes['class'] = 'generaltable files';
+        $table->colclasses = array('', 'name', 'size', 'date', 'commands');
+        $table->head = array(
+            '',
+            new html_table_cell(get_string('name')),
+            new html_table_cell(get_string('size')),
+            new html_table_cell(get_string('modified')),
+            new html_table_cell(get_string('action'))
+        );
+        $table->data = array();
+
+        $parent = $file->get_parent();
+        if ($parent) {
+            $parentlink = html_writer::link(new moodle_url('/files/index.php', $parent->get_params()), $this->output->pix_icon('f/parent', '').get_string('parentfolder'));
+            $row = new html_table_row(array('', $parentlink, '','',''));
+            $row->attributes['class'] = 'row folder parentfolder';
+            $table->data[] = $row;
+        }
+
+        $children = $file->get_children();
+        if ($children) {
+            $parentwritable = $file->is_writable();
+            $strfolder   = get_string('folder');
+            $strfile     = get_string('file');
+            $strdownload = get_string('download');
+            $strdelete   = get_string('delete');
+            $strdownloadfile = get_string('downloadfile');
+
+            foreach ($children as $child) {
+                $filename = $child->get_visible_name();
+                $filesize = $child->get_filesize();
+                $filesize = $filesize ? display_size($filesize) : '';
+                $filedate = $child->get_timemodified();
+                $filedate = $filedate ? userdate($filedate) : '';
+
+                if ($parentwritable) {
+                    $deleteurl = new moodle_url('/files/index.php', array_merge($child->get_params(), array('sesskey'=>sesskey(), 'delete'=>'1')));
+                    $deletelink = $this->output->action_icon($deleteurl, new pix_icon('t/delete', $strdelete), null, array('class'=>'command'), true);
+                } else {
+                    $deletelink = '';
+                }
+
+                if ($child->is_directory()) {
+                    $link = html_writer::link(new moodle_url('/files/index.php', $child->get_params()), $this->output->pix_icon('f/folder', '').s($filename));
+                    $row = new html_table_row(array('', $link, $filesize, $filedate, $deletelink));
+                    $row->attributes['class'] = 'row folder';
+                    $table->data[] = $row;
+
+                } else {
+
+                    $filename = $this->output->pix_icon(file_mimetype_icon($child->get_mimetype()), '').s($filename);
+                    if ($downloadurl = $child->get_url(true)) {
+                        $filename .= html_writer::link($downloadurl, $this->output->pix_icon('t/down', $strdownload), array('class'=>'downloadfile', 'title'=>$strdownloadfile));
+                    }
+                    if ($viewurl = $child->get_url()) {
+                        $filename .= $this->output->action_link($viewurl, $this->output->pix_icon('t/preview', $strfile), new popup_action('click', $viewurl, 'display', array('height' => 480, 'width' => 640)));
+                    }
+                    $row = new html_table_row(array('', $filename, $filesize, $filedate, $deletelink));
+                    $row->attributes['class'] = 'row file';
+                    $table->data[] = $row;
+                }
+            }
+        }
+
+        return html_writer::table($table);
+    }
+
+}
\ No newline at end of file
Index: moodle/lib/file/file_info.php
--- moodle/lib/file/file_info.php Base (1.8)
+++ moodle/lib/file/file_info.php Locally Modified (Based On 1.8)
@@ -88,6 +88,14 @@
     }
 
     /**
+     * Returns the context associated with this file
+     * @return stdClass Context
+     */
+    public function get_context() {
+        return $this->context;
+    }
+
+    /**
      * Returns file download url
      * @param bool $forcedownload
      * @param bool $htts force https
Index: moodle/lib/moodlelib.php
--- moodle/lib/moodlelib.php Base (1.1366)
+++ moodle/lib/moodlelib.php Locally Modified (Based On 1.1366)
@@ -6929,6 +6929,7 @@
             'editor'      => 'lib/editor',
             'edufields'   => NULL,
             'error'       => NULL,
+            'files'       => 'files',
             'filepicker'  => NULL,
             'filters'     => NULL,
             'flashdetect' => NULL,
Index: moodle/theme/standard/style/core.css
--- moodle/theme/standard/style/core.css Base (1.6)
+++ moodle/theme/standard/style/core.css Locally Modified (Based On 1.6)
@@ -62,10 +62,6 @@
 #page-site-index .subscribelink,
 .path-course-view .subscribelink {font-size: 0.8em;}
 
-.files .file,
-.files .folder {font-size: 0.9em;}
-.files .folder .size {font-weight: bold;}
-
 a.useredit,
 a:hover.useredit,
 .blink {color: black;cursor: help;}
@@ -410,3 +406,19 @@
 #custommenu .yui3-menu .yui3-menuitem-active {background-color:#e1e1df;}
 #custommenu .yui3-menu-horizontal.javascript-disabled a {color:inherit;}
 #custommenu .yui3-menu-horizontal.javascript-disabled a:hover {color:blue;text-decoration:none;}
+
+/**
+ * Files
+ */
+#filebrowser {margin:1em auto;width:740px;}
+#filebrowser .filemanagement div  {margin:1em;}
+#filebrowser .file_path_navigation  {margin:1em 0;}
+#filebrowser .file_path_navigation span  {margin:0 3px;font-weight:bold;}
+#filebrowser .file_path_navigation a  {margin:0 3px;}
+#filebrowsertable {width:100%;border-spacing: 2px;padding: 2px;}
+#filebrowsertable .file,
+#filebrowsertable .folder {font-size: 0.9em;}
+#filebrowsertable .folder .size {font-weight: bold;}
+#filebrowsertable .row .name .smallicon  {margin-right:5px;}
+#filebrowsertable .row td  {border-width:0;}
+#filebrowsertable .row .size  {text-align:right;}
