Returns a themed representation of all stylesheets to attach to the page.
It loads the CSS in order, with 'module' first, then 'theme' afterwards. This ensures proper cascading of styles so themes can easily override module styles through CSS selectors.
Themes may replace module-defined CSS files by adding a stylesheet with the same filename. For example, themes/bartik/system-menus.css would replace modules/system/system-menus.css. This allows themes to override complete CSS files, rather than specific selectors, when necessary.
If the original CSS file is being overridden by a theme, the theme is responsible for supplying an accompanying RTL CSS file to replace the module's.
Paramètres
array $css: (Optional) An array of CSS files. If no array is provided, the default stylesheets array is used instead.
bool $skip_alter: (Optional) If set to TRUE, this function skips calling drupal_alter() on $css, useful when the calling function passes a $css array that has already been altered.
Return value
array An array ready to be passed into drupal_render().
Voir aussi
drupal_add_css()
5 calls to advagg_get_css()
- AdvAggCascadingStylesheetsTestCase::testRenderFile dans tests/
advagg.test - Tests rendering the stylesheets.
- AdvAggJavaScriptTestCase::testJavaScriptAlwaysUsejQuery dans tests/
advagg.test - Test the 'javascript_always_use_jquery' variable.
- AdvAggThemeTestCase::testCssOverride dans tests/
advagg.test - Check theme and ajax functions and commands.
- imce-page.tpl.php dans tpl/
imce-page.tpl.php - _advagg_build_css_arrays_for_rendering dans ./
advagg.module - Builds the arrays needed for css rendering and caching.
Fichier
-
./
advagg.module, line 2732
Code
function advagg_get_css(array $css = array(), $skip_alter = FALSE) {
if (empty($css)) {
$css = drupal_add_css();
}
// Allow modules and themes to alter the CSS items.
if (!$skip_alter) {
advagg_add_default_dns_lookups($css, 'css');
// Call hook_css_alter().
drupal_alter('css', $css);
// Call hook_css_post_alter().
drupal_alter('css_post', $css);
// Call these advagg functions after the hook_css_alter was called.
advagg_fix_type($css, 'css');
}
// Sort CSS items, so that they appear in the correct order.
advagg_drupal_sort_css_js_stable($css);
// Provide the page with information about the individual CSS files used,
// information not otherwise available when CSS aggregation is enabled. The
// setting is attached later in this function, but is set here, so that CSS
// files removed below are still considered "used" and prevented from being
// added in a later AJAX request.
// Skip if no files were added to the page or jQuery.extend() will overwrite
// the Drupal.settings.ajaxPageState.css object with an empty array.
if (!empty($css)) {
// Cast the array to an object to be on the safe side even if not empty.
$setting['ajaxPageState']['css'] = (object) array_fill_keys(array_keys($css), 1);
}
// Remove the overridden CSS files. Later CSS files override former ones.
$previous_item = array();
foreach ($css as $key => $item) {
if ($item['type'] == 'file') {
// If defined, force a unique basename for this file.
$basename = isset($item['basename']) ? $item['basename'] : drupal_basename($item['data']);
if (isset($previous_item[$basename])) {
// Remove the previous item that shared the same base name.
unset($css[$previous_item[$basename]]);
}
$previous_item[$basename] = $key;
}
}
// Remove empty files.
advagg_remove_empty_files($css);
// Render the HTML needed to load the CSS.
$styles = array(
'#type' => 'styles',
'#items' => $css,
);
if (!empty($setting)) {
$styles['#attached']['js'][] = array(
'type' => 'setting',
'data' => $setting,
);
}
return $styles;
}