1 | <?php |
---|
2 | /** |
---|
3 | * @file |
---|
4 | * Contains the base argument validator plugin. |
---|
5 | */ |
---|
6 | |
---|
7 | /** |
---|
8 | * @defgroup views_argument_validate_plugins Views' argument validate plugins |
---|
9 | * @{ |
---|
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 | * @ingroup views_argument_validate_plugins |
---|
20 | */ |
---|
21 | class views_plugin_argument_validate extends views_plugin { |
---|
22 | |
---|
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 | |
---|
31 | $this->convert_options($options); |
---|
32 | $this->unpack_options($this->options, $options); |
---|
33 | } |
---|
34 | |
---|
35 | /** |
---|
36 | * Retrieve the options when this is a new access |
---|
37 | * control plugin |
---|
38 | */ |
---|
39 | function option_definition() { return array(); } |
---|
40 | |
---|
41 | /** |
---|
42 | * Provide the default form for setting options. |
---|
43 | */ |
---|
44 | function options_form(&$form, &$form_state) { } |
---|
45 | |
---|
46 | /** |
---|
47 | * Provide the default form form for validating options |
---|
48 | */ |
---|
49 | function options_validate(&$form, &$form_state) { } |
---|
50 | |
---|
51 | /** |
---|
52 | * Provide the default form form for submitting options |
---|
53 | */ |
---|
54 | function options_submit(&$form, &$form_state) { } |
---|
55 | |
---|
56 | /** |
---|
57 | * Convert options from the older style. |
---|
58 | * |
---|
59 | * In Views 3, the method of storing default argument options has changed |
---|
60 | * and each plugin now gets its own silo. This method can be used to |
---|
61 | * move arguments from the old style to the new style. See |
---|
62 | * views_plugin_argument_default_fixed for a good example of this method. |
---|
63 | */ |
---|
64 | function convert_options(&$options) { } |
---|
65 | |
---|
66 | /** |
---|
67 | * Determine if the administrator has the privileges to use this plugin |
---|
68 | */ |
---|
69 | function access() { return TRUE; } |
---|
70 | |
---|
71 | /** |
---|
72 | * If we don't have access to the form but are showing it anyway, ensure that |
---|
73 | * the form is safe and cannot be changed from user input. |
---|
74 | * |
---|
75 | * This is only called by child objects if specified in the options_form(), |
---|
76 | * so it will not always be used. |
---|
77 | */ |
---|
78 | function check_access(&$form, $option_name) { |
---|
79 | if (!$this->access()) { |
---|
80 | $form[$option_name]['#disabled'] = TRUE; |
---|
81 | $form[$option_name]['#value'] = $form[$this->option_name]['#default_value']; |
---|
82 | $form[$option_name]['#description'] .= ' <strong>' . t('Note: you do not have permission to modify this. If you change the default argument type, this setting will be lost and you will NOT be able to get it back.') . '</strong>'; |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | function validate_argument($arg) { return TRUE; } |
---|
87 | } |
---|
88 | |
---|
89 | /** |
---|
90 | * @} |
---|
91 | */ |
---|