diff --git a/lib/weblib.php b/lib/weblib.php index a9a53d1c3e1..5985c26c2df 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -780,6 +780,24 @@ function print_footer ($course=NULL) { include ("$CFG->dirroot/theme/$CFG->theme/footer.html"); } +function style_sheet_setup($lastmodified, $lifetime, $themename="") { + + global $CFG; + + header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"); + header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT"); + header("Cache-control: max_age = $lifetime"); + header("Pragma: "); + header("Content-type: text/css"); // Correct MIME type + + if (!empty($themename)) { + $CFG->theme = $themename; + } + + return "$CFG->wwwroot/theme/$CFG->theme"; + +} + function user_login_string($course, $user=NULL) { global $USER, $CFG; diff --git a/theme/brightretro/styles.php b/theme/brightretro/styles.php index 9f41f51e74d..d7e8d26ebe0 100644 --- a/theme/brightretro/styles.php +++ b/theme/brightretro/styles.php @@ -2,15 +2,9 @@ /// We use PHP so we can do value substitutions into the styles + $nomoodlecookie = true; require_once("../../config.php"); - - header("Content-type: text/css"); /// Correct MIME type - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); /// From here on it's nearly a normal stylesheet. diff --git a/theme/cordoroyblue/styles.php b/theme/cordoroyblue/styles.php index 59bb199596f..5bd43b93141 100644 --- a/theme/cordoroyblue/styles.php +++ b/theme/cordoroyblue/styles.php @@ -2,15 +2,10 @@ /// We use PHP so we can do value substitutions into the styles - require_once("../../config.php"); + $nomoodlecookie = true; + require_once("../../config.php"); + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); - header("Content-type: text/css"); /// Correct MIME type - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; /// From here on it's nearly a normal stylesheet. /// First are some CSS definitions for normal tags, diff --git a/theme/garden/styles.php b/theme/garden/styles.php index 169bdc6e22c..5719fef320a 100755 --- a/theme/garden/styles.php +++ b/theme/garden/styles.php @@ -2,15 +2,9 @@ /// We use PHP so we can do value substitutions into the styles - require_once("../../config.php"); - - header("Content-type: text/css"); // Correct MIME type - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; + $nomoodlecookie = true; + require_once("../../config.php"); + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); /// From here on it's nearly a normal stylesheet. /// First are some CSS definitions for normal tags, diff --git a/theme/oceanblue/styles.php b/theme/oceanblue/styles.php index 07e4e559dce..dd861fde7b1 100644 --- a/theme/oceanblue/styles.php +++ b/theme/oceanblue/styles.php @@ -2,15 +2,9 @@ /// We use PHP so we can do value substitutions into the styles - require_once("../../config.php"); - - header("Content-type: text/css"); // Correct MIME type - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; + $nomoodlecookie = true; + require_once("../../config.php"); + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); /// From here on it's nearly a normal stylesheet. /// First are some CSS definitions for normal tags, diff --git a/theme/poweraid/styles.php b/theme/poweraid/styles.php index 0a1e9794e07..8970299c09f 100644 --- a/theme/poweraid/styles.php +++ b/theme/poweraid/styles.php @@ -26,13 +26,9 @@ /* We use PHP so we can do value substitutions into the styles */ - require_once("../../config.php"); - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; + $nomoodlecookie = true; + require_once("../../config.php"); + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); /* From here on it's nearly a normal stylesheet. diff --git a/theme/standard/styles.php b/theme/standard/styles.php index b89b8aba50b..731de212206 100644 --- a/theme/standard/styles.php +++ b/theme/standard/styles.php @@ -2,15 +2,9 @@ /// We use PHP so we can do value substitutions into the styles + $nomoodlecookie = true; require_once("../../config.php"); - - header("Content-type: text/css"); // Correct MIME type - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); /// From here on it's nearly a normal stylesheet. /// First are some CSS definitions for normal tags, diff --git a/theme/standardblue/styles.php b/theme/standardblue/styles.php index b89b8aba50b..3025f069e51 100644 --- a/theme/standardblue/styles.php +++ b/theme/standardblue/styles.php @@ -2,15 +2,9 @@ /// We use PHP so we can do value substitutions into the styles - require_once("../../config.php"); - - header("Content-type: text/css"); // Correct MIME type - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; + $nomoodlecookie = true; + require_once("../../config.php"); + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); /// From here on it's nearly a normal stylesheet. /// First are some CSS definitions for normal tags, diff --git a/theme/standardgreen/styles.php b/theme/standardgreen/styles.php index b89b8aba50b..3025f069e51 100644 --- a/theme/standardgreen/styles.php +++ b/theme/standardgreen/styles.php @@ -2,15 +2,9 @@ /// We use PHP so we can do value substitutions into the styles - require_once("../../config.php"); - - header("Content-type: text/css"); // Correct MIME type - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; + $nomoodlecookie = true; + require_once("../../config.php"); + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); /// From here on it's nearly a normal stylesheet. /// First are some CSS definitions for normal tags, diff --git a/theme/standardlogo/styles.php b/theme/standardlogo/styles.php index b89b8aba50b..3025f069e51 100644 --- a/theme/standardlogo/styles.php +++ b/theme/standardlogo/styles.php @@ -2,15 +2,9 @@ /// We use PHP so we can do value substitutions into the styles - require_once("../../config.php"); - - header("Content-type: text/css"); // Correct MIME type - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; + $nomoodlecookie = true; + require_once("../../config.php"); + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); /// From here on it's nearly a normal stylesheet. /// First are some CSS definitions for normal tags, diff --git a/theme/standardred/styles.php b/theme/standardred/styles.php index b89b8aba50b..3025f069e51 100644 --- a/theme/standardred/styles.php +++ b/theme/standardred/styles.php @@ -2,15 +2,9 @@ /// We use PHP so we can do value substitutions into the styles - require_once("../../config.php"); - - header("Content-type: text/css"); // Correct MIME type - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; + $nomoodlecookie = true; + require_once("../../config.php"); + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); /// From here on it's nearly a normal stylesheet. /// First are some CSS definitions for normal tags, diff --git a/theme/standardwhite/styles.php b/theme/standardwhite/styles.php index b89b8aba50b..3025f069e51 100644 --- a/theme/standardwhite/styles.php +++ b/theme/standardwhite/styles.php @@ -2,15 +2,9 @@ /// We use PHP so we can do value substitutions into the styles - require_once("../../config.php"); - - header("Content-type: text/css"); // Correct MIME type - - if (isset($themename)) { - $CFG->theme = $themename; - } - - $themeurl = "$CFG->wwwroot/theme/$CFG->theme"; + $nomoodlecookie = true; + require_once("../../config.php"); + $themeurl = style_sheet_setup(filemtime("styles.php"), 300, $themename); /// From here on it's nearly a normal stylesheet. /// First are some CSS definitions for normal tags,