function context_active_values in Context 6
Same name and namespace in other branches
- 6.2 context.module \context_active_values()
Builds an array of values based on the current active contexts and group by conditions/reactions.
Parameters
$type: The condition or reaction type to pull values for.
$reset: Boolean value for resetting the static cache.
Return value
Returns a keyed array of reactions and values.
5 calls to context_active_values()
- context_block_list in ./
context.core.inc - An alternative version of block_list() that provides any context enabled blocks.
- context_links in ./
context.core.inc - Generates an array of links (suitable for use with theme_links) to the node forms of types associated with current active contexts.
- context_menu_navigation_links in ./
context.core.inc - Wrapper around menu_navigation_links() that gives themers the option of building navigation links based on an active context trail.
- context_menu_set_active in ./
context.core.inc - Iterates through a provided links array for use with theme_links() (e.g. from menu_primary_links()) and provides an active class for any items that have a path that matches an active context.
- context_preprocess_page in ./
context.core.inc - Implementation of preprocess_page().
File
- ./
context.module, line 506
Code
function context_active_values($type = NULL, $reset = FALSE) {
static $value_map;
if (!isset($value_map) || $reset) {
$value_map = array();
// This sucks... @TODO: fix it!!!
$keys = array_merge(array_keys(context_reactions()), array_keys(context_conditions()));
$keys[] = 'block';
foreach ($keys as $key) {
foreach (context_active_contexts() as $identifier => $context) {
if (!empty($context->{$key})) {
if (!isset($value_map[$key])) {
$value_map[$key] = array();
}
if (is_array($context->{$key})) {
$value_map[$key] = array_merge($value_map[$key], $context->{$key});
}
else {
$value_map[$key][] = $context->{$key};
}
}
}
}
}
if (!empty($type)) {
return !empty($value_map[$type]) ? $value_map[$type] : array();
}
return $value_map;
}