1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Contains the base argument validator plugin.
|
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
|
23 |
|
|
* it is linked to.
|
24 |
|
|
*/
|
25 |
|
|
function init(&$view, &$argument, $options) {
|
26 |
|
|
$this->view = &$view;
|
27 |
|
|
$this->argument = &$argument;
|
28 |
|
|
|
29 |
|
|
$this->convert_options($options);
|
30 |
|
|
$this->unpack_options($this->options, $options);
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
/**
|
34 |
|
|
* Retrieve the options when this is a new access
|
35 |
|
|
* control plugin
|
36 |
|
|
*/
|
37 |
|
|
function option_definition() { return array(); }
|
38 |
|
|
|
39 |
|
|
/**
|
40 |
|
|
* Provide the default form for setting options.
|
41 |
|
|
*/
|
42 |
|
|
function options_form(&$form, &$form_state) { }
|
43 |
|
|
|
44 |
|
|
/**
|
45 |
|
|
* Provide the default form form for validating options
|
46 |
|
|
*/
|
47 |
|
|
function options_validate(&$form, &$form_state) { }
|
48 |
|
|
|
49 |
|
|
/**
|
50 |
|
|
* Provide the default form form for submitting options
|
51 |
|
|
*/
|
52 |
|
|
function options_submit(&$form, &$form_state, &$options = array()) { }
|
53 |
|
|
|
54 |
|
|
/**
|
55 |
|
|
* Convert options from the older style.
|
56 |
|
|
*
|
57 |
|
|
* In Views 3, the method of storing default argument options has changed
|
58 |
|
|
* and each plugin now gets its own silo. This method can be used to
|
59 |
|
|
* move arguments from the old style to the new style. See
|
60 |
|
|
* views_plugin_argument_default_fixed for a good example of this method.
|
61 |
|
|
*/
|
62 |
|
|
function convert_options(&$options) { }
|
63 |
|
|
|
64 |
|
|
/**
|
65 |
|
|
* Determine if the administrator has the privileges to use this plugin
|
66 |
|
|
*/
|
67 |
|
|
function access() { return TRUE; }
|
68 |
|
|
|
69 |
|
|
/**
|
70 |
|
|
* If we don't have access to the form but are showing it anyway, ensure that
|
71 |
|
|
* the form is safe and cannot be changed from user input.
|
72 |
|
|
*
|
73 |
|
|
* This is only called by child objects if specified in the options_form(),
|
74 |
|
|
* so it will not always be used.
|
75 |
|
|
*/
|
76 |
|
|
function check_access(&$form, $option_name) {
|
77 |
|
|
if (!$this->access()) {
|
78 |
|
|
$form[$option_name]['#disabled'] = TRUE;
|
79 |
|
|
$form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
|
80 |
|
|
$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>';
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
function validate_argument($arg) { return TRUE; }
|
85 |
|
|
|
86 |
|
|
/**
|
87 |
|
|
* Process the summary arguments for displaying.
|
88 |
|
|
*
|
89 |
d719f12f
|
Assos Assos
|
* Some plugins alter the argument so it uses something else internally.
|
90 |
85ad3d82
|
Assos Assos
|
* For example the user validation set's the argument to the uid,
|
91 |
|
|
* for a faster query. But there are use cases where you want to use
|
92 |
|
|
* the old value again, for example the summary.
|
93 |
|
|
*/
|
94 |
|
|
function process_summary_arguments(&$args) { }
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
/**
|
98 |
|
|
* @}
|
99 |
|
|
*/ |