You are here

function apachesolr_search_update_7004 in Apache Solr Search 8

Same name and namespace in other branches
  1. 7 apachesolr_search.install \apachesolr_search_update_7004()

Add a default search page for core Add a taxonomy page if the taxonomy module was ever active

File

./apachesolr_search.install, line 295
Install and related hooks for apachesolr_search.

Code

function apachesolr_search_update_7004() {

  // Add Default search page (core search)
  $settings = array(
    'apachesolr_search_search_type' => 'custom',
    'apachesolr_search_per_page' => variable_get('apachesolr_rows', 10),
    'apachesolr_search_browse' => variable_get('apachesolr_search_browse', 'browse'),
    'apachesolr_search_spellcheck' => variable_get('apachesolr_search_spellcheck', TRUE),
    'apachesolr_search_not_removable' => TRUE,
    'apachesolr_search_search_box' => TRUE,
  );
  $settings = serialize($settings);
  $fields = array(
    'page_id' => 'core_search',
    'label' => 'Core Search',
    'description' => 'Site search',
    'search_path' => 'search/site',
    'env_id' => 'solr',
    'page_title' => 'Site',
    'settings' => $settings,
  );
  db_insert('apachesolr_search_page')
    ->fields($fields)
    ->execute();

  // Remove variables.
  variable_del('apachesolr_search_spellcheck');
  variable_del('apachesolr_search_browse');

  // Add this taxonomy search page to the database
  $settings = array(
    'apachesolr_search_search_type' => 'tid',
    'apachesolr_search_per_page' => 10,
    'apachesolr_search_browse' => 'results',
    'apachesolr_search_spellcheck' => FALSE,
    'apachesolr_search_search_box' => FALSE,
  );
  $settings = serialize($settings);
  $fields = array(
    'page_id' => 'taxonomy_search',
    'label' => 'Taxonomy Search',
    'description' => 'Search all items with given term',
    'search_path' => 'taxonomy/term/%',
    'env_id' => '',
    'page_title' => '%value',
    'settings' => $settings,
  );
  db_insert('apachesolr_search_page')
    ->fields($fields)
    ->execute();

  // Check if the taxonomy module was ever present
  $status = db_query("SELECT 1 FROM {system} WHERE name = 'apachesolr_taxonomy'")
    ->fetchField();
  if ($status) {
    $message = t('If you had the apachesolr_taxonomy module enabled please go to the !link and enable the Taxonomy Term page', array(
      '!link' => l('Apache Solr custom pages', 'admin/config/search/apachesolr/search-pages'),
    ));
    drupal_set_message($message, 'warning');
  }
}