| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: cssconstants.php,v 1.2 2007/01/24 07:08:50 moodler Exp $ 2 3 /****************************************************************************** 4 5 Plug in constants/variables - See MDL-6798 for details 6 7 Information from Urs Hunkler: 8 9 10 More flexible themes with CSS constants: An option for Moodle retro themes and easy colour palette variants. 11 12 I adopted Shaun Inman's "CSS Server-side Constants" to Moodle: http://www.shauninman.com/post/heap/2005/08/09/css_constants 13 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. 16 17 $THEME->cssconstants = true; 18 /// By setting this to true, you will be able to use CSS constants 19 20 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: 22 23 @server constants { 24 fontColor: #3a2830; 25 aLink: #116699; 26 aVisited: #AA2200; 27 aHover: #779911; 28 pageBackground: #FFFFFF; 29 backgroundColor: #EEEEEE; 30 backgroundSideblockHeader: #a8a4e9; 31 fontcolorSideblockHeader: #222222; 32 color1: #98818b; 33 color2: #bd807b; 34 color3: #f9d1d7; 35 color4: #e8d4d8; 36 } 37 38 39 40 The lines in the CSS files using CSS constants look like: 41 42 body { 43 font-size: 100%; 44 background-color: pageBackground; 45 color: fontColor; 46 font-family: 'Bitstream Vera Serif', georgia, times, serif; 47 margin: 0; 48 padding: 0; 49 } 50 div#page { 51 margin: 0 10px; 52 padding-top: 5px; 53 border-top-width: 10px; 54 border-top-style: solid; 55 border-top-color: color3; 56 } 57 div.clearer { 58 clear: both; 59 } 60 a:link { 61 color: aLink; 62 } 63 64 ******************************************************************************/ 65 66 function replace_cssconstants($css) { 67 if (preg_match_all("/@server\s+(?:variables|constants)\s*\{\s*([^\}]+)\s*\}\s*/i",$css,$matches)) { 68 $variables = array(); 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]; 74 } 75 } 76 $css = str_replace(array_keys($variables),array_values($variables),$css); 77 } 78 return ($css); 79 } 80 81 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140: 82 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |