hub MDL-23769 fill empty education level and audience help strings
[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);
64f93798 30$component = optional_param('component', '', PARAM_ALPHAEXT);
be19e367 31$filearea = optional_param('filearea', '', PARAM_ALPHAEXT);
32$itemid = optional_param('itemid', -1, PARAM_INT);
33$filepath = optional_param('filepath', '', PARAM_PATH);
34$filename = optional_param('filename', '', PARAM_FILE);
35
64f93798 36$PAGE->set_url('/files/index.php', array('contextid'=>$contextid, 'component'=>$component, 'filearea'=>$filearea, 'itemid'=>$itemid, 'filepath'=>$filepath, 'filename'=>$filename));
1904e9b3 37
64f93798
PS
38if ($component === '') {
39 $component = null;
be19e367 40}
f9903ed0 41
be19e367 42if ($filearea === '') {
43 $filearea = null;
44}
ad4e0fcc 45
be19e367 46if ($itemid < 0) {
47 $itemid = null;
48}
f9903ed0 49
be19e367 50if ($filepath === '') {
51 $filepath = null;
52}
fdfc6269 53
be19e367 54if ($filename === '') {
55 $filename = null;
56}
f9903ed0 57
64f93798 58list($context, $course, $cm) = get_context_info_array($contextid);
93ad2d4d 59$PAGE->set_context($context);
64f93798
PS
60
61require_login($course, false, $cm);
62require_capability('moodle/course:managefiles', $context);
63
be19e367 64$browser = get_file_browser();
1a11dfd1 65
64f93798 66$file_info = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
1a11dfd1 67
fb2fb46e 68$strfiles = get_string("files");
0e79a0d5
SH
69if ($node = $PAGE->settingsnav->find('coursefiles', navigation_node::TYPE_SETTING)) {
70 $node->make_active();
71} else {
72 $PAGE->navbar->add($strfiles);
73}
64f93798 74
64f93798
PS
75$PAGE->set_title("$SITE->shortname: $strfiles");
76$PAGE->set_heading($SITE->fullname);
77
fb2fb46e
DC
78if ($context->contextlevel == CONTEXT_MODULE) {
79 $PAGE->set_pagelayout('incourse');
80} else if ($context->contextlevel == CONTEXT_COURSE) {
81 $PAGE->set_pagelayout('course');
82} else {
83 $PAGE->set_pagelayout('admin');
f9903ed0 84}
85
64f93798
PS
86$output = $PAGE->get_renderer('core', 'files');
87
88echo $output->header();
89echo $output->box_start();
90
91if ($file_info) {
92 $options = array();
93 //$options['visible_areas'] = array('backup'=>array('section', 'course'), 'course'=>array('legacy'), 'user'=>array('backup'));
94 echo $output->files_tree_viewer($file_info, $options);
95} else {
96 notify(get_string('nofilesavailable', 'repository'));
97}
98
99echo $output->box_end();
6b091c94 100
64f93798 101echo $output->footer();
70cedbfd 102