views_plugin_argument_default.inc

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

Definition of views_plugin_argument_default.

File

plugins/views_plugin_argument_default.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_plugin_argument_default.
  5. */
  6. /**
  7. * @defgroup views_argument_default_plugins Views argument default plugins
  8. * @{
  9. * Allow specialized methods of filling in arguments when they aren't provided.
  10. *
  11. * @see hook_views_plugins()
  12. */
  13. /**
  14. * The fixed argument default handler; also used as the base.
  15. */
  16. class views_plugin_argument_default extends views_plugin {
  17. /**
  18. * Return the default argument.
  19. *
  20. * This needs to be overridden by every default argument handler to properly do what is needed.
  21. */
  22. function get_argument() { }
  23. /**
  24. * Initialize this plugin with the view and the argument
  25. * it is linked to.
  26. */
  27. function init(&$view, &$argument, $options) {
  28. $this->view = &$view;
  29. $this->argument = &$argument;
  30. $this->convert_options($options);
  31. $this->unpack_options($this->options, $options);
  32. }
  33. /**
  34. * Retrieve the options when this is a new access
  35. * control plugin
  36. */
  37. function option_definition() { return array(); }
  38. /**
  39. * Provide the default form for setting options.
  40. */
  41. function options_form(&$form, &$form_state) { }
  42. /**
  43. * Provide the default form form for validating options
  44. */
  45. function options_validate(&$form, &$form_state) { }
  46. /**
  47. * Provide the default form form for submitting options
  48. */
  49. function options_submit(&$form, &$form_state, &$options = array()) { }
  50. /**
  51. * Determine if the administrator has the privileges to use this
  52. * plugin
  53. */
  54. function access() { return TRUE; }
  55. /**
  56. * If we don't have access to the form but are showing it anyway, ensure that
  57. * the form is safe and cannot be changed from user input.
  58. *
  59. * This is only called by child objects if specified in the options_form(),
  60. * so it will not always be used.
  61. */
  62. function check_access(&$form, $option_name) {
  63. if (!$this->access()) {
  64. $form[$option_name]['#disabled'] = TRUE;
  65. $form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
  66. $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>';
  67. }
  68. }
  69. /**
  70. * Convert options from the older style.
  71. *
  72. * In Views 3, the method of storing default argument options has changed
  73. * and each plugin now gets its own silo. This method can be used to
  74. * move arguments from the old style to the new style. See
  75. * views_plugin_argument_default_fixed for a good example of this method.
  76. */
  77. function convert_options(&$options) { }
  78. }
  79. /**
  80. * @}
  81. */