You are here

function sweaver_plugin_palettes::sweaver_preprocess_page in Sweaver 6

Same name and namespace in other branches
  1. 7 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_result(db_query("SELECT info FROM {system} WHERE name = '%s' AND type ='theme'", $theme_key));
    $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'];

      // Add the css.
      drupal_add_css($css, 'theme');

      // Update $variables['css'].
      $vars['css']['all']['theme'][$css] = TRUE;

      // Update $variables['styles'].
      $vars['styles'] = drupal_get_css();
    }
  }
}