tripal_views_handler_filter_sequence.inc

  1. 2.x tripal_views/views/handlers/tripal_views_handler_filter_sequence.inc
  2. 3.x tripal_chado_views/views/handlers/tripal_views_handler_filter_sequence.inc
  3. 1.x tripal_views/views/handlers/tripal_views_handler_filter_sequence.inc

Contains tripal_views_handler_filter_sequence Filter handler

File

tripal_views/views/handlers/tripal_views_handler_filter_sequence.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains tripal_views_handler_filter_sequence Filter handler
  5. */
  6. /**
  7. * This Handler provides a file upload field by extending the
  8. * views_handler_filter object.
  9. *
  10. * @ingroup tripal_views
  11. */
  12. class tripal_views_handler_filter_sequence extends views_handler_filter {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. function value_form(&$form, &$form_state) {
  17. parent::value_form($form, $form_state);
  18. $this->value_form = array(
  19. '#type' => 'sequence_combo',
  20. '#title' => t('%label', array('%label' => $this->options['expose']['label'])),
  21. '#default_value' => $this->value,
  22. '#multiple' => FALSE,
  23. );
  24. $form['value'] = &$this->value_form;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. * Ensures the upload field gets rendered when the filter is exposed. It also
  29. * changes the form type from a GET to a POST so that file uploads will work.
  30. */
  31. function exposed_form(&$form, &$form_state) {
  32. // don't do anything if the form isn't exposed.
  33. if (empty($this->options['exposed'])) {
  34. return;
  35. }
  36. // rebuild the form elements
  37. $value = $this->options['expose']['identifier'];
  38. $this->value_form($form, $form_state);
  39. $form[$value] = $form['value'];
  40. unset($form[$value]['#title']);
  41. $this->exposed_translate($form[$value], 'value');
  42. if ($value != 'value') {
  43. unset($form['value']);
  44. }
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. function query() {
  50. $this->ensure_my_table();
  51. $upstream = $this->value[0]['upstream'];
  52. $downstream = $this->value[0]['downstream'];
  53. // we need the values provided by the user so that the field
  54. // handler can generate the results properly. Saving these as session
  55. // variables may not be the best way but it works.
  56. if ($upstream) {
  57. $_SESSION['upstream'] = $upstream;
  58. }
  59. if ($downstream) {
  60. $_SESSION['downstream'] = $downstream;
  61. }
  62. }
  63. }