You are here

function _advagg_drupal_load_stylesheet in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 6 advagg.module \_advagg_drupal_load_stylesheet()

Loads stylesheets recursively and returns contents with corrected paths.

This function is used for recursive loading of stylesheets and returns the stylesheet content with all url() paths corrected.

1 string reference to '_advagg_drupal_load_stylesheet'
advagg_drupal_load_stylesheet_content in ./advagg.module
Process the contents of a stylesheet for aggregation.

File

./advagg.module, line 2781
Advanced CSS/JS aggregation module

Code

function _advagg_drupal_load_stylesheet($matches) {
  $filename = $matches[1];

  // Load the imported stylesheet and replace @import commands in there as well.
  $file = advagg_build_css_bundle(array(
    $filename,
  ));

  // Determine the file's directory.
  $directory = dirname($filename);

  // If the file is in the current directory, make sure '.' doesn't appear in
  // the url() path.
  $directory = $directory == '.' ? '' : $directory . '/';

  // Alter all internal url() paths. Leave external paths alone. We don't need
  // to normalize absolute paths here (i.e. remove folder/... segments) because
  // that will be done later.
  return preg_replace('/url\\(\\s*([\'"]?)(?![a-z]+:|\\/+)/i', 'url(\\1' . $directory, $file);
}