You are here

function advagg_unlimited_css_traditional in Advanced CSS/JS Aggregation 6

Same name and namespace in other branches
  1. 7 includes/css.inc \advagg_unlimited_css_traditional()

Use link tags for CSS

Parameters

$files: array of css files ($media, $href, $prefix, $suffix)

&$styles: html string

1 call to advagg_unlimited_css_traditional()
advagg_unlimited_css_builder in ./advagg.module
Logic to figure out what kind of css tags to use.

File

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

Code

function advagg_unlimited_css_traditional($files, &$styles) {
  $last_prefix = '';
  $last_suffix = '';
  foreach ($files as $css_file) {
    $media = $css_file['media'];
    $prefix = empty($css_file['prefix']) ? '' : $css_file['prefix'] . "\n";
    $suffix = empty($css_file['suffix']) ? '' : $css_file['suffix'];

    // Group prefixes and suffixes.
    if (isset($css_file['href'])) {
      $href = $css_file['href'];
      if ($prefix != $last_prefix) {
        $styles .= $last_suffix . "\n" . $prefix . '<link type="text/css" rel="stylesheet" media="' . $media . '" href="' . $href . '" />' . "\n";
      }
      else {
        $styles .= '<link type="text/css" rel="stylesheet" media="' . $media . '" href="' . $href . '" />' . "\n";
      }
    }
    else {
      $data = $css_file['data'];
      if ($prefix != $last_prefix) {
        $styles .= $last_suffix . "\n" . $prefix . '<style type="text/css" media="' . $media . '">' . "\n" . $data . "\n" . '</style>' . "\n";
      }
      else {
        $styles .= '<style type="text/css" media="' . $media . '">' . "\n" . $data . "\n" . '</style>' . "\n";
      }
    }
    $last_prefix = $prefix;
    $last_suffix = $suffix;
  }
  $styles .= empty($last_suffix) ? '' : $last_suffix . "\n";
}