views_plugin_argument_default.inc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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
  21. * do what is needed.
  22. */
  23. public function get_argument() {
  24. }
  25. /**
  26. * Initialize this plugin with the view and the argument it is linked to.
  27. */
  28. public function init(&$view, &$argument, $options) {
  29. $this->view = &$view;
  30. $this->argument = &$argument;
  31. $this->convert_options($options);
  32. $this->unpack_options($this->options, $options);
  33. }
  34. /**
  35. * Retrieve the options when this is a new access control plugin.
  36. */
  37. public function option_definition() {
  38. return array();
  39. }
  40. /**
  41. * Provide the default form for setting options.
  42. */
  43. public function options_form(&$form, &$form_state) {
  44. }
  45. /**
  46. * Provide the default form form for validating options.
  47. */
  48. public function options_validate(&$form, &$form_state) {
  49. }
  50. /**
  51. * Provide the default form form for submitting options.
  52. */
  53. public function options_submit(&$form, &$form_state, &$options = array()) {
  54. }
  55. /**
  56. * Determine if the administrator has the privileges to use this plugin.
  57. */
  58. public function access() {
  59. return TRUE;
  60. }
  61. /**
  62. * If we don't have access to the form but are showing it anyway, ensure that
  63. * the form is safe and cannot be changed from user input.
  64. *
  65. * This is only called by child objects if specified in the options_form(),
  66. * so it will not always be used.
  67. */
  68. public function check_access(&$form, $option_name) {
  69. if (!$this->access()) {
  70. $form[$option_name]['#disabled'] = TRUE;
  71. $form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
  72. $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>';
  73. }
  74. }
  75. /**
  76. * Convert options from the older style.
  77. *
  78. * In Views 3, the method of storing default argument options has changed
  79. * and each plugin now gets its own silo. This method can be used to
  80. * move arguments from the old style to the new style. See
  81. * views_plugin_argument_default_fixed for a good example of this method.
  82. */
  83. public function convert_options(&$options) {
  84. }
  85. }
  86. /**
  87. * @}
  88. */