You are here

function ctools_css_compress in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/css.inc \ctools_css_compress()

Compress css data (filter it first!) to optimize for use on view.

Parameters

array $css_data: An array of css data, as produced by @see ctools_css_disassemble() disassembler and the @see ctools_css_filter_css_data() filter.

Return value

string $css css optimized for use.

1 call to ctools_css_compress()
ctools_css_filter in includes/css.inc
Filter a chunk of CSS text.

File

includes/css.inc, line 271

Code

function ctools_css_compress($css_data) {

  // Initialize the output.
  $css = '';

  // Iterate through all the statements.
  foreach ($css_data as $selector_str => $declaration) {
    if (empty($declaration)) {

      // Skip this statement if filtering removed all parts of the declaration.
      continue;
    }

    // Add the selectors, separating them with commas.
    $css .= $selector_str;

    // And, the opening curly brace.
    $css .= "{";

    // Iterate through all the statement properties.
    foreach ($declaration as $property => $value) {
      $css .= $property . ':' . $value . ';';
    }

    // Add the closing curly brace.
    $css .= "}";
  }

  // Return the output.
  return $css;
}