function apachesolr_content_extra_fields in Apache Solr Search 6.3
Implements hook_content_extra_fields().
File
- ./
apachesolr.module, line 1872 - Integration with the Apache Solr search application.
Code
function apachesolr_content_extra_fields($content_type) {
// Load all environments
$environments = apachesolr_load_all_environments();
$default_entity_info = apachesolr_get_index_callbacks();
// First set defaults so that we don't need to worry about NULL keys.
if (!isset($extra['apachesolr'])) {
$extra['apachesolr'] = array();
}
// in Drupal 6 we only support node types
$entity_type = 'node';
if (isset($default_entity_info[$entity_type])) {
$extra['apachesolr'] += $default_entity_info[$entity_type];
}
$default = array(
'indexable' => FALSE,
'status callback' => '',
'document callback' => '',
'reindex callback' => '',
'bundles changed callback' => '',
'label' => t('Apachesolr settings'),
'description' => 'Apachesolr Content type info',
'weight' => 100,
);
$extra['apachesolr'] += $default;
$extra['apachesolr']['index'] = FALSE;
// Loop over each environment and check if any of them have other entity
// bundles of any entity type enabled and set the index value to TRUE
foreach ($environments as $env) {
// Skip if the environment is set to read only
if (empty($env['env_id']['conf']['apachesolr_read_only'])) {
// Get the supported bundles
$supported = apachesolr_get_index_bundles($env['env_id'], $entity_type);
// For each bundle in drupal, compare to the supported apachesolr
// bundles and enable where possible
if (in_array($content_type, $supported)) {
$extra['apachesolr']['index'] = TRUE;
break;
}
}
}
return $extra;
}