You are here

function dynamic_background_load_image_configuration in Dynamic Background 6

Same name and namespace in other branches
  1. 7.2 dynamic_background.module \dynamic_background_load_image_configuration()
  2. 7 dynamic_background.module \dynamic_background_load_image_configuration()

Helper function that calls hook_dynamic_background_css() and sorts the returned image configurations based on weight. This function may be called by more then one preprocessor function, so a static cache applied.

@staticvar type $images

Parameters

type $reset:

Return value

type

2 calls to dynamic_background_load_image_configuration()
dynamic_background_css in ./dynamic_background.module
Menu callback function used to generate an body style css with the selected background image. The callback is /background.css.
dynamic_background_preprocess_page in ./dynamic_background.module
Page preprocess function used to create the $background variable, so it can be used in page.tpl.

File

./dynamic_background.module, line 270
This module enables administrators to upload images used as background on the site. The selected background image link is exposed as either $background in the page.tpl file or as /background.css.

Code

function dynamic_background_load_image_configuration(&$vars, $reset = FALSE) {
  static $images;
  if (!isset($images) || $reset) {

    // If images is null, create empty array (as no images may be selected).
    if (is_null($images)) {
      $images = array();
    }

    // Implementation of hook_dynamic_background_css().
    foreach (module_implements('dynamic_background_css') as $module) {
      $function = $module . '_dynamic_background_css';
      $result = $function($vars);
      if ($result && is_array($result)) {
        $images[$module] = $result;
      }
    }

    // Sort images based on weight and get images with highest weight.
    usort($images, '_dynamic_background_cmp');
  }
  return $images;
}