views_plugin_argument_validate.inc

  1. 3.x plugins/views_plugin_argument_validate.inc
  2. 2.x plugins/views_plugin_argument_validate.inc

Contains the base argument validator plugin.

File

plugins/views_plugin_argument_validate.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains the base argument validator plugin.
  5. */
  6. /**
  7. * @defgroup views_argument_validate_plugins Views argument validate plugins
  8. * @{
  9. * Allow specialized methods of validating arguments.
  10. *
  11. * @see hook_views_plugins()
  12. */
  13. /**
  14. * Base argument validator plugin to provide basic functionality.
  15. */
  16. class views_plugin_argument_validate extends views_plugin {
  17. /**
  18. * Initialize this plugin with the view and the argument
  19. * it is linked to.
  20. */
  21. function init(&$view, &$argument, $options) {
  22. $this->view = &$view;
  23. $this->argument = &$argument;
  24. $this->convert_options($options);
  25. $this->unpack_options($this->options, $options);
  26. }
  27. /**
  28. * Retrieve the options when this is a new access
  29. * control plugin
  30. */
  31. function option_definition() { return array(); }
  32. /**
  33. * Provide the default form for setting options.
  34. */
  35. function options_form(&$form, &$form_state) { }
  36. /**
  37. * Provide the default form form for validating options
  38. */
  39. function options_validate(&$form, &$form_state) { }
  40. /**
  41. * Provide the default form form for submitting options
  42. */
  43. function options_submit(&$form, &$form_state, &$options = array()) { }
  44. /**
  45. * Convert options from the older style.
  46. *
  47. * In Views 3, the method of storing default argument options has changed
  48. * and each plugin now gets its own silo. This method can be used to
  49. * move arguments from the old style to the new style. See
  50. * views_plugin_argument_default_fixed for a good example of this method.
  51. */
  52. function convert_options(&$options) { }
  53. /**
  54. * Determine if the administrator has the privileges to use this plugin
  55. */
  56. function access() { return TRUE; }
  57. /**
  58. * If we don't have access to the form but are showing it anyway, ensure that
  59. * the form is safe and cannot be changed from user input.
  60. *
  61. * This is only called by child objects if specified in the options_form(),
  62. * so it will not always be used.
  63. */
  64. function check_access(&$form, $option_name) {
  65. if (!$this->access()) {
  66. $form[$option_name]['#disabled'] = TRUE;
  67. $form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
  68. $form[$option_name]['#description'] .= ' <strong>' . t('Note: you do not have permission to modify this. If you change the default filter type, this setting will be lost and you will NOT be able to get it back.') . '</strong>';
  69. }
  70. }
  71. function validate_argument($arg) { return TRUE; }
  72. /**
  73. * Process the summary arguments for displaying.
  74. *
  75. * Some plugins alter the argument so it uses something else interal.
  76. * For example the user validation set's the argument to the uid,
  77. * for a faster query. But there are use cases where you want to use
  78. * the old value again, for example the summary.
  79. */
  80. function process_summary_arguments(&$args) { }
  81. }
  82. /**
  83. * @}
  84. */