You are here

function facetapi_facetapi_facet_info in Facet API 6

Same name and namespace in other branches
  1. 6.3 facetapi.module \facetapi_facetapi_facet_info()
  2. 7.2 facetapi.facetapi.inc \facetapi_facetapi_facet_info()
  3. 7 facetapi.facetapi.inc \facetapi_facetapi_facet_info()

Implementation of hook_facetapi_facet_info().

File

./facetapi.module, line 1468
An abstracted facet API that can be used by various search backens.

Code

function facetapi_facetapi_facet_info($searcher, $type) {
  $facets = array();
  if ('node' == $type) {
    $facets['type'] = array(
      'title' => t('Content type'),
      'description' => t('Filter by content type.'),
      'map callback' => 'facetapi_callback_type_map',
      'values callback' => 'facetapi_callback_type_values',
      'widget requirements' => array(
        'has default values',
      ),
      'default widgets' => array(
        'facetapi_checkboxes',
      ),
      'file' => 'facetapi.callbacks.inc',
    );
    $facets['author'] = array(
      'title' => t('Author'),
      'description' => t('Filter by author.'),
      'field' => 'uid',
      'data group' => 'user',
      'widget requirements' => array(
        'has default values',
      ),
      'map callback' => 'facetapi_callback_uid_map',
      'values callback' => 'facetapi_callback_user_values',
      'file' => 'facetapi.callbacks.inc',
    );
    $facets['language'] = array(
      'title' => t('Language'),
      'description' => t('Filter by language.'),
      'widget requirements' => array(
        'has default values',
      ),
      'default widgets' => array(
        'facetapi_checkboxes',
      ),
      'map callback' => 'facetapi_callback_language_map',
      'values callback' => 'facetapi_callback_language_values',
      'file' => 'facetapi.callbacks.inc',
    );
    $facets['created'] = array(
      'title' => t('Post date'),
      'description' => t('Filter by the date the node was posted.'),
      'widget requirements' => array(
        'date',
      ),
      'query type' => 'date',
      'map callback' => 'facetapi_callback_date_map',
      'min callback' => 'facetapi_callback_min_date',
      'max callback' => 'facetapi_callback_max_date',
      'file' => 'facetapi.callbacks.inc',
      'default sorts' => array(
        array(
          'active',
          SORT_DESC,
        ),
        array(
          'indexed',
          SORT_ASC,
        ),
      ),
    );
    $facets['changed'] = array(
      'title' => t('Updated date'),
      'description' => t('Filter by the date the node was last modified.'),
      'widget requirements' => array(
        'date',
      ),
      'query type' => 'date',
      'map callback' => 'facetapi_callback_date_map',
      'min callback' => 'facetapi_callback_min_date',
      'max callback' => 'facetapi_callback_max_date',
      'file' => 'facetapi.callbacks.inc',
      'default sorts' => array(
        array(
          'active',
          SORT_DESC,
        ),
        array(
          'indexed',
          SORT_ASC,
        ),
      ),
    );

    // Adds taxonomy facets, breaks up into separate vocabularies.
    if (module_exists('taxonomy')) {
      foreach (taxonomy_get_vocabularies() as $voc) {
        $facet_name = 'vocabulary_' . $voc->vid;
        $facets[$facet_name] = array(
          'title' => $voc->name,
          'field' => 'category',
          'data group' => 'taxonomy',
          'widget requirements' => array(
            'has default values',
          ),
          'default widgets' => array(
            'facetapi_multiselect',
          ),
          'map callback' => 'facetapi_callback_taxonomy_map',
          'values callback' => 'facetapi_callback_taxonomy_values',
          'file' => 'facetapi.callbacks.inc',
          'description' => t('Filter by terms in the %vocabulary vocabulary.', array(
            '%vocabulary' => $voc->name,
          )),
        );

        // Adds hierarchy callback to get parent information.
        if (facetapi_vocabulary_hierarchical($voc->vid)) {
          $facets[$facet_name]['hierarchy callback'] = 'facetapi_callback_taxonomy_hierarchy';
        }
      }
    }
  }
  return $facets;
}