function context_enabled_contexts in Context 6
Same name and namespace in other branches
- 6.3 context.module \context_enabled_contexts()
- 6.2 context.module \context_enabled_contexts()
- 7.3 context.module \context_enabled_contexts()
Retrieves all enabled contexts from the cache.
4 calls to context_enabled_contexts()
- context_active_contexts in ./
context.module - 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.
- context_condition_map in ./
context.module - Loads an associative array of conditions => context identifiers to allow contexts to be set by different conditions. Called by context_set_by_condition().
- context_set_by_condition in ./
context.module - Sets a namespace-attribute-value context that has been associated with the provided condition.
- context_ui_form_block_admin_configure_alter in context_ui/
context_ui.module - Implementation of hook_form_alter() for block_admin_configure.
File
- ./
context.module, line 397
Code
function context_enabled_contexts($namespace = NULL, $reset = FALSE) {
static $enabled;
static $namespaces;
if (!isset($enabled) || $reset) {
$enabled = array();
$cache = context_cache_get('enabled');
if ($cache && !$reset) {
$enabled = $cache;
}
else {
$contexts = context_contexts(TRUE);
foreach ($contexts as $context) {
if (context_status($context) == CONTEXT_STATUS_ENABLED) {
$identifier = "{$context->namespace}-{$context->attribute}-{$context->value}";
$enabled[$identifier] = $context;
}
}
// Set the cache
context_cache_set('enabled', $enabled);
}
foreach ($enabled as $identifier => $context) {
if (!isset($namespaces[$context->namespace])) {
$namespaces[$context->namespace] = array();
}
$namespaces[$context->namespace][$identifier] = $context;
}
}
if (!empty($namespace)) {
return !empty($namespaces[$namespace]) ? $namespaces[$namespace] : array();
}
return $enabled;
}