You are here

function apachesolr_date_apachesolr_facets in Apache Solr Search 6.2

Implementation of hook_apachesolr_facets(). Only handles end date facets. Start date facet definitions are handled later.

See also

apachesolr_date_apachesolr_cck_fields_alter()

2 calls to apachesolr_date_apachesolr_facets()
apachesolr_date_apachesolr_prepare_query in contrib/apachesolr_date/apachesolr_date.module
Implementation of hook_apachesolr_prepare_query(). Adds sorts for enabled date facets to the sorting block.
apachesolr_date_block in contrib/apachesolr_date/apachesolr_date.module
Implementation of hook_block().

File

contrib/apachesolr_date/apachesolr_date.module, line 15
Integration with the Apache Solr search application. Provides faceting for CCK Date fields.

Code

function apachesolr_date_apachesolr_facets() {

  // Get CCK field facets.
  $fields = apachesolr_cck_fields();
  $facets = array();
  if ($fields) {
    foreach ($fields as $name => $field) {
      if (in_array($field['field_type'], array(
        'date',
        'datetime',
        'datestamp',
      ))) {
        $cck_info = content_fields($field['field_name']);

        // Only fields with a value2 have end dates to facet upon.
        if (isset($cck_info['columns']['value2'])) {

          // $delta can only be 32 chars, and the CCK field name may be this
          // long also, so we cannot add anything to it.
          $facets[$field['field_name'] . '_end'] = array_merge($field, array(
            'info' => t('CCK @field_type field: Filter by @field end', array(
              '@field_type' => $field['field_type'],
              '@field' => $field['label'],
            )),
            // 'facet_field' will later be block deltas.
            'facet_field' => apachesolr_index_key($field) . '_end',
            'content_types' => $field['content_types'],
            'display_callback' => 'apachesolr_date_display_callback',
          ));
        }
      }
    }
  }
  return $facets;
}