You are here

function facetapi_block_info in Facet API 6.3

Same name and namespace in other branches
  1. 6 facetapi.widget.inc \facetapi_block_info()
  2. 7.2 facetapi.block.inc \facetapi_block_info()
  3. 7 facetapi.block.inc \facetapi_block_info()

Implements hook_block_info().

1 call to facetapi_block_info()
facetapi_block in ./facetapi.block.inc
@file Block realm code and hook implementations.

File

./facetapi.block.inc, line 21
Block realm code and hook implementations.

Code

function facetapi_block_info() {
  $blocks = array();

  // Gets delta map, iterates over all enabled facets.
  $map = facetapi_get_delta_map();
  foreach (facetapi_get_searcher_info() as $searcher => $info) {

    // Gets cache settings for the searcher.
    $cache = variable_get('facetapi:block_cache:' . $searcher, BLOCK_NO_CACHE);

    // Adds blocks for facets that are enabled or whose delta mapping is forced.
    foreach (facetapi_get_delta_map_queue($searcher, 'block') as $facet_name) {
      if ($facet = facetapi_facet_load($facet_name, $searcher)) {

        // Gets the delta from the delta map.
        $string = facetapi_build_delta($searcher, 'block', $facet_name);
        $delta = array_search($string, $map);

        // Defines the block.
        $blocks[$delta] = array(
          'info' => 'Facet API: ' . $info['label'] . ' : ' . $facet['label'],
          'cache' => $cache,
        );
      }
    }
  }

  // Returns available blocks.
  return $blocks;
}