You are here

public function AvailabilityCalendarAlterFieldFilter::configurationForm in Availability Calendars 7.5

Implements SearchApiAlterCallbackInterface::configurationForm().

Overrides SearchApiAbstractAlterCallback::configurationForm

File

./availability_calendar_alter_field_filter.inc, line 29

Class

AvailabilityCalendarAlterFieldFilter
Search API data alteration callback that filters out items based on the fields that refer to them.

Code

public function configurationForm() {
  if ($this->index->item_type === 'availability_calendar_calendar') {
    $options = drupal_map_assoc($this
      ->get_fields_by_type('availability_calendar'));
    $form = array(
      'default' => array(
        '#type' => 'radios',
        '#title' => t('Which items should be indexed?'),
        '#default_value' => isset($this->options['default']) ? $this->options['default'] : 'exclude',
        '#options' => array(
          'exclude' => t('All but those from one of the selected fields'),
          'include' => t('Only those from the selected fields'),
        ),
      ),
      'fields' => array(
        '#type' => 'select',
        '#title' => t('Fields'),
        '#default_value' => isset($this->options['fields']) ? $this->options['fields'] : array(),
        '#options' => $options,
        '#size' => min(3, count($options)),
        '#multiple' => TRUE,
      ),
    );
  }
  else {
    $form = array(
      'forbidden' => array(
        '#markup' => '<p>' . t("This index doesn't index availability calendars and therefore cannot be filtered on referring availability calendar fields here.") . '</p>',
      ),
    );
  }
  return $form;
}