You are here

function apachesolr_search_page_list_blocks in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 apachesolr_search.admin.inc \apachesolr_search_page_list_blocks()
  2. 7 apachesolr_search.admin.inc \apachesolr_search_page_list_blocks()

Listing of all the search blocks

Return value

array $build

1 call to apachesolr_search_page_list_blocks()
apachesolr_search_page_list_all in ./apachesolr_search.admin.inc
Menu callback for the overview page showing custom search pages and blocks.

File

./apachesolr_search.admin.inc, line 156
Administrative settings for searching.

Code

function apachesolr_search_page_list_blocks() {
  $build = array();
  $rows = array();

  // Build the sortable table header.
  $header = array(
    'label' => array(
      'data' => t('Name'),
      'field' => 's.label',
    ),
    'environment' => array(
      'data' => t('Search environment'),
    ),
    'operations' => array(
      'data' => t('Operations'),
    ),
  );
  $search_blocks = variable_get('apachesolr_search_mlt_blocks', array());
  foreach ($search_blocks as $search_block_id => $search_block) {
    $row = array();

    // Add the label
    $label = check_plain($search_block['name']);
    $row[] = $label;

    // Add the search environment
    $environment = apachesolr_environment_load($search_block['mlt_env_id']);
    $row[] = $environment ? check_plain($environment['name']) : check_plain(t('<Disabled>'));

    // Operations
    if (module_exists('block')) {
      $row[] = array(
        'data' => l(t('Configure'), 'admin/build/block/configure/apachesolr_search/' . $search_block_id . '/configure', array(
          'query' => array(
            'destination' => $_GET['q'],
          ),
        )),
      );
    }
    $row[] = array(
      'data' => l(t('Delete'), 'admin/settings/apachesolr/search-pages/block/' . $search_block_id . '/delete'),
    );
    $rows[$search_block_id] = $row;
  }

  // Automatically enlarge our header with the operations size
  $header['operations']['colspan'] = count(reset($rows)) - 2;
  $build['prefix'] = '<h3>Blocks "More Like This"</h3>';
  $build['list'] = theme('table', array_values($header), array_values($rows));

  // Print in a similar way as the Drupal 7 version
  $build_print = NULL;
  foreach ($build as $print) {
    $build_print .= $print;
  }
  return $build_print;
}