You are here

function _print_css_generator in Printer, email and PDF versions 7.2

Generates the CSS directive to include in the printer-friendly version.

Parameters

bool $expand: If TRUE, the provided CSS will be expanded, instead of given as a list of includes.

Return value

string applicable CSS

1 call to _print_css_generator()
print_preprocess_print in ./print.pages.inc
Implements hook_preprocess_HOOK().

File

./print.pages.inc, line 403

Code

function _print_css_generator($expand = FALSE) {
  $print_css = variable_get('print_css', PRINT_CSS_DEFAULT);
  if (!empty($print_css)) {
    drupal_add_css(strtr($print_css, array(
      '%t' => drupal_get_path('theme', variable_get('theme_default')),
    )));
  }
  else {
    drupal_add_css(drupal_get_path('module', 'print') . '/css/print.css');
  }
  $drupal_css = drupal_add_css();
  if (!variable_get('print_keep_theme_css', PRINT_KEEP_THEME_CSS_DEFAULT)) {
    foreach ($drupal_css as $key => $css_file) {
      if ($css_file['group'] == CSS_THEME) {

        // Unset the theme's CSS.
        unset($drupal_css[$key]);
      }
    }
  }

  // Expand the CSS if requested.
  if ($expand) {
    $style = '';
    $css_files = array_keys($drupal_css);
    foreach ($css_files as $filename) {
      if (file_exists($filename)) {
        $style .= file_get_contents($filename, TRUE);
      }
    }
    return "<style type='text/css' media='all'>{$style}</style>\n";
  }
  else {
    return drupal_get_css($drupal_css);
  }
}