]> git.mjollnir.org Git - moodle.git/commitdiff
added CSS constants - MDL-6798
authorurs_hunkler <urs_hunkler>
Mon, 8 Jan 2007 18:37:24 +0000 (18:37 +0000)
committerurs_hunkler <urs_hunkler>
Mon, 8 Jan 2007 18:37:24 +0000 (18:37 +0000)
lib/cssconstants.php [new file with mode: 0644]

diff --git a/lib/cssconstants.php b/lib/cssconstants.php
new file mode 100644 (file)
index 0000000..144a39c
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+/******************************************************************************
+ Plug in constants/variables 
+ ******************************************************************************/
+function replace_cssconstants($css) {
+    if (preg_match_all("/@server\s+(?:variables|constants)\s*\{\s*([^\}]+)\s*\}\s*/i",$css,$matches)) {
+        $variables  = array();
+        foreach ($matches[0] as $key=>$server) {
+            $css = str_replace($server,'',$css);
+            preg_match_all("/([^:\}\s]+)\s*:\s*([^;\}]+);/",$matches[1][$key],$vars);
+            foreach ($vars[1] as $var=>$value) {
+                $variables[$value] = $vars[2][$var];
+                }
+            }
+        $css = str_replace(array_keys($variables),array_values($variables),$css);
+        }
+    return ($css);
+}
+
+// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
+?>