You are here

function boxes_context_block_info_alter in Boxes 6

Same name and namespace in other branches
  1. 7 boxes.module \boxes_context_block_info_alter()

Implementation of hook_context_block_info_alter().

Provides spaces integration when working with blocks using context.

File

./boxes.module, line 492

Code

function boxes_context_block_info_alter(&$blocks) {

  // Add boxes JS. If this is getting called, it's highly likely a context
  // inline editor is on the page.
  boxes_add_js();
  if (module_exists('spaces') && ($space = spaces_get_space())) {
    $item = menu_get_item();

    // Prevent space-specific blocks from appearing on the dashboard settings
    // page within a space.
    if (!(isset($item['page_callback'], $item['page_arguments'][0]) && $item['page_callback'] === 'drupal_get_form' && $item['page_arguments'][0] === 'spaces_dashboard_admin_form')) {
      foreach ($space->controllers->boxes
        ->get() as $box) {
        $add = new stdClass();
        $add->bid = "boxes-{$box->delta}";
        $add->delta = $box->delta;
        $add->info = $box->description;
        $add->cache = BLOCK_NO_CACHE;
        $add->module = 'boxes';
        $blocks[$add->bid] = $add;
      }
    }
  }
}