You are here

function apachesolr_multilingual_apachesolr_field_name_map_alter in Apache Solr Multilingual 7

Same name and namespace in other branches
  1. 6.3 apachesolr_multilingual.module \apachesolr_multilingual_apachesolr_field_name_map_alter()
  2. 6 apachesolr_multilingual.module \apachesolr_multilingual_apachesolr_field_name_map_alter()
  3. 6.2 apachesolr_multilingual.module \apachesolr_multilingual_apachesolr_field_name_map_alter()

Implements hook_apachesolr_field_name_map_alter().

File

./apachesolr_multilingual.module, line 433
Multilingual search using Apache Solr.

Code

function apachesolr_multilingual_apachesolr_field_name_map_alter(&$map) {
  foreach (apachesolr_multilingual_language_list() as $language => $language_name) {

    // 'content' => t('The full, rendered content (e.g. the rendered node body)')
    // 'i18n_content_de' => 'German: ' . t('The full, rendered content (e.g. the rendered node body)')
    $map['i18n_content_' . $language] = $language_name . ': ' . $map['content'];

    // For language specific dynamic field i18n_ts_de_* we could not attach the
    // langcode at the end of the field name.
    $map['i18n_ts_' . $language . '_comments'] = $language_name . ': ' . $map['ts_comments'];
    $map['i18n_tos_' . $language . '_content_extra'] = $language_name . ': ' . $map['tos_content_extra'];
    $map['i18n_tos_' . $language . '_name_formatted'] = $language_name . ': ' . $map['tos_name_formatted'];
    $map['i18n_label_' . $language] = $language_name . ': ' . $map['label'];
    $map['i18n_teaser_' . $language] = $language_name . ': ' . $map['teaser'];
    $map['i18n_tos_' . $language . '_name'] = $language_name . ': ' . $map['tos_name'];
    $map['i18n_path_alias_' . $language] = $language_name . ': ' . $map['path_alias'];
    $map['i18n_tags_' . $language . '_h1'] = $language_name . ': ' . $map['tags_h1'];
    $map['i18n_tags_' . $language . '_h2_h3'] = $language_name . ': ' . $map['tags_h2_h3'];
    $map['i18n_tags_' . $language . '_h4_h5_h6'] = $language_name . ': ' . $map['tags_h4_h5_h6'];
    $map['i18n_tags_' . $language . '_inline'] = $language_name . ': ' . $map['tags_inline'];
    $map['i18n_tags_' . $language . '_a'] = $language_name . ': ' . $map['tags_a'];
    $map['i18n_tus_' . $language . '_content'] = $language_name . ': ' . $map['content'] . ' ' . t('(Unstemmed)');
    $map['i18n_tus_' . $language . '_comments'] = $language_name . ': ' . $map['ts_comments'] . ' ' . t('(Unstemmed)');
    $map['i18n_tus_' . $language . '_label'] = $language_name . ': ' . $map['label'] . ' ' . t('(Unstemmed)');
    $map['i18n_tus_' . $language . '_teaser'] = $language_name . ': ' . $map['teaser'] . ' ' . t('(Unstemmed)');
    $map['i18n_tus_' . $language . '_path_alias'] = $language_name . ': ' . $map['path_alias'] . ' ' . t('(Unstemmed)');
    if (module_exists('taxonomy')) {
      $map['i18n_taxonomy_names_' . $language] = $language_name . ': ' . $map['taxonomy_names'];
      foreach (taxonomy_get_vocabularies() as $vocab) {
        $map['i18n_tm_' . $language . '_vid_' . $vocab->vid . '_names'] = $language_name . ': ' . $map['tm_vid_' . $vocab->vid . '_names'];
      }
    }
    $prefixes = array_keys(apachesolr_multilingual_get_dynamic_text_field_prefixes_and_types());
    foreach (apachesolr_entity_fields('node') as $field_nm => $nodefields) {
      foreach ($nodefields as $field_info) {
        $name = apachesolr_index_key($field_info);
        list($prefix, ) = explode('_', $name);
        if (in_array($prefix, $prefixes)) {

          // FIXME are 32 chars the max allowed chars?
          $map['i18n_' . $prefix . '_' . $language . '_' . $field_nm] = $language_name . ': ' . $map[$name];
        }
      }
    }
  }
}