protected function context_reaction_block::build_block in Context 6
Same name and namespace in other branches
- 6.3 plugins/context_reaction_block.inc \context_reaction_block::build_block()
Build a block's content. Largely taken from block_list().
2 calls to context_reaction_block::build_block()
- 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_block::render_ajax in plugins/
context_reaction_block.inc - Block renderer for AJAX requests. Triggered when $_GET['context_block'] is set. See ->execute() for how this is called.
File
- plugins/
context_reaction_block.inc, line 328
Class
- context_reaction_block
- Expose blocks as context reactions.
Code
protected function build_block($block, $reset = FALSE) {
// Block caching is not compatible with node_access modules. We also
// preserve the submission of forms in blocks, by fetching from cache
// only if the request method is 'GET'.
static $cacheable;
if (!isset($cacheable) || $reset) {
$cacheable = !count(module_implements('node_grants')) && $_SERVER['REQUEST_METHOD'] == 'GET';
}
if (!isset($block->content)) {
$block->content = '';
// Try fetching the block from cache.
if ($cacheable && ($cid = _block_get_cache_id($block))) {
if ($cache = cache_get($cid, 'cache_block')) {
$array = $cache->data;
}
else {
$array = module_invoke($block->module, 'block', 'view', $block->delta);
cache_set($cid, $array, 'cache_block', CACHE_TEMPORARY);
}
}
else {
$array = module_invoke($block->module, 'block', 'view', $block->delta);
}
if (isset($array) && is_array($array)) {
foreach ($array as $k => $v) {
$block->{$k} = $v;
}
}
}
if (!empty($block->content)) {
// Only query for custom block title if block core compatibility is enabled.
if (!variable_get('context_reaction_block_disable_core', FALSE)) {
global $user, $theme_key;
$block->title = db_select('block')
->fields('block', array(
'title',
))
->condition('module', $block->module)
->condition('delta', $block->delta)
->condition('theme', $theme_key)
->execute()
->fetchField();
// $block->title = db_result(db_query("SELECT title FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block->module, $block->delta, $theme_key));
}
// Override default block title if a custom display title is present.
if (!empty($block->title)) {
// Check plain here to allow module generated titles to keep any markup.
$block->subject = $block->title == '<none>' ? '' : check_plain($block->title);
}
if (!isset($block->subject)) {
$block->subject = '';
}
}
return $block;
}