Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/modules/node/views_plugin_argument_validate_node.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Contains the 'node' argument validator plugin.
|
|
5 |
* Definition of views_plugin_argument_validate_node.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
9 | 9 |
* Validate whether an argument is an acceptable node. |
10 | 10 |
*/ |
11 | 11 |
class views_plugin_argument_validate_node extends views_plugin_argument_validate { |
12 |
function option_definition() { |
|
12 |
|
|
13 |
/** |
|
14 |
* {@inheritdoc} |
|
15 |
*/ |
|
16 |
public function option_definition() { |
|
13 | 17 |
$options = parent::option_definition(); |
14 | 18 |
$options['types'] = array('default' => array()); |
15 | 19 |
$options['access'] = array('default' => FALSE, 'bool' => TRUE); |
... | ... | |
19 | 23 |
return $options; |
20 | 24 |
} |
21 | 25 |
|
22 |
function options_form(&$form, &$form_state) { |
|
26 |
/** |
|
27 |
* {@inheritdoc} |
|
28 |
*/ |
|
29 |
public function options_form(&$form, &$form_state) { |
|
23 | 30 |
$types = node_type_get_types(); |
24 | 31 |
$options = array(); |
25 | 32 |
foreach ($types as $type => $info) { |
... | ... | |
58 | 65 |
); |
59 | 66 |
} |
60 | 67 |
|
61 |
function options_submit(&$form, &$form_state, &$options = array()) { |
|
62 |
// filter trash out of the options so we don't store giant unnecessary arrays |
|
68 |
/** |
|
69 |
* {@inheritdoc} |
|
70 |
*/ |
|
71 |
public function options_submit(&$form, &$form_state, &$options = array()) { |
|
72 |
// Filter trash out of the options so we don't store giant unnecessary |
|
73 |
// arrays. |
|
63 | 74 |
$options['types'] = array_filter($options['types']); |
64 | 75 |
} |
65 | 76 |
|
66 |
function convert_options(&$options) { |
|
77 |
/** |
|
78 |
* {@inheritdoc} |
|
79 |
*/ |
|
80 |
public function convert_options(&$options) { |
|
67 | 81 |
if (!isset($options['types']) && !empty($this->argument->options['validate_argument_node_type'])) { |
68 | 82 |
$options['types'] = isset($this->argument->options['validate_argument_node_type']) ? $this->argument->options['validate_argument_node_type'] : array(); |
69 | 83 |
$options['access'] = !empty($this->argument->options['validate_argument_node_access']); |
... | ... | |
72 | 86 |
} |
73 | 87 |
} |
74 | 88 |
|
75 |
function validate_argument($argument) { |
|
89 |
/** |
|
90 |
* {@inheritdoc} |
|
91 |
*/ |
|
92 |
public function validate_argument($argument) { |
|
76 | 93 |
$types = $this->options['types']; |
77 | 94 |
|
78 | 95 |
switch ($this->options['nid_type']) { |
... | ... | |
99 | 116 |
} |
100 | 117 |
|
101 | 118 |
return isset($types[$node->type]); |
102 |
break; |
|
119 |
break; |
|
120 |
|
|
103 | 121 |
case 'nids': |
104 | 122 |
$nids = new stdClass(); |
105 | 123 |
$nids->value = array($argument); |
... | ... | |
111 | 129 |
$test = drupal_map_assoc($nids->value); |
112 | 130 |
$titles = array(); |
113 | 131 |
|
114 |
$result = db_query("SELECT * FROM {node} WHERE nid IN (:nids)", array(':nids' => $nids->value));
|
|
132 |
$result = db_query("SELECT * FROM {node} WHERE nid IN (:nids)", array(':nids' => $nids->value)); |
|
115 | 133 |
foreach ($result as $node) { |
116 | 134 |
if ($types && empty($types[$node->type])) { |
117 | 135 |
return FALSE; |
... | ... | |
132 | 150 |
return empty($test); |
133 | 151 |
} |
134 | 152 |
} |
153 |
|
|
135 | 154 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules