You are here

function _regions_list in Regions 6

Same name and namespace in other branches
  1. 7 regions.module \_regions_list()

Helper function lists newly defined regions against regions already declared by a theme.

Parameters

$theme_key: A theme key to check against. Defaults to current theme.

Return value

An array keyed by region identifier, containing:

  • title: the region title
  • css: optional path to stylesheet for theming the new region, relative to implementing module directory.
  • js: optional path to javascript file, relative to implementing module directory.
  • render_callback: optional function to use in rendering blocks of this region (will be passed 'block' and $block parameters).

Or an empty array.

4 calls to _regions_list()
regions_footer in ./regions.module
Implementation of hook_footer().
regions_init in ./regions.module
Implementation of hook_init().
regions_perm in ./regions.module
Implementation of hook_perm().
regions_preprocess_page in ./regions.module
Implementation of hook_preprocess_page().

File

./regions.module, line 118
Add regions to the screen that are cross-theme compliant

Code

function _regions_list($theme_key = NULL) {
  if (!isset($theme_key)) {
    init_theme();
    global $theme_key;
  }

  // Tap the stored info file for the original_regions variable.
  $info = unserialize(db_result(db_query("SELECT info FROM {system} WHERE type = 'theme' AND name = '%s'", $theme_key)));
  if (isset($info['original_regions'])) {
    $theme_regions = array_map('t', $info['original_regions']);
  }
  else {
    $theme_regions = array_map('t', $info['regions']);
  }

  // Allow modules to define new regions.
  $defined_regions = module_invoke_all('define_regions');

  // Build an array of new regions, if defined ones don't already exist.
  $new_regions = array();
  if (!empty($defined_regions)) {
    foreach ($defined_regions as $key => $value) {
      if (!in_array($key, array_keys($theme_regions))) {
        $new_regions[$key] = $value;
      }
    }
  }
  return $new_regions;
}