3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Moodle file tree viewer based on YUI2 Treeview
23 * @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require('../config.php');
29 $contextid = optional_param('contextid', SYSCONTEXTID
, PARAM_INT
);
30 $filepath = optional_param('filepath', '', PARAM_PATH
);
31 $filename = optional_param('filename', '', PARAM_FILE
);
32 // hard-coded to course legacy area
33 $component = 'course';
37 $PAGE->set_url('/files/index.php', array('contextid'=>$contextid, 'filepath'=>$filepath, 'filename'=>$filename));
39 if ($filepath === '') {
43 if ($filename === '') {
47 list($context, $course, $cm) = get_context_info_array($contextid);
48 $PAGE->set_context($context);
50 require_login($course, false, $cm);
51 require_capability('moodle/course:managefiles', $context);
53 $browser = get_file_browser();
55 $file_info = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
57 $strfiles = get_string("files");
58 if ($node = $PAGE->settingsnav
->find('coursefiles', navigation_node
::TYPE_SETTING
)) {
61 $PAGE->navbar
->add($strfiles);
64 $PAGE->set_title("$course->shortname: $strfiles");
65 $PAGE->set_heading($course->fullname
);
66 $PAGE->set_pagelayout('course');
68 $output = $PAGE->get_renderer('core', 'files');
70 echo $output->header();
71 echo $output->box_start();
75 $options['context'] = $context;
76 //$options['visible_areas'] = array('backup'=>array('section', 'course'), 'course'=>array('legacy'), 'user'=>array('backup'));
77 echo $output->files_tree_viewer($file_info, $options);
79 echo $output->notification(get_string('nofilesavailable', 'repository'));
82 echo $output->box_end();
83 echo $output->footer();