function _ctools_css_disassemble_declaration in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/css.inc \_ctools_css_disassemble_declaration()
1 call to _ctools_css_disassemble_declaration()
- ctools_css_disassemble in includes/
css.inc - Disassemble the css string.
File
- includes/
css.inc, line 368
Code
function _ctools_css_disassemble_declaration($declaration) {
$formatted_statement = array();
$propval_pairs = explode(";", $declaration);
// Make sure we actually have some properties to work with.
if (!empty($propval_pairs)) {
// Iterate through the remains and parse them.
foreach ($propval_pairs as $key => $propval_pair) {
// Check that we have a ':', otherwise it's an invalid pair.
if (strpos($propval_pair, ':') === FALSE) {
continue;
}
// Clean up the current property-value pair.
$propval_pair = preg_replace("/[\n|\t|\\|\\s]+/", ' ', trim($propval_pair));
// Explode the remaining fragements some more, but clean them up first.
list($property, $value) = explode(':', $propval_pair, 2);
// If the property survived, toss it onto the stack.
if (!empty($property)) {
$formatted_statement[trim($property)] = trim($value);
}
}
}
return $formatted_statement;
}