Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function _block_get_renderable_region($list = array()) {
- $weight = 0;
- $build = array();
- foreach ($list as $key => $block) {
- $config = $block->getBlock();
- $build[$key] = array(
- '#block' => $block,
- '#weight' => ++$weight,
- '#theme_wrappers' => array('block'),
- );
- // 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' (or 'HEAD'). User 1 being out of
- // the regular 'roles define permissions' schema, it brings too many
- // chances of having unwanted output get in the cache and later be served
- // to other users. We therefore exclude user 1 from block caching.
- if (
- $GLOBALS['user']->uid == 1 ||
- count(module_implements('node_grants')) ||
- !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) ||
- in_array($config->cache, array(DRUPAL_NO_CACHE, DRUPAL_CACHE_CUSTOM))
- ) {
- // Non-cached blocks get built immediately. Provides more content
- // that can be easily manipulated during hook_page_alter().
- $build[$key] = _block_get_renderable_block($build[$key]);
- }
- else {
- $build[$key] += array(
- '#pre_render' => array('_block_get_renderable_block'),
- '#cache' => array(
- 'keys' => array($config->module, $config->delta),
- 'granularity' => $config->cache,
- 'bin' => 'block',
- 'expire' => CACHE_TEMPORARY,
- ),
- );
- }
- // Add contextual links for this block; skip the main content block, since
- // contextual links are basically output as tabs/local tasks already. Also
- // skip the help block, since we assume that most users do not need or want
- // to perform contextual actions on the help block, and the links needlessly
- // draw attention on it.
- if ($key != 'system_main' && $key != 'system_help') {
- $build[$key]['#contextual_links']['block'] = array('admin/structure/block/manage', array($config->get('module'), $config->get('delta')));
- }
- }
- $build['#sorted'] = TRUE;
- return $build;
- }
Advertisement
Add Comment
Please, Sign In to add comment