You are here

function panels_page_disassemble_css in Panels 5.2

Same name and namespace in other branches
  1. 6.2 panels_page/panels_page.css_filter.inc \panels_page_disassemble_css()

Disassemble the css string.

Strip the css of irrelevant characters, invalid/malformed selectors and declarations, and otherwise prepare it for processing.

Parameters

string $css: A string containing the css to be disassembled.

Return value

array $disassembled_css An array of disassembled, slightly cleaned-up/formatted css statements.

1 call to panels_page_disassemble_css()
panels_page_view_page in panels_page/panels_page.module
Page callback to view a panel page.

File

panels_page/panels_page.css_filter.inc, line 83

Code

function panels_page_disassemble_css($css) {
  $disassembled_css = array();

  // Remove comments.
  $css = preg_replace("/\\/\\*(.*)?\\*\\//Usi", "", $css);

  // Split out each statement
  $statements = explode("}", $css);

  // If we have any statements, parse them.
  if (!empty($statements)) {

    // Iterate through all of the statements.
    foreach ($statements as $statement) {

      // Get the selector(s) and declaration.
      list($selector_str, $declaration) = explode('{', $statement);

      // If the selector exists, then disassemble it, check it, and regenerate
      // the selector string.
      $selector_str = empty($selector_str) ? FALSE : panels_page_disassemble_css_selector($selector_str);
      if (empty($selector_str)) {

        // No valid selectors. Bomb out and start the next item.
        continue;
      }

      // Disassemble the declaration, check it and tuck it into an array.
      $disassembled_css[$selector_str] = panels_page_disassemble_css_declaration(strtolower($declaration));
    }
  }
  return $disassembled_css;
}