function context_reaction_block::execute in Context 7.3
Same name and namespace in other branches
- 6.3 plugins/context_reaction_block.inc \context_reaction_block::execute()
- 6 plugins/context_reaction_block.inc \context_reaction_block::execute()
Execute.
File
- plugins/
context_reaction_block.inc, line 210
Class
- context_reaction_block
- Expose blocks as context reactions.
Code
function execute(&$page) {
global $theme;
// The theme system might not yet be initialized. We need $theme.
drupal_theme_initialize();
// If the context_block querystring param is set, switch to AJAX rendering.
// Note that we check the output buffer for any content to ensure that we
// are not in the middle of a PHP template render.
if (isset($_GET['context_block']) && !ob_get_contents()) {
return $this
->render_ajax($_GET['context_block']);
}
// Populate all block regions
$all_regions = $this
->system_region_list($theme);
// Load all region content assigned via blocks.
foreach (array_keys($all_regions) as $region) {
if ($this
->is_enabled_region($region)) {
if ($blocks = $this
->block_get_blocks_by_region($region)) {
// Are the blocks already sorted.
$blocks_sorted = TRUE;
// If blocks have already been placed in this region (most likely by
// Block module), then merge in blocks from Context.
if (isset($page[$region])) {
$page[$region] = array_merge($page[$region], $blocks);
// Restore the weights that Block module manufactured
// @see _block_get_renderable_array()
foreach ($page[$region] as &$block) {
if (isset($block['#block']->weight)) {
$block['#weight'] = $block['#block']->weight;
$blocks_sorted = FALSE;
}
}
}
else {
$page[$region] = $blocks;
}
$page[$region]['#sorted'] = $blocks_sorted;
}
}
}
}