views_plugin_argument_validate.inc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_plugin_argument_validate.
  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 it is linked to.
  19. */
  20. public function init(&$view, &$argument, $options) {
  21. $this->view = &$view;
  22. $this->argument = &$argument;
  23. $this->convert_options($options);
  24. $this->unpack_options($this->options, $options);
  25. }
  26. /**
  27. * Retrieve the options when this is a new access control plugin.
  28. */
  29. public function option_definition() {
  30. return array();
  31. }
  32. /**
  33. * Provide the default form for setting options.
  34. */
  35. public function options_form(&$form, &$form_state) {
  36. }
  37. /**
  38. * Provide the default form form for validating options.
  39. */
  40. public function options_validate(&$form, &$form_state) {
  41. }
  42. /**
  43. * Provide the default form form for submitting options
  44. */
  45. public function options_submit(&$form, &$form_state, &$options = array()) {
  46. }
  47. /**
  48. * Convert options from the older style.
  49. *
  50. * In Views 3, the method of storing default argument options has changed
  51. * and each plugin now gets its own silo. This method can be used to
  52. * move arguments from the old style to the new style. See
  53. * views_plugin_argument_default_fixed for a good example of this method.
  54. */
  55. public function convert_options(&$options) {
  56. }
  57. /**
  58. * Determine if the administrator has the privileges to use this plugin.
  59. */
  60. public function access() {
  61. return TRUE;
  62. }
  63. /**
  64. * If we don't have access to the form but are showing it anyway, ensure that
  65. * the form is safe and cannot be changed from user input.
  66. *
  67. * This is only called by child objects if specified in the options_form(),
  68. * so it will not always be used.
  69. */
  70. public function check_access(&$form, $option_name) {
  71. if (!$this->access()) {
  72. $form[$option_name]['#disabled'] = TRUE;
  73. $form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
  74. $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>';
  75. }
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public function validate_argument($arg) {
  81. return TRUE;
  82. }
  83. /**
  84. * Process the summary arguments for displaying.
  85. *
  86. * Some plugins alter the argument so it uses something else internally.
  87. * For example the user validation set's the argument to the uid,
  88. * for a faster query. But there are use cases where you want to use
  89. * the old value again, for example the summary.
  90. */
  91. public function process_summary_arguments(&$args) {
  92. }
  93. }
  94. /**
  95. * @}
  96. */