MDL-32683 use slashargument urls for theme javascript files

This commit is contained in:
Petr Skoda 2012-05-05 15:31:27 +02:00
parent 7070b7f261
commit ecbad2ad1c
2 changed files with 23 additions and 4 deletions

View File

@ -775,7 +775,13 @@ class theme_config {
$params = array('theme'=>$this->name,'rev'=>$rev);
$params['type'] = $inhead ? 'head' : 'footer';
return new moodle_url($CFG->httpswwwroot.'/theme/javascript.php', $params);
if (!empty($CFG->slasharguments) and $rev > 0) {
$url = new moodle_url("$CFG->httpswwwroot/theme/javascript.php");
$url->set_slashargument('/'.$this->name.'/'.$rev.'/'.$params['type'], 'noparam', true);
return $url;
} else {
return new moodle_url($CFG->httpswwwroot.'/theme/javascript.php', $params);
}
}
/**

View File

@ -32,9 +32,22 @@ define('NO_DEBUG_DISPLAY', true);
define('ABORT_AFTER_CONFIG', true);
require('../config.php'); // this stops immediately at the beginning of lib/setup.php
$themename = min_optional_param('theme', 'standard', 'SAFEDIR');
$rev = min_optional_param('rev', 0, 'INT');
$type = min_optional_param('type', 'head', 'RAW');
if ($slashargument = min_get_slash_argument()) {
$slashargument = ltrim($slashargument, '/');
if (substr_count($slashargument, '/') < 2) {
image_not_found();
}
// image must be last because it may contain "/"
list($themename, $rev, $type) = explode('/', $slashargument, 3);
$themename = min_clean_param($themename, 'SAFEDIR');
$rev = min_clean_param($rev, 'INT');
$type = min_clean_param($type, 'SAFEDIR');
} else {
$themename = min_optional_param('theme', 'standard', 'SAFEDIR');
$rev = min_optional_param('rev', 0, 'INT');
$type = min_optional_param('type', 'head', 'RAW');
}
if ($type !== 'head' and $type !== 'footer') {
header('HTTP/1.0 404 not found');