You are here

function facetapi_get_delta_map in Facet API 6.3

Same name and namespace in other branches
  1. 7.2 facetapi.block.inc \facetapi_get_delta_map()
  2. 7 facetapi.block.inc \facetapi_get_delta_map()

Returns a cached delta map of hashes to names.

Sometimes our deltas are longer than 32 chars and need to be passed to hash(). Due to the block table's schema, deltas cannot be longer than 32 characters. However, hashes are nasty as CSS IDs, so we can use the map to convert the hashes back to a nicer value in facetapi_preprocess_block().

Return value

An array containing the delta map.

2 calls to facetapi_get_delta_map()
facetapi_block_info in ./facetapi.block.inc
Implements hook_block_info().
facetapi_check_block_visibility in ./facetapi.block.inc
Checks whether the block should be displayed.

File

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

Code

function facetapi_get_delta_map() {
  $map =& ctools_static(__FUNCTION__);
  if (NULL === $map) {
    if ($data = cache_get('facetapi:delta_map') && !empty($data->data)) {
      $map = $data->data;
    }
    else {
      $map = array();

      // Maps facet deltas.
      foreach (facetapi_get_searcher_info() as $searcher => $info) {
        foreach (facetapi_get_delta_map_queue($searcher, 'block') as $facet_name) {
          $delta = facetapi_build_delta($searcher, 'block', $facet_name);
          $map[facetapi_hash_delta($delta)] = $delta;
        }
      }

      // Caches the map so we don't have to do this repeatedly.
      cache_set('facetapi:delta_map', $map, 'cache', CACHE_TEMPORARY);
    }
  }
  return $map;
}