Automatically generated installer lang files
[moodle.git] / files / index.php
CommitLineData
be19e367 1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
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.
9//
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.
14//
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/>.
17
18/**
fb2fb46e 19 * Moodle file tree viewer based on YUI2 Treeview
be19e367 20 *
64f93798 21 * @package core
be19e367 22 * @subpackage file
fb2fb46e 23 * @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
be19e367 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26
27require('../config.php');
be19e367 28
be19e367 29$contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT);
be19e367 30$filepath = optional_param('filepath', '', PARAM_PATH);
31$filename = optional_param('filename', '', PARAM_FILE);
e921afa8
DC
32// hard-coded to course legacy area
33$component = 'course';
34$filearea = 'legacy';
35$itemid = 0;
be19e367 36
e921afa8 37$PAGE->set_url('/files/index.php', array('contextid'=>$contextid, 'filepath'=>$filepath, 'filename'=>$filename));
f9903ed0 38
be19e367 39if ($filepath === '') {
40 $filepath = null;
41}
fdfc6269 42
be19e367 43if ($filename === '') {
44 $filename = null;
45}
f9903ed0 46
64f93798 47list($context, $course, $cm) = get_context_info_array($contextid);
93ad2d4d 48$PAGE->set_context($context);
64f93798
PS
49
50require_login($course, false, $cm);
51require_capability('moodle/course:managefiles', $context);
52
be19e367 53$browser = get_file_browser();
1a11dfd1 54
64f93798 55$file_info = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
1a11dfd1 56
fb2fb46e 57$strfiles = get_string("files");
0e79a0d5
SH
58if ($node = $PAGE->settingsnav->find('coursefiles', navigation_node::TYPE_SETTING)) {
59 $node->make_active();
60} else {
61 $PAGE->navbar->add($strfiles);
62}
64f93798 63
e921afa8
DC
64$PAGE->set_title("$course->shortname: $strfiles");
65$PAGE->set_heading($course->fullname);
66$PAGE->set_pagelayout('course');
f9903ed0 67
64f93798
PS
68$output = $PAGE->get_renderer('core', 'files');
69
70echo $output->header();
71echo $output->box_start();
72
73if ($file_info) {
74 $options = array();
e921afa8 75 $options['context'] = $context;
64f93798
PS
76 //$options['visible_areas'] = array('backup'=>array('section', 'course'), 'course'=>array('legacy'), 'user'=>array('backup'));
77 echo $output->files_tree_viewer($file_info, $options);
78} else {
affb8fd6 79 echo $output->notification(get_string('nofilesavailable', 'repository'));
64f93798
PS
80}
81
82echo $output->box_end();
64f93798 83echo $output->footer();