You are here

public function Sweaver::get_secondary_styles in Sweaver 7

Return all styles that affect the current page except the one active

File

./sweaver.inc, line 226
Class Sweaver.

Class

Sweaver
@file Class Sweaver.

Code

public function get_secondary_styles() {
  $path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
  $styles_to_load = array();
  $styles = db_query("SELECT style_id, visibility, pages FROM {sweaver_style} where theme = :theme and active = 2", array(
    ':theme' => $this->theme,
  ));
  while ($style = $styles
    ->fetchObject()) {
    $style->pages = drupal_strtolower($style->pages);
    $page_match = drupal_match_path($path, $style->pages);
    if ($path != $_GET['q']) {
      $page_match = $page_match || drupal_match_path($_GET['q'], $style->pages);
    }
    $page_match = !($style->visibility xor $page_match);
    if ($page_match) {
      $styles_to_load[] = $style->style_id;
    }
  }
  if (!empty($styles_to_load)) {
    $list = implode(', ', $styles_to_load);
    $styles = db_query("SELECT style_id, css FROM {sweaver_style} where style_id IN (:list)", array(
      ':list' => $list,
    ));
    $styles_to_return = array();
    while ($style = $styles
      ->fetchObject()) {
      $style->type = 'live';
      $styles_to_return[] = $style;
    }
    return $styles_to_return;
  }
  else {
    return array();
  }
}