You are here

apachesolr_multilingual.install in Apache Solr Multilingual 6.3

Same filename and directory in other branches
  1. 7 apachesolr_multilingual.install

TODO

File

apachesolr_multilingual.install
View source
<?php

/**
 * @file
 *  TODO
 */

/**
 * Implements hook_enable().
 *
 * Set variable "apachesolr_service_class" to
 * "DrupalApacheSolrMultilingualService" to support multilingual spell checking.
 */
function apachesolr_multilingual_enable() {
  $class_info = array(
    'file' => 'DrupalApacheSolrMultilingualService',
    'module' => 'apachesolr_multilingual',
    'class' => 'DrupalApacheSolrMultilingualService',
  );
  variable_set('apachesolr_service_class', $class_info);
}

/**
 * Implements hook_disable().
 *
 * Set variable "apachesolr_service_class" back to default.
 */
function apachesolr_multilingual_disable() {

  // Deleting the variable will reset it to default.
  variable_del('apachesolr_service_class');
}

/**
 * Implements hook_requirements().
 */
function apachesolr_multilingual_requirements($phase) {
  $requirements = array();
  if ($phase != 'runtime') {
    return $requirements;
  }
  module_load_include('admin.inc', 'apachesolr_search');
  $t = get_t();
  $environments = apachesolr_multilingual_load_all_environments();
  $types = array_unique(array_values(apachesolr_multilingual_get_dynamic_text_field_prefixes_and_types()));
  $ok = TRUE;
  foreach ($environments as $environment) {
    $fields = apachesolr_search_get_fields($environment);
    if (!is_object($fields) || empty($fields)) {
      $requirements['apachesolr_multilingual_bias_' . $environment['env_id']] = array(
        'title' => $t('Apache Solr Multilingual'),
        'value' => $t('Field bias settings of environment ID %id could not be verified.', array(
          '%id' => $environment['env_id'],
        )),
        'description' => $t('Could not establish a connection to this solr index. The field bias settings could not be verified.'),
        'severity' => REQUIREMENT_ERROR,
      );
      $ok = FALSE;
    }
    else {
      $field_bias = apachesolr_environment_variable_get($environment['env_id'], 'field_bias', array());
      foreach ($fields as $field_name => $field) {

        // Only indexed fields are searchable.
        if (in_array($field->type, $types) && $field->schema[0] == 'I') {
          if (!array_key_exists($field_name, $field_bias)) {
            $requirements['apachesolr_multilingual_bias_' . $environment['env_id']] = array(
              'title' => $t('Apache Solr Multilingual'),
              'value' => $t('Missing field bias settings of environment ID %id.', array(
                '%id' => $environment['env_id'],
              )),
              'description' => $t('This solr index contains new searchable fields. These fields are ignored until you configured and saved the !field_biases.', array(
                '!field_biases' => l($t('Field biases'), 'admin/settings/apachesolr/settings/' . $environment['env_id'] . '/bias'),
              )),
              'severity' => REQUIREMENT_WARNING,
            );
            $ok = FALSE;
            break;
          }
        }
      }
    }
  }
  if ($ok) {
    $requirements['apachesolr_multilingual_bias'] = array(
      'title' => $t('Apache Solr Multilingual.'),
      'value' => $t('Field biases'),
      'description' => $t('All settings for all indexes are complete.'),
      'severity' => REQUIREMENT_OK,
    );
  }
  return $requirements;
}

/**
 * Set variable "apachesolr_service_class" to
 * "DrupalApacheSolrMultilingualService" to support multilingual spell checking.
 */
function apachesolr_multilingual_update_6300(&$sandbox) {
  apachesolr_multilingual_enable();
}

Functions

Namesort descending Description
apachesolr_multilingual_disable Implements hook_disable().
apachesolr_multilingual_enable Implements hook_enable().
apachesolr_multilingual_requirements Implements hook_requirements().
apachesolr_multilingual_update_6300 Set variable "apachesolr_service_class" to "DrupalApacheSolrMultilingualService" to support multilingual spell checking.