You are here

function context_reaction_block::is_editable_check in Context 7.3

Determine if there is an active context editor block, and set a flag. We will set a flag so that we can make sure that blocks with empty content have some default content. This is needed so the save of the context inline editor does not remove the blocks with no content.

1 call to context_reaction_block::is_editable_check()
context_reaction_block::block_list in plugins/context_reaction_block.inc
An alternative version of block_list() that provides any context enabled blocks.

File

plugins/context_reaction_block.inc, line 431

Class

context_reaction_block
Expose blocks as context reactions.

Code

function is_editable_check($context_blocks) {
  foreach ($context_blocks as $r => $blocks) {
    if (isset($blocks['context_ui-editor'])) {
      $block = $blocks['context_ui-editor'];

      // see if the editor is actually enabled, lifted from _block_render_blocks
      if (!count(module_implements('node_grants')) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') && ($cid = _block_get_cache_id($block)) && ($cache = cache_get($cid, 'cache_block'))) {
        $array = $cache->data;
      }
      else {
        $array = module_invoke($block->module, 'block_view', $block->delta);
        drupal_alter(array(
          'block_view',
          "block_view_{$block->module}_{$block->delta}",
        ), $array, $block);
      }
      if (!empty($array['content'])) {
        context_set('context_ui', 'context_ui_editor_present', TRUE);
      }
      break;
    }
  }
}