function apachesolr_cck_fields in Apache Solr Search 6.2
Same name and namespace in other branches
- 5.2 apachesolr.module \apachesolr_cck_fields()
- 5 apachesolr.module \apachesolr_cck_fields()
- 6 apachesolr.module \apachesolr_cck_fields()
Invokes hook_apachesolr_cck_field_mappings to find out how to handle CCK fields.
9 calls to apachesolr_cck_fields()
- apachesolr_date_apachesolr_facets in contrib/
apachesolr_date/ apachesolr_date.module - Implementation of hook_apachesolr_facets(). Only handles end date facets. Start date facet definitions are handled later.
- apachesolr_date_block in contrib/
apachesolr_date/ apachesolr_date.module - Implementation of hook_block().
- apachesolr_field_name_map in ./
apachesolr.module - Try to map a schema field name to a human-readable description.
- apachesolr_node_to_document in ./
apachesolr.index.inc - Given a node, return a document representing that node.
- apachesolr_search_apachesolr_facets in ./
apachesolr_search.module - Implementation of hook_apachesolr_facets().
File
- ./
apachesolr.module, line 1923 - Integration with the Apache Solr search application.
Code
function apachesolr_cck_fields() {
static $fields;
if (!isset($fields)) {
$fields = array();
// If CCK isn't enabled, do nothing.
if (module_exists('content')) {
module_load_include('inc', 'content', 'includes/content.crud');
$cck_field_instances = content_field_instance_read();
// A single default mapping for all text fields.
$mappings['text'] = array(
'optionwidgets_select' => array(
'display_callback' => 'apachesolr_cck_text_field_callback',
'indexing_callback' => 'apachesolr_cck_text_indexing_callback',
'index_type' => 'string',
'facets' => TRUE,
),
'optionwidgets_buttons' => array(
'display_callback' => 'apachesolr_cck_text_field_callback',
'indexing_callback' => 'apachesolr_cck_text_indexing_callback',
'index_type' => 'string',
'facets' => TRUE,
),
'optionwidgets_onoff' => array(
'display_callback' => 'apachesolr_cck_text_field_callback',
'indexing_callback' => 'apachesolr_cck_text_indexing_callback',
'index_type' => 'string',
'facets' => TRUE,
),
);
// A single default mapping for all integer fields using optionwidgets.
$mappings['number_integer'] = array(
'optionwidgets_select' => array(
'display_callback' => 'apachesolr_cck_text_field_callback',
'indexing_callback' => 'apachesolr_cck_integer_indexing_callback',
'index_type' => 'sint',
'facets' => TRUE,
),
'optionwidgets_buttons' => array(
'display_callback' => 'apachesolr_cck_text_field_callback',
'indexing_callback' => 'apachesolr_cck_integer_indexing_callback',
'index_type' => 'sint',
'facets' => TRUE,
),
'optionwidgets_onoff' => array(
'display_callback' => 'apachesolr_cck_text_field_callback',
'indexing_callback' => 'apachesolr_cck_integer_indexing_callback',
'index_type' => 'sint',
'facets' => TRUE,
),
);
$mappings['nodereference'] = array(
'nodereference_buttons' => array(
'display_callback' => 'apachesolr_cck_nodereference_field_callback',
'indexing_callback' => 'apachesolr_cck_nodereference_indexing_callback',
'index_type' => 'integer',
'facets' => TRUE,
),
'nodereference_select' => array(
'display_callback' => 'apachesolr_cck_nodereference_field_callback',
'indexing_callback' => 'apachesolr_cck_nodereference_indexing_callback',
'index_type' => 'integer',
'facets' => TRUE,
),
'nodereference_autocomplete' => array(
'display_callback' => 'apachesolr_cck_nodereference_field_callback',
'indexing_callback' => 'apachesolr_cck_nodereference_indexing_callback',
'index_type' => 'integer',
'facets' => TRUE,
),
);
$mappings['userreference'] = array(
'userreference_buttons' => array(
'display_callback' => 'apachesolr_cck_userreference_field_callback',
'indexing_callback' => 'apachesolr_cck_userreference_indexing_callback',
'index_type' => 'integer',
'facets' => TRUE,
),
'userreference_select' => array(
'display_callback' => 'apachesolr_cck_userreference_field_callback',
'indexing_callback' => 'apachesolr_cck_userreference_indexing_callback',
'index_type' => 'integer',
'facets' => TRUE,
),
'userreference_autocomplete' => array(
'display_callback' => 'apachesolr_cck_userreference_field_callback',
'indexing_callback' => 'apachesolr_cck_userreference_indexing_callback',
'index_type' => 'integer',
'facets' => TRUE,
),
);
// Allow other modules to add or alter mappings.
drupal_alter('apachesolr_cck_fields', $mappings);
foreach ($cck_field_instances as $instance) {
$field_type = $instance['type'];
$field_name = $instance['field_name'];
$widget_type = $instance['widget']['type'];
if (!isset($mappings[$field_type][$widget_type]) && !isset($mappings['per-field'][$field_name]) && isset($mappings[$field_type]['default'])) {
$widget_type = 'default';
}
// Only deal with fields that have index mappings and that have not been marked for exclusion.
if ((isset($mappings[$field_type][$widget_type]) || isset($mappings['per-field'][$field_name])) && empty($instance['display_settings'][NODE_BUILD_SEARCH_INDEX]['exclude'])) {
if (isset($mappings['per-field'][$field_name])) {
$instance['index_type'] = $mappings['per-field'][$field_name]['index_type'];
$instance['indexing_callback'] = $mappings['per-field'][$field_name]['indexing_callback'];
$instance['display_callback'] = $mappings['per-field'][$field_name]['display_callback'];
if (isset($mappings['per-field'][$field_name]['facet_block_callback'])) {
$instance['facet_block_callback'] = $mappings['per-field'][$field_name]['facet_block_callback'];
}
$instance['facets'] = $mappings['per-field'][$field_name]['facets'];
}
else {
$instance['index_type'] = $mappings[$field_type][$widget_type]['index_type'];
$instance['indexing_callback'] = $mappings[$field_type][$widget_type]['indexing_callback'];
$instance['display_callback'] = $mappings[$field_type][$widget_type]['display_callback'];
if (isset($mappings[$field_type][$widget_type]['facet_block_callback'])) {
$instance['facet_block_callback'] = $mappings[$field_type][$widget_type]['facet_block_callback'];
}
$instance['facets'] = $mappings[$field_type][$widget_type]['facets'];
}
$instance['multiple'] = (bool) $instance['multiple'];
$instance['name'] = 'cck_' . $field_name;
if (isset($fields[$field_name]) && is_array($fields[$field_name])) {
// Merge together settings when used for multiple node types.
$fields[$field_name] = array_merge($fields[$field_name], $instance);
}
else {
$fields[$field_name] = $instance;
}
$fields[$field_name]['content_types'][] = $instance['type_name'];
unset($fields[$field_name]['type_name']);
}
}
}
}
return $fields;
}