Loads the stylesheet and resolves all @import commands.

Loads a stylesheet and replaces @import commands with the contents of the imported file. Use this instead of file_get_contents when processing stylesheets.

The returned contents are compressed removing white space and comments only when CSS aggregation is enabled. This optimization will not apply for color.module enabled themes with CSS aggregation turned off.

Paramètres

string $file: Name of the stylesheet to be processed.

bool $optimize: Defines if CSS contents should be compressed or not.

bool $reset_basepath: Used internally to facilitate recursive resolution of @import commands.

Return value

string Contents of the stylesheet, including any resolved @import commands.

Voir aussi

drupal_load_stylesheet()

4 calls to advagg_load_stylesheet()
AdvAggCascadingStylesheetsTestCase::testRenderFile dans tests/advagg.test
Tests rendering the stylesheets.
advagg_load_css_stylesheet dans ./advagg.inc
Loads the stylesheet and resolves all @import commands.
advagg_mod_find_critical_css_file dans advagg_mod/advagg_mod.module
Try to find the critical css file.
_advagg_load_stylesheet dans ./advagg.module
Loads stylesheets recursively and returns contents with corrected paths.

Fichier

./advagg.module, line 5104

Code

function advagg_load_stylesheet($file, $optimize = FALSE, $reset_basepath = TRUE, $contents = '') {
    // These static's are not cache variables, so we don't use drupal_static().
    static $_optimize, $basepath;
    if ($reset_basepath) {
        $basepath = '';
    }
    // Store the value of $optimize for preg_replace_callback with nested @import
    // loops.
    if (isset($optimize)) {
        $_optimize = $optimize;
    }
    // Stylesheets are relative one to each other. Start by adding a base path
    // prefix provided by the parent stylesheet (if necessary).
    if ($basepath && !file_uri_scheme($file)) {
        $file = $basepath . '/' . $file;
    }
    // Store the parent base path to restore it later.
    $parent_base_path = $basepath;
    // Set the current base path to process possible child imports.
    $basepath = dirname($file);
    // Load the CSS stylesheet. We suppress errors because themes may specify
    // stylesheets in their .info file that don't exist in the theme's path,
    // but are merely there to disable certain module CSS files.
    $content = '';
    if (empty($contents) && !empty($file)) {
        $contents = (string) @advagg_file_get_contents($file);
    }
    if ($contents) {
        // Return the processed stylesheet.
        $content = advagg_load_stylesheet_content($contents, $_optimize);
    }
    // Restore the parent base path as the file and its children are processed.
    $basepath = $parent_base_path;
    if ($_optimize) {
        $content = trim($content);
    }
    return $content;
}