New, shorter intro to styles files that calls a function.
authormoodler <moodler>
Tue, 12 Aug 2003 07:52:19 +0000 (07:52 +0000)
committermoodler <moodler>
Tue, 12 Aug 2003 07:52:19 +0000 (07:52 +0000)
This function sets header information to improve caching (default 5 minutes)

Cookies are also prevented to improve cacheability.

12 files changed:
lib/weblib.php
theme/brightretro/styles.php
theme/cordoroyblue/styles.php
theme/garden/styles.php
theme/oceanblue/styles.php
theme/poweraid/styles.php
theme/standard/styles.php
theme/standardblue/styles.php
theme/standardgreen/styles.php
theme/standardlogo/styles.php
theme/standardred/styles.php
theme/standardwhite/styles.php

index a9a53d1c3e1d9924ac13a149ad763f70eff31066..5985c26c2df03683b94cbf1e6aa180dd5c18cd8a 100644 (file)
@@ -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;
index 9f41f51e74d6e082424007ec48657e7d351ab2b2..d7e8d26ebe093881c9fcfd10a8f7d5628e219784 100644 (file)
@@ -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. 
index 59bb199596fe4a3ce048cacbae93a93f786a04e2..5bd43b9314171e45763029b136bafe13bba64a37 100644 (file)
@@ -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, 
index 169bdc6e22cb9379d21391e76c2edbe9c864ada6..5719fef320aa7b413d629ef3292d921f4aa11d07 100755 (executable)
@@ -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, 
index 07e4e559dce2c70731c446c035d2928727a070e9..dd861fde7b161feb9da262d9194d2d8daef63b38 100644 (file)
@@ -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, 
index 0a1e9794e0778d908be4b3981843f5d9af88f82b..8970299c09f28ebad97ff70fef526f7b20634750 100644 (file)
 
 /* 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.
index b89b8aba50bc5a57167703910caf67cf5becfb8e..731de2122069e635ce5d3270d4df3565109cd74f 100644 (file)
@@ -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, 
index b89b8aba50bc5a57167703910caf67cf5becfb8e..3025f069e5190465d1c4de4ade62495412659da7 100644 (file)
@@ -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, 
index b89b8aba50bc5a57167703910caf67cf5becfb8e..3025f069e5190465d1c4de4ade62495412659da7 100644 (file)
@@ -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, 
index b89b8aba50bc5a57167703910caf67cf5becfb8e..3025f069e5190465d1c4de4ade62495412659da7 100644 (file)
@@ -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, 
index b89b8aba50bc5a57167703910caf67cf5becfb8e..3025f069e5190465d1c4de4ade62495412659da7 100644 (file)
@@ -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, 
index b89b8aba50bc5a57167703910caf67cf5becfb8e..3025f069e5190465d1c4de4ade62495412659da7 100644 (file)
@@ -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,