views_handler_argument_null.inc

  1. 3.x handlers/views_handler_argument_null.inc
  2. 2.x handlers/views_handler_argument_null.inc

Definition of views_handler_argument_null.

File

handlers/views_handler_argument_null.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_argument_null.
  5. */
  6. /**
  7. * Argument handler that ignores the argument.
  8. *
  9. * @ingroup views_argument_handlers
  10. */
  11. class views_handler_argument_null extends views_handler_argument {
  12. function option_definition() {
  13. $options = parent::option_definition();
  14. $options['must_not_be'] = array('default' => FALSE, 'bool' => TRUE);
  15. return $options;
  16. }
  17. /**
  18. * Override options_form() so that only the relevant options
  19. * are displayed to the user.
  20. */
  21. function options_form(&$form, &$form_state) {
  22. parent::options_form($form, $form_state);
  23. $form['must_not_be'] = array(
  24. '#type' => 'checkbox',
  25. '#title' => t('Fail basic validation if any argument is given'),
  26. '#default_value' => !empty($this->options['must_not_be']),
  27. '#description' => t('By checking this field, you can use this to make sure views with more arguments than necessary fail validation.'),
  28. '#fieldset' => 'more',
  29. );
  30. unset($form['exception']);
  31. }
  32. /**
  33. * Override default_actions() to remove actions that don't
  34. * make sense for a null argument.
  35. */
  36. function default_actions($which = NULL) {
  37. if ($which) {
  38. if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) {
  39. return parent::default_actions($which);
  40. }
  41. return;
  42. }
  43. $actions = parent::default_actions();
  44. unset($actions['summary asc']);
  45. unset($actions['summary desc']);
  46. return $actions;
  47. }
  48. function validate_argument_basic($arg) {
  49. if (!empty($this->options['must_not_be'])) {
  50. return !isset($arg);
  51. }
  52. return parent::validate_argument_basic($arg);
  53. }
  54. /**
  55. * Override the behavior of query() to prevent the query
  56. * from being changed in any way.
  57. */
  58. function query($group_by = FALSE) {}
  59. }