You are here

apachesolr_info.inc in Apache Solr Panels 6.3

File

plugins/content_types/apachesolr_info.inc
View source
<?php

if (module_exists('apachesolr_search')) {
  $plugin = array(
    'single' => TRUE,
    'title' => t('Apache Solr search information'),
    'description' => t('Information about an Apache Solr search.'),
    'icon' => 'icon_search.png',
    'category' => t('Apache Solr Search'),
    'hook theme' => 'apachesolr_panels_apachesolr_info_theme',
  );
}

/**
 * Delegated implementation of hook_theme().
 */
function apachesolr_panels_apachesolr_info_theme(&$theme) {
  $theme['apachesolr_panels_info'] = array(
    'arguments' => array(
      'response' => NULL,
      'search' => NULL,
    ),
  );
}

/**
 * Execute the search and render results.
 */
function apachesolr_panels_apachesolr_info_content_type_render($subtype, $conf, $panel_args, $context) {
  $response = apachesolr_static_response_cache();
  $search = apachesolr_panels_static_search_cache();
  if (empty($response) || empty($search)) {
    return;
  }
  $block = new stdClass();
  $block->module = 'apachesolr_panels';
  $block->delta = 'info';
  $block->title = '';
  $block->content = theme('apachesolr_panels_info', $response, $search);
  return $block;
}

/**
 * Empty form so we can have the default override title.
 */
function apachesolr_panels_apachesolr_info_content_type_edit_form(&$form, &$form_state) {

  // Does nothing!
}

/**
 * Theme search result information.
 */
function theme_apachesolr_panels_info($response, $search) {
  if ($total = $response->response->numFound) {
    $start = $response->response->start + 1;
    $end = $response->response->start + count($response->response->docs);
    if (!empty($search['keys'])) {
      $info = t('Results %start - %end of %total for %keys', array(
        '%start' => $start,
        '%end' => $end,
        '%total' => $total,
        '%keys' => $search['keys'],
      ));
    }
    else {
      $info = t('Results %start - %end of %total', array(
        '%start' => $start,
        '%end' => $end,
        '%total' => $total,
      ));
    }
    return $info;
  }
}

Functions

Namesort descending Description
apachesolr_panels_apachesolr_info_content_type_edit_form Empty form so we can have the default override title.
apachesolr_panels_apachesolr_info_content_type_render Execute the search and render results.
apachesolr_panels_apachesolr_info_theme Delegated implementation of hook_theme().
theme_apachesolr_panels_info Theme search result information.