handler_argument_fulltext.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Views argument handler class for handling fulltext fields.
  4. */
  5. class SearchApiMultiHandlerArgumentFulltext extends SearchApiViewsHandlerArgumentFulltext {
  6. /**
  7. * Extend the options form a bit.
  8. */
  9. public function options_form(array &$form, array &$form_state) {
  10. parent::options_form($form, $form_state);
  11. $fields = array();
  12. $server_id = substr($this->table, 18);
  13. $indexes = search_api_index_load_multiple(FALSE, array('enabled' => TRUE, 'server' => $server_id));
  14. foreach ($indexes as $index) {
  15. if (!empty($index->options['fields'])) {
  16. $prefix = $index->machine_name . ':';
  17. $prefix_name = $index->name . ' » ';
  18. $f = $index->options['fields'];
  19. foreach ($index->getFulltextFields() as $name) {
  20. $fields[$prefix . $name] = $prefix_name . $f[$name]['name'];
  21. }
  22. }
  23. }
  24. if (!empty($fields)) {
  25. $form['fields'] = array(
  26. '#type' => 'select',
  27. '#title' => t('Searched fields'),
  28. '#description' => t('Select the fields that will be searched. If no fields are selected, all available fulltext fields will be searched.'),
  29. '#options' => $fields,
  30. '#size' => min(4, count($fields)),
  31. '#multiple' => TRUE,
  32. '#default_value' => $this->options['fields'],
  33. );
  34. }
  35. else {
  36. $form['fields'] = array(
  37. '#type' => 'value',
  38. '#value' => array(),
  39. );
  40. }
  41. }
  42. }