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.

Paramètres

array $matches: The matches from preg_replace_callback().

Return value

array String with altered internal url() paths.

Voir aussi

_drupal_load_stylesheet()

1 string reference to '_advagg_load_stylesheet'
advagg_load_stylesheet_content dans ./advagg.module
Processes the contents of a stylesheet for aggregation.

Fichier

./advagg.module, line 5296

Code

function _advagg_load_stylesheet(array $matches) {
    $filename = $matches[1];
    // Load the imported stylesheet and replace @import commands in there as well.
    $file = advagg_load_stylesheet($filename, NULL, FALSE);
    if (empty($file)) {
        if (strpos($matches[0], 'http://') === 0 || strpos($matches[0], 'https://') === 0 || strpos($matches[0], '//') === 0) {
            return $matches[0];
        }
        if (variable_get('advagg_debug', ADVAGG_DEBUG) >= 2) {
            watchdog('advagg-debug', 'Trying to load @file via @import statement but it was not found.', array(
                '@file' => $filename,
            ), WATCHDOG_DEBUG);
        }
        if (variable_get('advagg_cache_level', ADVAGG_CACHE_LEVEL) <= 1) {
            return $matches[0];
        }
        else {
            return '';
        }
    }
    // 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]++:|/)([^\'")]+)([\'"]?+)\\s*\\)%i', 'url(\\1' . $directory . '\\2\\3)', $file);
}