You are here

function styleswitcher_default_style_key in Style Switcher 6.2

Same name and namespace in other branches
  1. 8.2 styleswitcher.module \styleswitcher_default_style_key()
  2. 7.2 styleswitcher.module \styleswitcher_default_style_key()
  3. 3.0.x styleswitcher.module \styleswitcher_default_style_key()

Finds the default style and returns its key.

Parameters

string $theme: Name of the theme to find the default style for.

Return value

string The key of the default style.

3 calls to styleswitcher_default_style_key()
styleswitcher_active_style_path in ./styleswitcher.module
Finds the style active for current user and returns its path.
styleswitcher_block_view in ./styleswitcher.module
Returns a renderable view of a block.
styleswitcher_config_theme in ./styleswitcher.admin.inc
Page callback: Constructs a form for a theme-specific styles settings.

File

./styleswitcher.module, line 638
Module's hooks implementations and helper functions.

Code

function styleswitcher_default_style_key($theme) {
  static $default_key = array();

  // Search the default style explicitly set by admin.
  if (!isset($default_key[$theme])) {
    $styles = styleswitcher_style_load_multiple($theme, array(
      'is_default' => TRUE,
    ));
    $default_key[$theme] = key($styles);
  }

  // Plan B. If default style is not set in styles configuration form by admin
  // then find out initial default style defined by theme.
  if (!isset($default_key[$theme])) {
    styleswitcher_theme_styles($theme);
    $default_key[$theme] = styleswitcher_theme_default_style_key($theme);
  }

  // Fallback to the blank style.
  if (!isset($default_key[$theme])) {
    $styles = styleswitcher_style_load_multiple($theme, array(
      'path' => NULL,
    ));
    $default_key[$theme] = key($styles);
  }
  return $default_key[$theme];
}