See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * This file is part of the Database module for Moodle 19 * 20 * @copyright 2005 Martin Dougiamas http://dougiamas.com 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 * @package mod_data 23 */ 24 use mod_data\manager; 25 use mod_data\preset; 26 27 define('NO_MOODLE_COOKIES', true); // session not used here 28 29 require_once('../../config.php'); 30 31 $id = optional_param('id', 0, PARAM_INT); // Course module id. 32 $d = optional_param('d', 0, PARAM_INT); // Database id. 33 $presetfullname = optional_param('preset', '', PARAM_PATH); // The directory the preset is in. 34 35 $lifetime = 600; // Seconds to cache this stylesheet. 36 $url = new moodle_url('/mod/data/js.php'); 37 38 $manager = null; 39 if ($id) { 40 list($course, $cm) = get_course_and_cm_from_cmid($id, manager::MODULE); 41 $manager = manager::create_from_coursemodule($cm); 42 $instance = $manager->get_instance(); 43 } else { 44 // We must have the database activity id. 45 $d = required_param('d', PARAM_INT); 46 $instance = $DB->get_record('data', ['id' => $d], '*', MUST_EXIST); 47 $manager = manager::create_from_instance($instance); 48 } 49 $url->param('d', $instance->id); 50 51 // Get the content. 52 if ($presetfullname) { 53 $url->param('preset', $presetfullname); 54 $preset = preset::create_from_fullname($manager, $presetfullname); 55 $content = $preset->get_template_content('jstemplate'); 56 $lifetime = 60; // Preset preview does not need a long cache. 57 } else { 58 $content = $instance->jstemplate; 59 } 60 61 $PAGE->set_url($url); 62 63 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); 64 header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $lifetime) . ' GMT'); 65 header('Cache-control: max_age = '. $lifetime); 66 header('Pragma: '); 67 header('Content-type: application/javascript; charset=utf-8'); // Correct MIME type. 68 69 echo $content;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body