views_plugin_argument_default_variable.inc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * @file
  4. * Contains the php code argument default plugin.
  5. */
  6. /**
  7. * Default argument plugin to provide a variable value.
  8. */
  9. class views_plugin_argument_default_variable extends views_plugin_argument_default {
  10. function option_definition() {
  11. $options = parent::option_definition();
  12. $options['variable'] = array('default' => '');
  13. return $options;
  14. }
  15. function options_form(&$form, &$form_state) {
  16. parent::options_form($form, $form_state);
  17. $form['variable'] = array(
  18. '#type' => 'select',
  19. '#title' => t('Variable value'),
  20. '#options' => _variable_views_variable_list(),
  21. '#default_value' => $this->options['variable'],
  22. '#description' => t('Select a variable whose value will be retrieved at run time.'),
  23. );
  24. }
  25. function convert_options(&$options) {
  26. if (!isset($options['variable']) && isset($this->argument->options['default_argument_variable'])) {
  27. $options['variable'] = $this->argument->options['default_argument_variable'];
  28. }
  29. }
  30. /**
  31. * Only let users with PHP block visibility permissions set/modify this
  32. * default plugin.
  33. */
  34. function access() {
  35. return user_access('administer site configuration');
  36. }
  37. function get_argument() {
  38. return variable_get_value($this->options['variable']);
  39. }
  40. }