You are here

function current_search_check_visibility in Facet API 7.2

Same name and namespace in other branches
  1. 6.3 contrib/current_search/current_search.block.inc \current_search_check_visibility()
  2. 7 contrib/current_search/current_search.block.inc \current_search_check_visibility()

Checks whether the block should be displayed.

In cases where modules like Context are being used, hook_block_list_alter() is not invoked and we get fatal errors. We have to test whether or not the hook has been invoked and call this function manually otherwise.

Parameters

$delta: The block delta.

Return value

A boolean flagging whether to display this block or not.

1 call to current_search_check_visibility()
current_search_block_view in contrib/current_search/current_search.block.inc
Returns the content for a facet based on the delta.

File

contrib/current_search/current_search.block.inc, line 168
Block hook implementations and block form alterations.

Code

function current_search_check_visibility($delta) {
  $searcher = current_search_get_block_searcher($delta);

  // Checks whether block should be displayed.
  if (!facetapi_is_active_searcher($searcher)) {
    return FALSE;
  }
  if (!($adapter = facetapi_adapter_load($searcher))) {
    return FALSE;
  }
  if (!$adapter
    ->searchExecuted($searcher)) {
    return FALSE;
  }
  if (!($config = current_search_item_load($delta))) {
    return FALSE;
  }

  // Returns TRUE based on the empty_searches setting and the current search.
  switch ($config->settings['advanced']['empty_searches']) {
    case CURRENT_SEARCH_DISPLAY_KEYS:
      return $adapter
        ->getSearchKeys();
    case CURRENT_SEARCH_DISPLAY_FILTERS:
      return $adapter
        ->getAllActiveItems();
    case CURRENT_SEARCH_DISPLAY_KEYS_FILTERS:
      return $adapter
        ->getSearchKeys() || $adapter
        ->getAllActiveItems();
    case CURRENT_SEARCH_DISPLAY_ALWAYS:
    default:
      return TRUE;
  }
}