You are here

function context_active_contexts in Context 6

Same name and namespace in other branches
  1. 6.3 context.module \context_active_contexts()
  2. 6.2 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.

5 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_condition_context::execute in plugins/context_condition_context.inc
Execute.
context_reaction::get_contexts in plugins/context_reaction.inc
Retrieve active contexts that have values for this reaction.
context_reaction_block::block_list in plugins/context_reaction_block.inc
An alternative version of block_list() that provides any context enabled blocks.
context_reaction_debug::execute in plugins/context_reaction_debug.inc
Output a list of active contexts.

File

./context.module, line 437

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;
}