You are here

function apachesolr_search_page_list_pages in Apache Solr Search 6.3

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

Listing of all the search pages

Return value

array $build

1 call to apachesolr_search_page_list_pages()
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 85
Administrative settings for searching.

Code

function apachesolr_search_page_list_pages() {
  $build = array();
  $rows = array();
  $rows['core_search'] = array();

  // Build the sortable table header.
  $header = array(
    'label' => array(
      'data' => t('Name'),
      'field' => 's.label',
    ),
    'path' => array(
      'data' => t('Path'),
      'field' => 's.search_path',
    ),
    'environment' => array(
      'data' => t('Search environment'),
    ),
    'operations' => array(
      'data' => t('Operations'),
    ),
  );
  $search_pages = apachesolr_search_load_all_search_pages();
  $default_search_page = apachesolr_search_default_search_page();
  foreach ($search_pages as $search_page) {
    $row = array();

    // Add the label
    $label = check_plain($search_page['label']);

    // Is this row our default environment?
    if ($search_page['page_id'] == $default_search_page) {
      $label = t('!search_page <em>(Default)</em>', array(
        '!search_page' => $label,
      ));
    }

    // Add the search page label
    $row[] = array(
      'data' => $label,
    );

    // Add the link
    $row[] = array(
      'data' => l($search_page['search_path'], $search_page['search_path']),
    );

    // Add the search environment
    $environment = apachesolr_environment_load($search_page['env_id']);
    $row[] = array(
      'data' => $environment ? check_plain($environment['name']) : check_plain(t('<Disabled>')),
    );

    // Operations
    $row[] = array(
      'data' => l(t('Edit'), 'admin/settings/apachesolr/search-pages/' . $search_page['page_id'] . '/edit'),
    );
    $row[] = array(
      'data' => l(t('Clone'), 'admin/settings/apachesolr/search-pages/' . $search_page['page_id'] . '/clone'),
    );

    // Allow to revert a search page or to delete it
    if (!isset($search_page['settings']['apachesolr_search_not_removable']) && !isset($search_page['in_code_only'])) {
      if (isset($search_page['type']) && $search_page['type'] == 'Overridden') {
        $row[] = array(
          'data' => l(t('Revert'), 'admin/settings/apachesolr/search-pages/' . $search_page['page_id'] . '/delete'),
        );
      }
      else {
        $row[] = array(
          'data' => l(t('Delete'), 'admin/settings/apachesolr/search-pages/' . $search_page['page_id'] . '/delete'),
        );
      }
    }
    else {
      $row[] = array(
        'data' => '',
      );
    }
    $rows[$search_page['page_id']] = $row;
  }

  // Automatically enlarge our header with the operations size
  $header['operations']['colspan'] = count(reset($rows)) - 3;
  $build['prefix'] = '<h3>Pages</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;
}