You are here

function context_active_contexts in Context 6.2

Same name and namespace in other branches
  1. 6.3 context.module \context_active_contexts()
  2. 6 context.module \context_active_contexts()
  3. 7.3 context.module \context_active_contexts()

Loads any active contexts with associated reactions. This should be run at a late stage of the page load to ensure that relevant contexts have been set.

2 calls to context_active_contexts()
context_active_values in ./context.module
Builds an array of values based on the current active contexts and group by conditions/reactions.
context_preprocess_page in ./context.core.inc
Implementation of preprocess_page().

File

./context.module, line 441

Code

function context_active_contexts($reset = FALSE) {
  static $contexts;
  if (!isset($contexts) || $reset) {
    $contexts = array();
    $cache = context_enabled_contexts();
    foreach ($cache as $context) {
      if (context_get($context->namespace, $context->attribute) == $context->value) {
        $identifier = "{$context->namespace}-{$context->attribute}-{$context->value}";
        $contexts[$identifier] = $context;
      }
    }
    drupal_alter('context_active_contexts', $contexts);
  }
  return $contexts;
}