You are here

function panopoly_search_facet_content_type_edit_form in Panopoly Search 7

1 string reference to 'panopoly_search_facet_content_type_edit_form'
facet.inc in plugins/content_types/facet/facet.inc

File

plugins/content_types/facet/facet.inc, line 19

Code

function panopoly_search_facet_content_type_edit_form($form, &$form_state) {

  // Determine what deltas Facet API Supports
  $map = facetapi_get_delta_map();
  $deltas = array();
  $realm_name = 'block';
  foreach (facetapi_get_searcher_info() as $searcher => $info) {
    foreach (facetapi_get_delta_map_queue($searcher, $realm_name) as $facet_name) {
      if ($facet = facetapi_facet_load($facet_name, $searcher)) {
        if ($string = facetapi_build_delta($searcher, $realm_name, $facet_name)) {
          if ($delta = array_search($string, $map)) {
            switch ($searcher) {
              case 'search_api@database_node_index':
                $deltas[$delta] = 'DB: ' . $facet_name;
                break;
              case 'search_api@node_index':
                $deltas[$delta] = 'Solr: ' . $facet_name;
                break;
              default:
                $deltas[$delta] = 'Unknown: ' . $facet_name;
                break;
            }
          }
        }
      }
    }
  }

  // Build the configuration form
  $conf = $form_state['conf'];
  $form['delta'] = array(
    '#type' => 'select',
    '#title' => t('Facet Type'),
    '#default_value' => !empty($conf['delta']) ? $conf['delta'] : '',
    '#options' => $deltas,
  );
  return $form;
}