You are here

function apachesolr_attachments_entity_bundle_settings in Apache Solr Attachments 7

Form callback for content type settings.

1 string reference to 'apachesolr_attachments_entity_bundle_settings'
apachesolr_attachments_menu in ./apachesolr_attachments.module
Implements hook_menu().

File

./apachesolr_attachments.admin.inc, line 110
Provides a file attachment search implementation for use with the Apache Solr module

Code

function apachesolr_attachments_entity_bundle_settings() {
  $env_id = apachesolr_default_environment();
  foreach (entity_get_info() as $entity_type => $entity_info) {
    if (!empty($entity_info['apachesolr']['indexable'])) {
      $indexed_bundles = apachesolr_get_index_bundles($env_id, $entity_type);
      foreach ($indexed_bundles as $bundle) {
        if ($bundle != 'file') {
          $form['apachesolr_attachments_entity_bundle_indexing_' . $bundle] = array(
            '#type' => 'select',
            /* NOTE: If http://drupal.org/node/969180 ever gets committed we could use that function instead
               and remove apachesolr_attachments_entity_bundle_label from the bottom of this file.
               */
            '#title' => apachesolr_attachments_entity_bundle_label($entity_type, $bundle),
            '#default_value' => variable_get('apachesolr_attachments_entity_bundle_indexing_' . $bundle, 'seperate'),
            '#options' => array(
              'seperate' => t('Attachments as separate entities'),
              'parent' => t('Attachments as part of parent entity'),
              'none' => t("Don't index attachments"),
            ),
          );
        }
      }
    }
  }
  if (empty($form)) {

    // Display a message if there are no indexable bundles.
    $form['no_bundles']['#markup'] = t('There are no bundles indexable by Apache Solr. You can select entities and bundles that should be indexed via <a href="!url">the Apache Solr search settings</a> page.', array(
      '!url' => url('admin/config/search/apachesolr'),
    ));
    return $form;
  }
  else {
    return system_settings_form($form);
  }
}