You are here

function styleswitcher_style_load_multiple in Style Switcher 6.2

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

Returns a list of styles.

Parameters

string $theme: Name of the theme to get styles for.

array $filter: Style properties to filter by. Each key is a property name, and value is a corresponding filter value.

Return value

array Array of styles - all or just filtered by conditions from the $filter argument. Keys are machine names and each element is a corresponding style array, which structure is the same as returned from styleswitcher_style_load().

See also

styleswitcher_style_load()

6 calls to styleswitcher_style_load_multiple()
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.
styleswitcher_config_theme_submit in ./styleswitcher.admin.inc
Form submission handler for styleswitcher_config_theme().
styleswitcher_default_style_key in ./styleswitcher.module
Finds the default style and returns its key.
styleswitcher_style_load in ./styleswitcher.module
Loads a style array by its machine name and a theme name.

... See full list

File

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

Code

function styleswitcher_style_load_multiple($theme, array $filter = array()) {
  static $styles = array();
  if (!isset($styles[$theme])) {
    $theme_styles = styleswitcher_custom_styles() + styleswitcher_theme_styles($theme);
    $settings = styleswitcher_styles_settings($theme);
    foreach (array_keys($theme_styles) as $i => $key) {
      if (isset($settings[$key])) {
        $theme_styles[$key] += $settings[$key];
      }

      // Default settings.
      $theme_styles[$key] += array(
        'is_default' => FALSE,
        'status' => TRUE,
        'weight' => 0,
        '_i' => $i,
        'theme' => $theme,
      );
    }
    $styles[$theme] = $theme_styles;
  }
  if (empty($filter)) {
    return $styles[$theme];
  }
  $return = array();
  foreach ($styles[$theme] as $key => $style) {

    // Check the requested conditions.
    foreach ($filter as $property => $value) {
      if ($style[$property] != $value) {
        continue 2;
      }
    }
    $return[$key] = $style;
  }
  return $return;
}