1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of views_plugin_argument_default.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* @defgroup views_argument_default_plugins Views argument default plugins
|
10 |
|
|
* @{
|
11 |
|
|
* Allow specialized methods of filling in arguments when they aren't provided.
|
12 |
|
|
*
|
13 |
|
|
* @see hook_views_plugins()
|
14 |
|
|
*/
|
15 |
|
|
|
16 |
|
|
/**
|
17 |
|
|
* The fixed argument default handler; also used as the base.
|
18 |
|
|
*/
|
19 |
|
|
class views_plugin_argument_default extends views_plugin {
|
20 |
|
|
/**
|
21 |
|
|
* Return the default argument.
|
22 |
|
|
*
|
23 |
|
|
* This needs to be overridden by every default argument handler to properly do what is needed.
|
24 |
|
|
*/
|
25 |
|
|
function get_argument() { }
|
26 |
|
|
|
27 |
|
|
/**
|
28 |
|
|
* Initialize this plugin with the view and the argument
|
29 |
|
|
* it is linked to.
|
30 |
|
|
*/
|
31 |
|
|
function init(&$view, &$argument, $options) {
|
32 |
|
|
$this->view = &$view;
|
33 |
|
|
$this->argument = &$argument;
|
34 |
|
|
|
35 |
|
|
$this->convert_options($options);
|
36 |
|
|
$this->unpack_options($this->options, $options);
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
/**
|
40 |
|
|
* Retrieve the options when this is a new access
|
41 |
|
|
* control plugin
|
42 |
|
|
*/
|
43 |
|
|
function option_definition() { return array(); }
|
44 |
|
|
|
45 |
|
|
/**
|
46 |
|
|
* Provide the default form for setting options.
|
47 |
|
|
*/
|
48 |
|
|
function options_form(&$form, &$form_state) { }
|
49 |
|
|
|
50 |
|
|
/**
|
51 |
|
|
* Provide the default form form for validating options
|
52 |
|
|
*/
|
53 |
|
|
function options_validate(&$form, &$form_state) { }
|
54 |
|
|
|
55 |
|
|
/**
|
56 |
|
|
* Provide the default form form for submitting options
|
57 |
|
|
*/
|
58 |
|
|
function options_submit(&$form, &$form_state, &$options = array()) { }
|
59 |
|
|
|
60 |
|
|
/**
|
61 |
|
|
* Determine if the administrator has the privileges to use this
|
62 |
|
|
* plugin
|
63 |
|
|
*/
|
64 |
|
|
function access() { return TRUE; }
|
65 |
|
|
|
66 |
|
|
/**
|
67 |
|
|
* If we don't have access to the form but are showing it anyway, ensure that
|
68 |
|
|
* the form is safe and cannot be changed from user input.
|
69 |
|
|
*
|
70 |
|
|
* This is only called by child objects if specified in the options_form(),
|
71 |
|
|
* so it will not always be used.
|
72 |
|
|
*/
|
73 |
|
|
function check_access(&$form, $option_name) {
|
74 |
|
|
if (!$this->access()) {
|
75 |
|
|
$form[$option_name]['#disabled'] = TRUE;
|
76 |
|
|
$form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
|
77 |
|
|
$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>';
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
/**
|
82 |
|
|
* Convert options from the older style.
|
83 |
|
|
*
|
84 |
|
|
* In Views 3, the method of storing default argument options has changed
|
85 |
|
|
* and each plugin now gets its own silo. This method can be used to
|
86 |
|
|
* move arguments from the old style to the new style. See
|
87 |
|
|
* views_plugin_argument_default_fixed for a good example of this method.
|
88 |
|
|
*/
|
89 |
|
|
function convert_options(&$options) { }
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
/**
|
93 |
|
|
* @}
|
94 |
|
|
*/ |