You are here

function sweaver_plugin_palettes::sweaver_preprocess_page in Sweaver 7

Same name and namespace in other branches
  1. 6 plugins/sweaver_plugin_palettes/sweaver_plugin_palettes.inc \sweaver_plugin_palettes::sweaver_preprocess_page()

Preprocess page function.

Overrides sweaver_plugin::sweaver_preprocess_page

File

plugins/sweaver_plugin_palettes/sweaver_plugin_palettes.inc, line 19
Palettes plugin.

Class

sweaver_plugin_palettes
@file Palettes plugin.

Code

function sweaver_preprocess_page(&$vars) {

  // Get active palette.
  $current_style = Sweaver::get_instance()
    ->get_current_style();
  $active_palette = isset($current_style->palette) ? $current_style->palette : '';

  // Add the correct stylesheet if an active palette is found.
  if (!empty($active_palette)) {
    $theme_key = Sweaver::get_instance()
      ->get_theme_key();
    $info = db_query("SELECT info FROM {system} WHERE name = :theme AND type ='theme'", array(
      ':theme' => $theme_key,
    ))
      ->fetchField();
    $theme_info = unserialize($info);
    if (isset($theme_info['sweaver']['palettes'][$active_palette])) {
      $css = drupal_get_path('theme', $theme_key) . '/' . $theme_info['sweaver']['palettes'][$active_palette]['file'];
      $settings = array(
        'weight' => 1001,
        'preprocess' => TRUE,
        'group' => CSS_THEME,
      );
      drupal_add_css($css, $settings);
    }
  }
}