Projet

Général

Profil

Paste
Télécharger (2,94 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / plugins / views_plugin_argument_validate.inc @ 5d12d676

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_plugin_argument_validate.
6
 */
7

    
8
/**
9
 * @defgroup views_argument_validate_plugins Views argument validate plugins
10
 * @{
11
 * Allow specialized methods of validating arguments.
12
 *
13
 * @see hook_views_plugins()
14
 */
15

    
16
/**
17
 * Base argument validator plugin to provide basic functionality.
18
 */
19
class views_plugin_argument_validate extends views_plugin {
20

    
21
  /**
22
   * Initialize this plugin with the view and the argument it is linked to.
23
   */
24
  public function init(&$view, &$argument, $options) {
25
    $this->view = &$view;
26
    $this->argument = &$argument;
27

    
28
    $this->convert_options($options);
29
    $this->unpack_options($this->options, $options);
30
  }
31

    
32
  /**
33
   * Retrieve the options when this is a new access control plugin.
34
   */
35
  public function option_definition() {
36
    return array();
37
  }
38

    
39
  /**
40
   * Provide the default form for setting options.
41
   */
42
  public function options_form(&$form, &$form_state) {
43
  }
44

    
45
  /**
46
   * Provide the default form form for validating options.
47
   */
48
  public function options_validate(&$form, &$form_state) {
49
  }
50

    
51
  /**
52
   * Provide the default form form for submitting options
53
   */
54
  public function options_submit(&$form, &$form_state, &$options = array()) {
55
  }
56

    
57
  /**
58
   * Convert options from the older style.
59
   *
60
   * In Views 3, the method of storing default argument options has changed
61
   * and each plugin now gets its own silo. This method can be used to
62
   * move arguments from the old style to the new style. See
63
   * views_plugin_argument_default_fixed for a good example of this method.
64
   */
65
  public function convert_options(&$options) {
66
  }
67

    
68
  /**
69
   * Determine if the administrator has the privileges to use this plugin.
70
   */
71
  public function access() {
72
    return TRUE;
73
  }
74

    
75
  /**
76
   * If we don't have access to the form but are showing it anyway, ensure that
77
   * the form is safe and cannot be changed from user input.
78
   *
79
   * This is only called by child objects if specified in the options_form(),
80
   * so it will not always be used.
81
   */
82
  public function check_access(&$form, $option_name) {
83
    if (!$this->access()) {
84
      $form[$option_name]['#disabled'] = TRUE;
85
      $form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
86
      $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>';
87
    }
88
  }
89

    
90
  /**
91
   * {@inheritdoc}
92
   */
93
  public function validate_argument($arg) {
94
    return TRUE;
95
  }
96

    
97
  /**
98
   * Process the summary arguments for displaying.
99
   *
100
   * Some plugins alter the argument so it uses something else internally.
101
   * For example the user validation set's the argument to the uid,
102
   * for a faster query. But there are use cases where you want to use
103
   * the old value again, for example the summary.
104
   */
105
  public function process_summary_arguments(&$args) {
106
  }
107

    
108
}
109

    
110
/**
111
 * @}
112
 */