3 /******************************************************************************
5 Plug in constants/variables - See MDL-6798 for details
7 Information from Urs Hunkler:
10 More flexible themes with CSS constants: An option for Moodle retro themes and easy colour palette variants.
12 I adopted Shaun Inman's "CSS Server-side Constants" to Moodle: http://www.shauninman.com/post/heap/2005/08/09/css_constants
14 With setting "cssconstants" to true in "config.php" you activate the CSS constants. If "cssconstants" is missing or set to "false" the
15 replacement function is not used.
17 $THEME->cssconstants = true;
18 /// By setting this to true, you will be able to use CSS constants
21 The constant definitions are written into a separate CSS file named like "constants.css" and loaded first in config.php. You can use constants for any CSS properties. The constant definition looks like:
28 pageBackground: #FFFFFF;
29 backgroundColor: #EEEEEE;
30 backgroundSideblockHeader: #a8a4e9;
31 fontcolorSideblockHeader: #222222;
40 The lines in the CSS files using CSS constants look like:
44 background-color: pageBackground;
46 font-family: 'Bitstream Vera Serif', georgia, times, serif;
53 border-top-width: 10px;
54 border-top-style: solid;
55 border-top-color: color3;
64 ******************************************************************************/
66 function replace_cssconstants($css) {
67 if (preg_match_all("/@server\s+(?:variables|constants)\s*\{\s*([^\}]+)\s*\}\s*/i",$css,$matches)) {
69 foreach ($matches[0] as $key=>$server) {
70 $css = str_replace($server,'',$css);
71 preg_match_all("/([^:\}\s]+)\s*:\s*([^;\}]+);/",$matches[1][$key],$vars);
72 foreach ($vars[1] as $var=>$value) {
73 $variables[$value] = $vars[2][$var];
76 $css = str_replace(array_keys($variables),array_values($variables),$css);
81 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140: