You are here

function _search_api_stats_block_show_keywords in Search API Stats 7

Responsible for querying the database and generating the list of phrases.

Parameters

string $s_name The machine name of the Search API server:

string $i_name The machine name of the Search API index:

Return value

markup Complete markup for the block content

1 call to _search_api_stats_block_show_keywords()
search_api_stats_block_block_view in contrib/search_api_stats_block/search_api_stats_block.module
Implements hook_block_view().

File

contrib/search_api_stats_block/search_api_stats_block.module, line 119
search_api_stats_block.module

Code

function _search_api_stats_block_show_keywords($s_name, $i_name) {
  $config = variable_get('search_api_stats_block_config', array());

  // Default variables passed to theming function.
  $phrases = array();
  $path = empty($config[$s_name][$i_name]['path']) ? '' : $config[$s_name][$i_name]['path'];
  $param_name = empty($config[$s_name][$i_name]['param_name']) ? 'keywords' : $config[$s_name][$i_name]['param_name'];
  $result = db_query_range("SELECT *, count(*) as num FROM {search_api_stats} WHERE s_name=:s_name AND i_name=:i_name AND keywords <> '' GROUP BY keywords ORDER BY num DESC", 0, 8, array(
    ':s_name' => $s_name,
    ':i_name' => $i_name,
  ));
  foreach ($result as $phrase) {
    $phrases[$phrase->keywords] = (array) $result;
  }
  return theme('search_api_stats_block', array(
    'phrases' => $phrases,
    'path' => $path,
    'param_name' => $param_name,
  ));
}