You are here

function sweaver_preprocess_page in Sweaver 7

Same name and namespace in other branches
  1. 6 sweaver.module \sweaver_preprocess_page()

Implements hook_preprocess_page().

File

./sweaver.module, line 403
Sweaver functions.

Code

function sweaver_preprocess_page(&$vars) {
  $sweaver = Sweaver::get_instance();
  $styles = array();

  // Load css for this theme if available.
  if (drupal_static('load_style')) {

    // Extra check for the theme if we need to load css files.
    if (drupal_static('load_style')) {
      if (!empty($GLOBALS['theme'])) {
        $sweaver
          ->set_current_style($GLOBALS['theme']);
      }
    }
    $sweaver_style = $sweaver
      ->get_current_style();
    if (!is_null($sweaver_style)) {
      $styles[] = $sweaver_style;
    }
  }

  //$styles = array_merge($styles, $sweaver->get_secondary_styles());
  if (!empty($styles)) {
    $settings = array(
      'weight' => 1000,
      'preprocess' => TRUE,
      'group' => CSS_THEME,
    );
    foreach ($styles as $sweaver_style) {
      $css_path = 'public://sweaver/sweaver_' . $sweaver
        ->get_theme_key() . '_' . $sweaver_style->style_id . '_' . $sweaver_style->type . '.css';
      drupal_add_css($css_path, $settings);
    }
    foreach (array_keys($sweaver
      ->get_plugins_registry(TRUE)) as $plugin_name) {
      $sweaver_plugin = $sweaver
        ->get_plugin($plugin_name);

      // Fire preprocess.
      $sweaver_plugin
        ->sweaver_preprocess_page($vars);
    }
  }
}