function apachesolr_multilingual_copy_common_to_i18n_fields in Apache Solr Multilingual 6.3
Same name and namespace in other branches
- 7 apachesolr_multilingual.module \apachesolr_multilingual_copy_common_to_i18n_fields()
1 call to apachesolr_multilingual_copy_common_to_i18n_fields()
File
- ./
apachesolr_multilingual.module, line 219 - Multilingual search using Apache Solr.
Code
function apachesolr_multilingual_copy_common_to_i18n_fields($src_document, $dst_document) {
$fields = $src_document
->getFieldNames();
$additionally_store_unstemmed = array(
'ts' => 'tus',
'tm' => 'tom',
);
// Use language-specific stemming and so on by copying all fields of type text
// to a language-specific text field.
foreach (array(
'label',
'teaser',
'content',
'path_alias',
) as $field_name) {
if (in_array($field_name, $fields)) {
$dst_document->{'i18n_' . $field_name . '_' . $src_document->ss_language} = $dst_document->{'i18n_tus_' . $src_document->ss_language . '_' . $field_name} = $src_document->{$field_name};
}
}
$dst_document->{'i18n_path_' . $src_document->ss_language} = $src_document->{'path'};
foreach ($fields as $field_name) {
$prefixes = array_keys(apachesolr_multilingual_get_dynamic_text_field_prefixes_and_types());
$prefixes[] = 'tags_';
foreach ($prefixes as $prefix) {
if (strpos($field_name, $prefix) === 0 && !empty($src_document->{$field_name})) {
// search for existing language identifier at second position
$tmp = explode('_', $field_name);
if ($src_document->ss_language != $tmp[1]) {
// Dynamic fields have to be prefixed with 'i18n_' to distinguish between
// language-specific dynamic fields and standard dynamic fields.
// The language suffix is not enough, because someone could define a
// drupal field name like 'de_foo', which matches ts_de_* but not i18n_ts_*
$new_field_name = 'i18n_' . $tmp[0] . '_' . $src_document->ss_language . drupal_substr($field_name, drupal_strlen($tmp[0]));
$dst_document->{$new_field_name} = $src_document->{$field_name};
if (array_key_exists($tmp[0], $additionally_store_unstemmed)) {
$dst_document->{str_replace(array_keys($additionally_store_unstemmed), array_values($additionally_store_unstemmed), $new_field_name)} = $src_document->{$field_name};
}
}
}
}
}
}