drupal_load_stylesheet
- Versions
- 6 – 7
drupal_load_stylesheet($file, $optimize = NULL)
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.
Parameters
$file Name of the stylesheet to be processed.
$optimize Defines if CSS contents should be compressed or not.
Return value
Contents of the stylesheet, including any resolved @import commands.
Code
includes/common.inc, line 3437
<?php
function drupal_load_stylesheet($file, $optimize = NULL) {
// $_optimize does not use drupal_static as it is set by $optimize.
static $_optimize;
// Store optimization parameter for preg_replace_callback with nested @import loops.
if (isset($optimize)) {
$_optimize = $optimize;
}
$contents = '';
if (file_exists($file)) {
// Load the local CSS stylesheet.
$contents = file_get_contents($file);
// Change to the current stylesheet's directory.
$cwd = getcwd();
chdir(dirname($file));
// Process the stylesheet.
$contents = drupal_load_stylesheet_content($contents, $_optimize);
// Change back directory.
chdir($cwd);
}
return $contents;
}
?>Login or register to post comments 