Projet

Général

Profil

Paste
Télécharger (1,27 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / variable / variable_views / includes / views_plugin_argument_default_variable.inc @ 7942932f

1
<?php
2
/**
3
 * @file
4
 * Contains the php code argument default plugin.
5
 */
6

    
7
/**
8
 * Default argument plugin to provide a variable value.
9
 */
10
class views_plugin_argument_default_variable extends views_plugin_argument_default {
11
  function option_definition() {
12
    $options = parent::option_definition();
13
    $options['variable'] = array('default' => '');
14
    return $options;
15
  }
16

    
17
  function options_form(&$form, &$form_state) {
18
    parent::options_form($form, $form_state);
19
    $form['variable'] = array(
20
      '#type' => 'select',
21
      '#title' => t('Variable value'),
22
      '#options' => _variable_views_variable_list(),
23
      '#default_value' => $this->options['variable'],
24
      '#description' => t('Select a variable whose value will be retrieved at run time.'),
25
    );
26
  }
27

    
28
  function convert_options(&$options) {
29
    if (!isset($options['variable']) && isset($this->argument->options['default_argument_variable'])) {
30
      $options['variable'] = $this->argument->options['default_argument_variable'];
31
    }
32
  }
33

    
34
  /**
35
   * Only let users with PHP block visibility permissions set/modify this
36
   * default plugin.
37
   */
38
  function access() {
39
    return user_access('administer site configuration');
40
  }
41

    
42
  function get_argument() {
43
    return variable_get_value($this->options['variable']);
44
  }
45
}