mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-32683 use slashargument urls for theme style sheets
This commit is contained in:
parent
9d473266a7
commit
7070b7f261
@ -85,14 +85,21 @@ function css_store_css(theme_config $theme, $csspath, array $cssfiles) {
|
||||
*
|
||||
* @param string $themename The name of the theme we are sending CSS for.
|
||||
* @param string $rev The revision to ensure we utilise the cache.
|
||||
* @param bool $slasharguments
|
||||
*/
|
||||
function css_send_ie_css($themename, $rev) {
|
||||
function css_send_ie_css($themename, $rev, $slasharguments) {
|
||||
$lifetime = 60*60*24*30; // 30 days
|
||||
|
||||
$css = "/** Unfortunately IE6/7 does not support more than 4096 selectors in one CSS file, which means we have to use some ugly hacks :-( **/";
|
||||
$css .= "\n@import url(styles.php?theme=$themename&rev=$rev&type=plugins);";
|
||||
$css .= "\n@import url(styles.php?theme=$themename&rev=$rev&type=parents);";
|
||||
$css .= "\n@import url(styles.php?theme=$themename&rev=$rev&type=theme);";
|
||||
if ($slasharguments) {
|
||||
$css .= "\n@import url(styles.php/$themename/$rev/plugins);";
|
||||
$css .= "\n@import url(styles.php/$themename/$rev/parents);";
|
||||
$css .= "\n@import url(styles.php/$themename/$rev/theme);";
|
||||
} else {
|
||||
$css .= "\n@import url(styles.php?theme=$themename&rev=$rev&type=plugins);";
|
||||
$css .= "\n@import url(styles.php?theme=$themename&rev=$rev&type=parents);";
|
||||
$css .= "\n@import url(styles.php?theme=$themename&rev=$rev&type=theme);";
|
||||
}
|
||||
|
||||
header('Etag: '.md5($rev));
|
||||
header('Content-Disposition: inline; filename="styles.php"');
|
||||
|
@ -518,8 +518,14 @@ class theme_config {
|
||||
$rev = theme_get_revision();
|
||||
|
||||
if ($rev > -1) {
|
||||
$params = array('theme'=>$this->name,'rev'=>$rev, 'type'=>'editor');
|
||||
return new moodle_url($CFG->httpswwwroot.'/theme/styles.php', $params);
|
||||
if (!empty($CFG->slasharguments)) {
|
||||
$url = new moodle_url("$CFG->httpswwwroot/theme/styles.php");
|
||||
$url->set_slashargument('/'.$this->name.'/'.$rev.'/editor', 'noparam', true);
|
||||
return $url;
|
||||
} else {
|
||||
$params = array('theme'=>$this->name,'rev'=>$rev, 'type'=>'editor');
|
||||
return new moodle_url($CFG->httpswwwroot.'/theme/styles.php', $params);
|
||||
}
|
||||
} else {
|
||||
$params = array('theme'=>$this->name, 'type'=>'editor');
|
||||
return new moodle_url($CFG->httpswwwroot.'/theme/styles_debug.php', $params);
|
||||
@ -589,7 +595,13 @@ class theme_config {
|
||||
$urls[] = new moodle_url($CFG->httpswwwroot.'/theme/styles.php', array('theme'=>$this->name,'rev'=>$rev, 'type'=>'parents'));
|
||||
$urls[] = new moodle_url($CFG->httpswwwroot.'/theme/styles.php', array('theme'=>$this->name,'rev'=>$rev, 'type'=>'theme'));
|
||||
} else {
|
||||
$urls[] = new moodle_url($CFG->httpswwwroot.'/theme/styles.php', array('theme'=>$this->name,'rev'=>$rev));
|
||||
if (!empty($CFG->slasharguments)) {
|
||||
$url = new moodle_url("$CFG->httpswwwroot/theme/styles.php");
|
||||
$url->set_slashargument('/'.$this->name.'/'.$rev.'/all', 'noparam', true);
|
||||
$urls[] = $url;
|
||||
} else {
|
||||
$urls[] = new moodle_url($CFG->httpswwwroot.'/theme/styles.php', array('theme'=>$this->name,'rev'=>$rev, 'type'=>'all'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// find out the current CSS and cache it now for 5 seconds
|
||||
@ -872,8 +884,6 @@ class theme_config {
|
||||
* @return string The processed CSS.
|
||||
*/
|
||||
public function post_process($css) {
|
||||
global $CFG;
|
||||
|
||||
// now resolve all image locations
|
||||
if (preg_match_all('/\[\[pix:([a-z_]+\|)?([^\]]+)\]\]/', $css, $matches, PREG_SET_ORDER)) {
|
||||
$replaced = array();
|
||||
|
@ -33,9 +33,22 @@ define('ABORT_AFTER_CONFIG', true);
|
||||
require('../config.php'); // this stops immediately at the beginning of lib/setup.php
|
||||
require_once($CFG->dirroot.'/lib/csslib.php');
|
||||
|
||||
$themename = min_optional_param('theme', 'standard', 'SAFEDIR');
|
||||
$type = min_optional_param('type', 'all', 'SAFEDIR');
|
||||
$rev = min_optional_param('rev', 0, 'INT');
|
||||
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', 'all', 'SAFEDIR');
|
||||
}
|
||||
|
||||
if (!in_array($type, array('all', 'ie', 'editor', 'plugins', 'parents', 'theme'))) {
|
||||
header('HTTP/1.0 404 not found');
|
||||
@ -52,7 +65,7 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) {
|
||||
}
|
||||
|
||||
if ($type === 'ie') {
|
||||
css_send_ie_css($themename, $rev);
|
||||
css_send_ie_css($themename, $rev, !empty($slashargument));
|
||||
}
|
||||
|
||||
$candidatesheet = "$CFG->cachedir/theme/$themename/css/$type.css";
|
||||
|
Loading…
x
Reference in New Issue
Block a user