You are here

public function Sweaver::get_current_style in Sweaver 6

Same name and namespace in other branches
  1. 7 sweaver.inc \Sweaver::get_current_style()

Return a style for a theme.

Parameters

$theme: The machine name of the theme.

$reset: Whether to reset the current $css variable or not.

Return value

$css The css definition for this theme.

File

./sweaver.inc, line 153
Class Sweaver.

Class

Sweaver
@file Class Sweaver.

Code

public function get_current_style($reset = FALSE) {
  $run =& ctools_static('run', FALSE);
  $css =& ctools_static('css', FALSE);
  if (!$run || $reset) {
    $run = TRUE;
    if (sweaver_session(NULL, 'sweaver_temp')) {
      ctools_include('object-cache');
      $css = ctools_object_cache_get('sweaver-styling', 'sweaver-styling');
      $css->type = 'draft';
    }
    elseif (sweaver_session(NULL, 'draft_mode')) {
      $table = sweaver_session(NULL, 'loaded_table') == 'live' ? 'sweaver_style' : 'sweaver_style_draft';
      $css = db_fetch_object(db_query("SELECT * FROM {" . $table . "} where style_id = %d", sweaver_session(NULL, 'loaded_style')));
      $css->type = 'draft';
    }
    else {
      $css = db_fetch_object(db_query("SELECT style_id, theme, style, css, customcss, palette, themesettings, active FROM {sweaver_style} where theme = '%s' and active = 1", $this->theme));
      $css->type = 'live';
    }
    if (!isset($css->style_id)) {
      $css = NULL;
    }
  }
  $this->style = $css;
  return $css;
}