You are here

function apachesolr_search_load_all_search_pages in Apache Solr Search 8

Same name and namespace in other branches
  1. 6.3 apachesolr_search.module \apachesolr_search_load_all_search_pages()
  2. 7 apachesolr_search.module \apachesolr_search_load_all_search_pages()

Return all the saved search pages

Return value

array $search_pages Array of all search pages

4 calls to apachesolr_search_load_all_search_pages()
apachesolr_search_menu_alter in ./apachesolr_search.module
apachesolr_search_page_clone in ./apachesolr_search.module
Function that clones a search page
apachesolr_search_page_list_pages in ./apachesolr_search.admin.inc
Listing of all the search pages
apachesolr_search_page_load in ./apachesolr_search.module
Load a search page
3 string references to 'apachesolr_search_load_all_search_pages'
DrupalSolrOfflineSearchPagesWebTestCase::testCloneSearchPage in tests/apachesolr_base.test
Asserts that we can clone a search page
DrupalSolrOfflineSearchPagesWebTestCase::testEditSearchPage in tests/apachesolr_base.test
Asserts that we can edit a search environment
DrupalSolrOfflineSearchPagesWebTestCase::testNewAndRemoveSearchPage in tests/apachesolr_base.test
Asserts that we can edit a search environment

File

./apachesolr_search.module, line 575
Provides a content search implementation for node content for use with the Apache Solr search application.

Code

function apachesolr_search_load_all_search_pages() {
  $search_pages =& drupal_static(__FUNCTION__, array());
  if (!empty($search_pages)) {
    return $search_pages;
  }

  // If ctools module is enabled, add search pages from code, e.g. from a
  // feature module.
  if (module_exists('ctools')) {
    ctools_include('export');
    $defaults = ctools_export_load_object('apachesolr_search_page', 'all');
    foreach ($defaults as $page_id => $default) {
      $search_pages[$page_id] = (array) $default;
    }
  }

  // Get all search_pages and their id
  $search_pages_db = db_query('SELECT * FROM {apachesolr_search_page}')
    ->fetchAllAssoc('page_id', PDO::FETCH_ASSOC);
  $search_pages = $search_pages + $search_pages_db;

  // Ensure that the core search page uses the default environment. In some
  // instances, for example when unit testing, this search page isn't defined.
  if (isset($search_pages['core_search'])) {
    $search_pages['core_search']['env_id'] = apachesolr_default_environment();
  }

  // convert settings to an array
  foreach ($search_pages as $id => $search_page) {
    if (is_string($search_pages[$id]['settings'])) {
      $search_pages[$id]['settings'] = unserialize($search_pages[$id]['settings']);

      // Prevent false outcomes for the following search page
      $settings = 0;
    }
  }
  return $search_pages;
}