You are here

function _ctools_css_disassemble_declaration in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 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 345
CSS filtering functions. Contains a disassembler, filter, compressor, and decompressor.

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;
}