function apachesolr_multilingual_datestamp_default_indexing_callback_implementation in Apache Solr Multilingual 7
This function is used during indexing to normalize the DATESTAMP fields into the appropriate format for Apache Solr.
Parameters
object $entity:
string $field_name:
string $index_key:
array $field_info:
Return value
array $fields
1 call to apachesolr_multilingual_datestamp_default_indexing_callback_implementation()
- apachesolr_multilingual_datestamp_default_indexing_callback in ./
apachesolr_multilingual.module - This function is used during indexing to normalize the DATESTAMP fields into the appropriate format for Apache Solr.
File
- ./
apachesolr_multilingual.index.inc, line 136
Code
function apachesolr_multilingual_datestamp_default_indexing_callback_implementation($entity, $field_name, $index_key, array $field_info) {
$fields = array();
if (!empty($entity->{$field_name})) {
// $fields may end up having two values; one for the start date
// and one for the end date.
$field = $entity->{$field_name};
$values = array();
if (array_key_exists($entity->language, $field) && is_array($field[$entity->language])) {
$values = $field[$entity->language];
}
else {
list($lang, $values) = each($field);
if (!is_array($values)) {
$values = array();
}
}
foreach ($values as $value) {
if (isset($value['value']) && $value['value'] != 0) {
$index_value = apachesolr_date_iso($value['value']);
$fields[] = array(
'key' => $index_key,
'value' => $index_value,
);
}
if (isset($value['value2']) && $value['value'] != 0) {
$index_value = apachesolr_date_iso($value['value2']);
$fields[] = array(
// The value2 element is the end date. Therefore it gets indexed
// into its own Solr field.
'key' => $index_key . '_end',
'value' => $index_value,
);
}
}
}
return $fields;
}