mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
added CSS constants - MDL-6798
This commit is contained in:
parent
16f0af59b0
commit
162f74a29f
1 changed files with 22 additions and 0 deletions
22
lib/cssconstants.php
Normal file
22
lib/cssconstants.php
Normal file
|
@ -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:
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue