You are here

function _regions_list in Regions 7

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

Helper function lists defined regions against theme regions.

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.

3 calls to _regions_list()
regions_init in ./regions.module
Implements hook_init().
regions_page_alter in ./regions.module
Implements hook_page_alter().
regions_permission in ./regions.module
Implements hook_permission().

File

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

Code

function _regions_list($theme_key = NULL) {

  // statically cache future calls
  $new_regions =& drupal_static(__FUNCTION__);
  if (!isset($new_regions)) {
    if (!isset($theme_key)) {
      global $theme_key;
    }

    // Tap the stored info file for the original_regions variable.
    $info = unserialize(db_query("SELECT info FROM {system} WHERE type = :type AND name = :name", array(
      ':type' => 'theme',
      ':name' => $theme_key,
    ))
      ->fetchField());
    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;
}