Révision 78d68095
Ajouté par Assos Assos il y a environ 5 ans
drupal7/sites/all/modules/chain_menu_access/CHANGELOG.txt | ||
---|---|---|
4 | 4 |
|
5 | 5 |
chain_menu_access 7.x-2.x-dev: |
6 | 6 |
|
7 |
chain_menu_access 7.x-2.1 (2019-02-06): |
|
8 |
- Issue #2995656 by somersoft, aburrows: Fix Function create_function() is deprecated. |
|
9 |
|
|
7 | 10 |
|
8 | 11 |
chain_menu_access 7.x-2.0 (2012-08-30): |
9 | 12 |
- Avoid a notice (no functional change). |
drupal7/sites/all/modules/chain_menu_access/chain_menu_access.info | ||
---|---|---|
6 | 6 |
files[] = chain_menu_access.module |
7 | 7 |
files[] = tests/chain_menu_access.test |
8 | 8 |
|
9 |
; Information added by drupal.org packaging script on 2012-08-30
|
|
10 |
version = "7.x-2.0"
|
|
9 |
; Information added by Drupal.org packaging script on 2019-03-07
|
|
10 |
version = "7.x-2.1"
|
|
11 | 11 |
core = "7.x" |
12 | 12 |
project = "chain_menu_access" |
13 |
datestamp = "1346338604" |
|
14 |
|
|
13 |
datestamp = "1551918184" |
drupal7/sites/all/modules/chain_menu_access/chain_menu_access.module | ||
---|---|---|
56 | 56 |
} |
57 | 57 |
|
58 | 58 |
// Look through the child items for the MENU_DEFAULT_LOCAL_TASK. |
59 |
$child_paths = array_filter(array_keys($items), create_function('$p', "return preg_match('#^$path/[^/]*$#', \$p);")); |
|
59 |
$child_paths = array_filter(array_keys($items), function($p) use ($path) { |
|
60 |
return preg_match("#^$path/[^/]*$#", $p); |
|
61 |
}); |
|
62 |
|
|
60 | 63 |
foreach ($child_paths as $child_path) { |
61 | 64 |
$child_item =& $items[$child_path]; |
62 | 65 |
if (isset($child_item['type']) && $child_item['type'] == MENU_DEFAULT_LOCAL_TASK) { |
drupal7/sites/all/modules/chain_menu_access/tests/chain_menu_access_test.info | ||
---|---|---|
4 | 4 |
core = 7.x |
5 | 5 |
hidden = TRUE |
6 | 6 |
|
7 |
; Information added by drupal.org packaging script on 2012-08-30
|
|
8 |
version = "7.x-2.0"
|
|
7 |
; Information added by Drupal.org packaging script on 2019-03-07
|
|
8 |
version = "7.x-2.1"
|
|
9 | 9 |
core = "7.x" |
10 | 10 |
project = "chain_menu_access" |
11 |
datestamp = "1346338604" |
|
12 |
|
|
11 |
datestamp = "1551918184" |
drupal7/sites/all/modules/shs/README.txt | ||
---|---|---|
88 | 88 |
* undpaul |
89 | 89 |
Drupal experts providing professional Drupal development services. |
90 | 90 |
Visit http://www.undpaul.de for more information. |
91 |
|
drupal7/sites/all/modules/shs/includes/handlers/shs_handler_filter_entityreference.inc | ||
---|---|---|
12 | 12 |
*/ |
13 | 13 |
class shs_handler_filter_entityreference extends views_handler_filter_numeric { |
14 | 14 |
|
15 |
// Define filter options. |
|
16 |
function option_definition() { |
|
15 |
/** |
|
16 |
* Define filter options. |
|
17 |
*/ |
|
18 |
public function option_definition() { |
|
17 | 19 |
$options = parent::option_definition(); |
18 | 20 |
|
19 | 21 |
$options['shs_enabled'] = array('default' => FALSE); |
... | ... | |
30 | 32 |
* @param array $form_state |
31 | 33 |
* Current form state. |
32 | 34 |
*/ |
33 |
function options_form(&$form, &$form_state) { |
|
35 |
public function options_form(&$form, &$form_state) {
|
|
34 | 36 |
parent::options_form($form, $form_state); |
35 | 37 |
|
36 | 38 |
$form['shs_enabled'] = array( |
... | ... | |
58 | 60 |
} |
59 | 61 |
|
60 | 62 |
/** |
61 |
* Provide a simple textfield for equality |
|
63 |
* Provide a simple textfield for equality.
|
|
62 | 64 |
*/ |
63 |
function value_form(&$form, &$form_state) { |
|
65 |
public function value_form(&$form, &$form_state) {
|
|
64 | 66 |
global $language; |
65 | 67 |
|
66 | 68 |
parent::value_form($form, $form_state); |
... | ... | |
93 | 95 |
if (empty($form_state['input'][$identifier])) { |
94 | 96 |
$form_state['input'][$identifier] = 'All'; |
95 | 97 |
} |
96 |
$default_value = $form_state['input'][$identifier];
|
|
98 |
$default_value = check_plain($form_state['input'][$identifier]);
|
|
97 | 99 |
if (!is_array($default_value) && $multiple) { |
98 | 100 |
$default_value = explode('+', $default_value); |
99 | 101 |
foreach ($default_value as $delta => $value) { |
... | ... | |
207 | 209 |
* @return string |
208 | 210 |
* Short summary explaining the settings. |
209 | 211 |
*/ |
210 |
function admin_summary() { |
|
212 |
public function admin_summary() {
|
|
211 | 213 |
$summary = parent::admin_summary(); |
212 | 214 |
|
213 | 215 |
// @todo: add "shs". |
drupal7/sites/all/modules/shs/includes/handlers/shs_handler_filter_term_node_tid.inc | ||
---|---|---|
12 | 12 |
*/ |
13 | 13 |
class shs_handler_filter_term_node_tid extends views_handler_filter_term_node_tid { |
14 | 14 |
|
15 |
function option_definition() { |
|
15 |
/** |
|
16 |
* {@inheritdoc} |
|
17 |
*/ |
|
18 |
public function option_definition() { |
|
16 | 19 |
$options = parent::option_definition(); |
17 | 20 |
|
18 | 21 |
$options['type'] = array('default' => 'shs'); |
... | ... | |
21 | 24 |
return $options; |
22 | 25 |
} |
23 | 26 |
|
24 |
function extra_options_form(&$form, &$form_state) { |
|
27 |
/** |
|
28 |
* {@inheritdoc} |
|
29 |
*/ |
|
30 |
public function extra_options_form(&$form, &$form_state) { |
|
25 | 31 |
parent::extra_options_form($form, $form_state); |
26 | 32 |
|
27 | 33 |
$form['type']['#options'] += array( |
... | ... | |
44 | 50 |
} |
45 | 51 |
} |
46 | 52 |
|
47 |
function value_form(&$form, &$form_state) { |
|
53 |
/** |
|
54 |
* {@inheritdoc} |
|
55 |
*/ |
|
56 |
public function value_form(&$form, &$form_state) { |
|
48 | 57 |
global $language; |
49 | 58 |
|
50 | 59 |
parent::value_form($form, $form_state); |
... | ... | |
65 | 74 |
$default_value = empty($this->value) ? 0 : $this->value; |
66 | 75 |
|
67 | 76 |
if (!empty($form_state['input'][$identifier])) { |
68 |
$default_value = $form_state['input'][$identifier];
|
|
77 |
$default_value = check_plain($form_state['input'][$identifier]);
|
|
69 | 78 |
if ($multiple && !is_array($default_value)) { |
70 | 79 |
$default_value = array($default_value); |
71 | 80 |
} |
... | ... | |
83 | 92 |
$default_value = $values; |
84 | 93 |
} |
85 | 94 |
$parents_multiple = array(); |
86 |
foreach ($default_value as $delta => $tid) {
|
|
95 |
foreach ($default_value as $tid) { |
|
87 | 96 |
$parents_multiple[] = $tid; |
88 | 97 |
} |
89 | 98 |
$parents[] = array('tid' => $parents_multiple); |
... | ... | |
159 | 168 |
} |
160 | 169 |
} |
161 | 170 |
|
162 |
function admin_summary() { |
|
171 |
/** |
|
172 |
* {@inheritdoc} |
|
173 |
*/ |
|
174 |
public function admin_summary() { |
|
163 | 175 |
// Set up $this->value_options for the parent summary. |
164 | 176 |
$this->value_options = array(); |
165 | 177 |
|
drupal7/sites/all/modules/shs/includes/handlers/shs_handler_filter_term_node_tid_depth.inc | ||
---|---|---|
15 | 15 |
* @ingroup views_filter_handlers |
16 | 16 |
*/ |
17 | 17 |
class shs_handler_filter_term_node_tid_depth extends shs_handler_filter_term_node_tid { |
18 |
function operator_options($which = 'title') { |
|
18 |
|
|
19 |
/** |
|
20 |
* {@inheritdoc} |
|
21 |
*/ |
|
22 |
public function operator_options($which = 'title') { |
|
19 | 23 |
return array( |
20 | 24 |
'or' => t('Is one of'), |
21 | 25 |
); |
22 | 26 |
} |
23 | 27 |
|
24 |
function option_definition() { |
|
28 |
/** |
|
29 |
* {@inheritdoc} |
|
30 |
*/ |
|
31 |
public function option_definition() { |
|
25 | 32 |
$options = parent::option_definition(); |
26 | 33 |
|
27 | 34 |
$options['depth'] = array('default' => 0); |
... | ... | |
29 | 36 |
return $options; |
30 | 37 |
} |
31 | 38 |
|
32 |
function extra_options_form(&$form, &$form_state) { |
|
39 |
/** |
|
40 |
* {@inheritdoc} |
|
41 |
*/ |
|
42 |
public function extra_options_form(&$form, &$form_state) { |
|
33 | 43 |
parent::extra_options_form($form, $form_state); |
34 | 44 |
|
35 | 45 |
$form['depth'] = array( |
... | ... | |
40 | 50 |
); |
41 | 51 |
} |
42 | 52 |
|
43 |
function query() { |
|
53 |
/** |
|
54 |
* {@inheritdoc} |
|
55 |
*/ |
|
56 |
public function query() { |
|
44 | 57 |
// Check if multiple select allowed. |
45 | 58 |
if ($this->options['expose']['multiple']) { |
46 | 59 |
// If no filter values are present, then do nothing. |
... | ... | |
118 | 131 |
$subquery->condition($where); |
119 | 132 |
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", $subquery, 'IN'); |
120 | 133 |
} |
134 |
|
|
121 | 135 |
} |
drupal7/sites/all/modules/shs/js/shs.js | ||
---|---|---|
223 | 223 |
data: { |
224 | 224 |
callback: 'shs_json_term_add', |
225 | 225 |
arguments: { |
226 |
token: settings.token, |
|
226 | 227 |
vid: term.vid, |
227 | 228 |
parent: term.parent, |
228 | 229 |
name: term.name, |
drupal7/sites/all/modules/shs/modules/shs_node_count/shs_node_count.info | ||
---|---|---|
3 | 3 |
description = Extends 'Simple hierarchical select' with "node count" functionality. |
4 | 4 |
dependencies[] = shs |
5 | 5 |
|
6 |
; Information added by Drupal.org packaging script on 2018-03-06
|
|
7 |
version = "7.x-1.7"
|
|
6 |
; Information added by Drupal.org packaging script on 2019-03-13
|
|
7 |
version = "7.x-1.8"
|
|
8 | 8 |
core = "7.x" |
9 | 9 |
project = "shs" |
10 |
datestamp = "1520313188" |
|
11 |
|
|
10 |
datestamp = "1552465688" |
drupal7/sites/all/modules/shs/modules/shs_node_count/shs_node_count.module | ||
---|---|---|
65 | 65 |
* |
66 | 66 |
* @param object $term |
67 | 67 |
* The term object. |
68 |
* @param boolean $count_children
|
|
68 |
* @param bool $count_children |
|
69 | 69 |
* If set to TRUE, nodes in child terms are counted also. |
70 | 70 |
* |
71 | 71 |
* @return int |
... | ... | |
84 | 84 |
|
85 | 85 |
// Count nodes associated to this term. |
86 | 86 |
$num_nodes["{$term->tid}:{$count_children}"] = db_select($index_table, 'ti') |
87 |
->fields('ti')
|
|
88 |
->condition('tid', $term->tid)
|
|
89 |
->execute()
|
|
90 |
->rowCount();
|
|
87 |
->fields('ti') |
|
88 |
->condition('tid', $term->tid) |
|
89 |
->execute() |
|
90 |
->rowCount(); |
|
91 | 91 |
|
92 | 92 |
if ($count_children) { |
93 | 93 |
$tids = array(); |
... | ... | |
97 | 97 |
} |
98 | 98 |
if (count($tids)) { |
99 | 99 |
$num_nodes["{$term->tid}:{$count_children}"] += db_select($index_table, 'ti') |
100 |
->fields('ti')
|
|
101 |
->condition('tid', $tids, 'IN')
|
|
102 |
->execute()
|
|
103 |
->rowCount();
|
|
100 |
->fields('ti') |
|
101 |
->condition('tid', $tids, 'IN') |
|
102 |
->execute() |
|
103 |
->rowCount(); |
|
104 | 104 |
} |
105 | 105 |
} |
106 | 106 |
} |
drupal7/sites/all/modules/shs/shs.api.php | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Hooks for the shs module. |
|
5 | 6 |
* |
6 | 7 |
* This file contains no working PHP code; it exists to provide additional |
7 | 8 |
* documentation for doxygen as well as to document hooks in the standard Drupal |
... | ... | |
13 | 14 |
* |
14 | 15 |
* @param array $settings |
15 | 16 |
* Settings for js module. |
16 |
* @see hook_js() |
|
17 |
* |
|
18 |
* @see hook_js() |
|
17 | 19 |
*/ |
18 |
function hook_shs_js_info_alter(&$settings) { |
|
20 |
function hook_shs_js_info_alter(array &$settings) {
|
|
19 | 21 |
// Add pathauto as dependency for the default json callback. |
20 | 22 |
$settings['json']['dependencies'][] = 'pathauto'; |
21 | 23 |
// Change the access callback. |
... | ... | |
34 | 36 |
* @param object $account |
35 | 37 |
* The user to check access for. |
36 | 38 |
* |
37 |
* @return boolean
|
|
39 |
* @return bool |
|
38 | 40 |
* <code>FALSE</code> if no new terms should be created below the given |
39 | 41 |
* parent, otherwise <code>TRUE</code>. |
40 | 42 |
*/ |
... | ... | |
55 | 57 |
* @param array $callbacks |
56 | 58 |
* List of callback definitions. |
57 | 59 |
*/ |
58 |
function hook_shs_json_callbacks_alter(&$callbacks) { |
|
60 |
function hook_shs_json_callbacks_alter(array &$callbacks) {
|
|
59 | 61 |
// Use custom callback for adding new terms. |
60 | 62 |
$callbacks['shs_json_term_add']['callback'] = 'my_custom_shs_json_term_add'; |
61 | 63 |
} |
... | ... | |
70 | 72 |
* - parent: ID of parent term |
71 | 73 |
* - settings: Additional settings (for example "language", etc.,) |
72 | 74 |
*/ |
73 |
function hook_shs_term_get_children_alter(&$terms, &$alter_options) {
|
|
75 |
function hook_shs_term_get_children_alter(array &$terms, array &$alter_options) {
|
|
74 | 76 |
|
75 | 77 |
} |
76 | 78 |
|
... | ... | |
84 | 86 |
* @param int|string $vocabulary_identifier |
85 | 87 |
* ID or machine_name of vocabulary the settings are used for. |
86 | 88 |
*/ |
87 |
function hook_shs_js_settings_alter(&$settings_js, $field_name, $vocabulary_identifier) { |
|
89 |
function hook_shs_js_settings_alter(array &$settings_js, $field_name, $vocabulary_identifier) {
|
|
88 | 90 |
if ($field_name == 'field_article_terms') { |
89 | 91 |
foreach ($settings_js['shs'] as $field => $container) { |
90 | 92 |
foreach ($container as $identifier => $settings) { |
91 |
$settings_js['shs'][$field][$identifier]['any_label'] = t(' - Select an item - ');
|
|
93 |
$settings_js['shs'][$field][$identifier]['any_label'] = t('- Select an item -');
|
|
92 | 94 |
} |
93 | 95 |
} |
94 | 96 |
} |
... | ... | |
104 | 106 |
* @param int|string $vocabulary_identifier |
105 | 107 |
* ID or machine_name of vocabulary the settings are used for. |
106 | 108 |
*/ |
107 |
function hook_shs_FIELDNAME_js_settings_alter(&$settings_js, $field_name, $vocabulary_identifier) { |
|
109 |
function hook_shs_FIELDNAME_js_settings_alter(array &$settings_js, $field_name, $vocabulary_identifier) {
|
|
108 | 110 |
foreach ($settings_js['shs'] as $field => &$container) { |
109 | 111 |
foreach ($container as $identifier => &$settings) { |
110 | 112 |
// Define labels for each level. |
111 | 113 |
$settings['labels'] = array( |
112 |
FALSE, // No label for first level. |
|
114 |
// No label for first level. |
|
115 |
FALSE, |
|
113 | 116 |
t('Country'), |
114 | 117 |
t('City'), |
115 | 118 |
); |
drupal7/sites/all/modules/shs/shs.info | ||
---|---|---|
6 | 6 |
files[] = includes/handlers/shs_handler_filter_term_node_tid.inc |
7 | 7 |
files[] = includes/handlers/shs_handler_filter_term_node_tid_depth.inc |
8 | 8 |
|
9 |
; Information added by Drupal.org packaging script on 2018-03-06
|
|
10 |
version = "7.x-1.7"
|
|
9 |
; Information added by Drupal.org packaging script on 2019-03-13
|
|
10 |
version = "7.x-1.8"
|
|
11 | 11 |
core = "7.x" |
12 | 12 |
project = "shs" |
13 |
datestamp = "1520313188" |
|
14 |
|
|
13 |
datestamp = "1552465688" |
drupal7/sites/all/modules/shs/shs.install | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* Installation tasks for "Simple hierarchical select". |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* Implements hook_requirements(). |
|
10 |
*/ |
|
11 |
function shs_requirements($phase) { |
|
12 |
$requirements = array(); |
|
13 |
$t = get_t(); |
|
14 |
|
|
15 |
if ($phase !== 'runtime' || !module_exists('chosen')) { |
|
16 |
return $requirements; |
|
17 |
} |
|
18 |
if (($info = drupal_get_library('chosen', 'chosen')) === FALSE) { |
|
19 |
return $requirements; |
|
20 |
} |
|
21 |
// Chosen version should be at least 1.0. |
|
22 |
if (version_compare($info['version'], '1.1.0') < 0) { |
|
23 |
$requirements['shs'] = array( |
|
24 |
'title' => $t('Simple hierarchical select: chosen integration'), |
|
25 |
'description' => $t('If you would like to use chosen with Simple hierarchical select you need to install at least version 1.1.0 of !chosen_library.', array('!chosen_library' => l($t('Chosen'), 'http://harvesthq.github.io/chosen/'))), |
|
26 |
'severity' => REQUIREMENT_WARNING, |
|
27 |
'value' => $t('Chosen library too old (installed version is !version)', array('!version' => $info['version'])), |
|
28 |
); |
|
29 |
} |
|
30 |
|
|
31 |
return $requirements; |
|
32 |
} |
drupal7/sites/all/modules/shs/shs.module | ||
---|---|---|
41 | 41 |
return $settings; |
42 | 42 |
} |
43 | 43 |
|
44 |
/** |
|
45 |
* Implements hook_requirements(). |
|
46 |
*/ |
|
47 |
function shs_requirements($phase) { |
|
48 |
$requirements = array(); |
|
49 |
$t = get_t(); |
|
50 |
|
|
51 |
if ($phase !== 'runtime' || !module_exists('chosen')) { |
|
52 |
return $requirements; |
|
53 |
} |
|
54 |
if (($info = drupal_get_library('chosen', 'chosen')) === FALSE) { |
|
55 |
return $requirements; |
|
56 |
} |
|
57 |
// Chosen version should be at least 1.0. |
|
58 |
if (version_compare($info['version'], '1.1.0') < 0) { |
|
59 |
$requirements['shs'] = array( |
|
60 |
'title' => $t('Simple hierarchical select: chosen integration'), |
|
61 |
'description' => $t('If you would like to use chosen with Simple hierarchical select you need to install at least version 1.1.0 of !chosen_library.', array('!chosen_library' => l('Chosen', 'http://harvesthq.github.io/chosen/'))), |
|
62 |
'severity' => REQUIREMENT_WARNING, |
|
63 |
'value' => $t('Chosen library too old (installed version is !version)', array('!version' => $info['version'])), |
|
64 |
); |
|
65 |
} |
|
66 |
|
|
67 |
return $requirements; |
|
68 |
} |
|
69 |
|
|
70 | 44 |
/** |
71 | 45 |
* Menu callback to get data in JSON format. |
72 | 46 |
*/ |
... | ... | |
97 | 71 |
/** |
98 | 72 |
* Get a list of supported JSON callbacks. |
99 | 73 |
* |
100 |
* @return <array>
|
|
74 |
* @return array
|
|
101 | 75 |
* List of valid callbacks with the following structure: |
102 | 76 |
* - [name of callback] |
103 | 77 |
* - 'callback': function to call |
... | ... | |
118 | 92 |
'shs_json_term_add' => array( |
119 | 93 |
'callback' => 'shs_json_term_add', |
120 | 94 |
'arguments' => array( |
95 |
'token' => array( |
|
96 |
'callback' => 'shs_json_valid_token', |
|
97 |
'arguments' => array( |
|
98 |
'field_name' => '@field', |
|
99 |
), |
|
100 |
), |
|
121 | 101 |
'vid' => 'shs_json_validation_vocabulary_identifier', |
122 | 102 |
'parent' => 'is_numeric', |
123 | 103 |
'name' => 'is_string', |
... | ... | |
130 | 110 |
return $callbacks; |
131 | 111 |
} |
132 | 112 |
|
113 |
/** |
|
114 |
* Wrapper around drupal_valid_token(). |
|
115 |
* |
|
116 |
* @param string $token |
|
117 |
* The token to validate. |
|
118 |
* @param array $params |
|
119 |
* Additional params to generate the token key. |
|
120 |
* - field_name: (required) Name of field the token has been generated for. |
|
121 |
* |
|
122 |
* @return bool |
|
123 |
* TRUE if the token is valid, FALSE otherwise. |
|
124 |
* |
|
125 |
* @see drupal_valid_token() |
|
126 |
*/ |
|
127 |
function shs_json_valid_token($token, array $params) { |
|
128 |
if (empty($params['field_name'])) { |
|
129 |
$t_args = array( |
|
130 |
'%param' => 'field_name', |
|
131 |
'%function' => 'shs_json_valid_token', |
|
132 |
); |
|
133 |
watchdog('shs', 'Missing mandantory token parameter "%param" in %function', $t_args, WATCHDOG_ERROR); |
|
134 |
return FALSE; |
|
135 |
} |
|
136 |
$token_key = 'shs-' . $params['field_name']; |
|
137 |
return drupal_valid_token($token, $token_key); |
|
138 |
} |
|
139 |
|
|
133 | 140 |
/** |
134 | 141 |
* Helper function to get the (validated) arguments for a JSON callback. |
135 | 142 |
* |
136 |
* @param <array> $callback
|
|
137 |
* Callback definition from campus_events_json_callbacks().
|
|
138 |
* @param <array> $arguments
|
|
143 |
* @param array $callback
|
|
144 |
* Callback definition from shs_json_callbacks().
|
|
145 |
* @param array $arguments
|
|
139 | 146 |
* Unfiltered arguments posted with $.ajax(). |
140 | 147 |
* |
141 |
* @return <array>
|
|
148 |
* @return array
|
|
142 | 149 |
* List of (validated) arguments for this callback. Any arguments not defined |
143 | 150 |
* for this callback will be removed. |
144 | 151 |
*/ |
145 |
function _shs_json_callback_get_arguments($callback, $arguments) {
|
|
152 |
function _shs_json_callback_get_arguments(array $callback, array $arguments) {
|
|
146 | 153 |
$result = array(); |
147 | 154 |
// Get arguments from callback definition. |
148 | 155 |
$callback_arguments = $callback['arguments']; |
... | ... | |
151 | 158 |
continue; |
152 | 159 |
} |
153 | 160 |
$argument_valid = TRUE; |
154 |
if ((($validation_function = $callback_arguments[$key]) !== FALSE) && function_exists($validation_function)) { |
|
161 |
if (($validation_function = $callback_arguments[$key]) === FALSE) { |
|
162 |
$argument_valid = FALSE; |
|
163 |
continue; |
|
164 |
} |
|
165 |
$validation_arguments = array(); |
|
166 |
if (is_array($validation_function)) { |
|
167 |
if (!isset($validation_function['callback'])) { |
|
168 |
$argument_valid = FALSE; |
|
169 |
watchdog('shs', 'Invalid structure for shs_json validation callback %key', array('%key' => $key), WATCHDOG_ERROR); |
|
170 |
// Stop validation right now. |
|
171 |
return $result; |
|
172 |
} |
|
173 |
foreach ($validation_function['arguments'] as $validation_argument_key => $validation_argument) { |
|
174 |
if (strpos($validation_argument, '@') === 0) { |
|
175 |
// Back-reference to callback argument. |
|
176 |
$argument_name = substr($validation_argument, 1); |
|
177 |
if (isset($arguments[$argument_name])) { |
|
178 |
$validation_arguments[$validation_argument_key] = $arguments[$argument_name]; |
|
179 |
} |
|
180 |
} |
|
181 |
else { |
|
182 |
$validation_arguments[$validation_argument_key] = $validation_argument; |
|
183 |
} |
|
184 |
} |
|
185 |
$validation_function = $validation_function['callback']; |
|
186 |
} |
|
187 |
if (function_exists($validation_function)) { |
|
155 | 188 |
// Validate argument. |
156 |
$argument_valid = $validation_function($value); |
|
189 |
if (empty($validation_arguments)) { |
|
190 |
$argument_valid = call_user_func($validation_function, $value); |
|
191 |
} |
|
192 |
else { |
|
193 |
$argument_valid = call_user_func($validation_function, $value, $validation_arguments); |
|
194 |
} |
|
157 | 195 |
} |
158 | 196 |
if ($argument_valid) { |
159 | 197 |
// Add argument and its value to the result list. |
... | ... | |
306 | 344 |
* @return array |
307 | 345 |
* Processed form structure. |
308 | 346 |
*/ |
309 |
function shs_entityreference_field_settings_process($form, $form_state) {
|
|
347 |
function shs_entityreference_field_settings_process(array $form, array $form_state) {
|
|
310 | 348 |
if (!empty($form['target_type'])) { |
311 | 349 |
// Reduce list of available target types to taxonomy terms. |
312 | 350 |
$form['target_type']['#options'] = array( |
... | ... | |
437 | 475 |
} |
438 | 476 |
|
439 | 477 |
// Check if term exists (the term could probably be deleted meanwhile). |
440 |
if ($element_value && (($term = taxonomy_term_load($element_value)) === FALSE)) {
|
|
478 |
if ($element_value && (taxonomy_term_load($element_value) === FALSE)) {
|
|
441 | 479 |
$element_value = 0; |
442 | 480 |
} |
443 | 481 |
|
... | ... | |
457 | 495 |
$options = array( |
458 | 496 |
'_none' => empty($element['#required']) ? t('- None -', array(), array('context' => 'shs')) : t('- Select a value -', array(), array('context' => 'shs')), |
459 | 497 |
); |
460 |
foreach ($referencable_entities as $v_name => $terms) {
|
|
498 |
foreach ($referencable_entities as $terms) { |
|
461 | 499 |
$options += $terms; |
462 | 500 |
} |
463 | 501 |
} |
... | ... | |
548 | 586 |
); |
549 | 587 |
} |
550 | 588 |
|
589 |
// Create token to prevent against CSRF attacks. |
|
590 |
$token = drupal_get_token('shs-' . $element['#name']); |
|
591 |
|
|
551 | 592 |
// Create settings needed for our js magic. |
552 | 593 |
$settings_js = array( |
553 | 594 |
'shs' => array( |
... | ... | |
559 | 600 |
'parents' => array_reverse($parents), |
560 | 601 |
'any_label' => empty($element['#required']) ? t('- None -', array(), array('context' => 'shs')) : t('- Select a value -', array(), array('context' => 'shs')), |
561 | 602 |
'any_value' => '_none', |
603 |
'token' => $token, |
|
562 | 604 |
), |
563 | 605 |
), |
564 | 606 |
), |
... | ... | |
631 | 673 |
foreach ($vocabulary_names as $vocabulary_name) { |
632 | 674 |
if (($vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name)) === FALSE) { |
633 | 675 |
// Vocabulary not found. Stop here. |
634 |
form_error($element, t('Vocabulary %machine_name is configured as source for field %field_name but could not be found.', array('%machine_name' => $vocabulary_name, '%field_name' => $instance['label'], '%field_machine_name' => $field_name))); |
|
676 |
$t_args = array( |
|
677 |
'%machine_name' => $vocabulary_name, |
|
678 |
'%field_name' => $instance['label'], |
|
679 |
'%field_machine_name' => $field_name, |
|
680 |
); |
|
681 |
form_error($element, t('Vocabulary %machine_name is configured as source for field %field_name but could not be found.', $t_args)); |
|
635 | 682 |
return; |
636 | 683 |
} |
637 | 684 |
// Does the selected term has any children? |
... | ... | |
784 | 831 |
* [$parent] => array(), |
785 | 832 |
* </code> |
786 | 833 |
* |
787 |
* @param <mixed> $identifier
|
|
834 |
* @param mixed $identifier
|
|
788 | 835 |
* Either a vocabulary ID or an array with the following keys: |
789 | 836 |
* - field_name: Name of field which sends the request. |
790 |
* @param <int> $parent
|
|
837 |
* @param int $parent
|
|
791 | 838 |
* ID of parent term. |
792 |
* @param <array> $settings
|
|
839 |
* @param array $settings
|
|
793 | 840 |
* Additional settings (for example "language", etc.,). |
794 |
* @param <boolean> $reset
|
|
841 |
* @param bool $reset
|
|
795 | 842 |
* If TRUE, rebuild the cache for the given $vid and $parent. |
796 | 843 |
* |
797 |
* @return <array>
|
|
844 |
* @return array
|
|
798 | 845 |
* List of child terms keyed by term id. |
799 | 846 |
*/ |
800 |
function shs_term_get_children($identifier, $parent = 0, $settings = array(), $reset = FALSE) { |
|
847 |
function shs_term_get_children($identifier, $parent = 0, array $settings = array(), $reset = FALSE) {
|
|
801 | 848 |
global $language; |
802 | 849 |
$langcode = $language->language; |
803 | 850 |
if (empty($settings['language']->language)) { |
... | ... | |
851 | 898 |
} |
852 | 899 |
} |
853 | 900 |
|
854 |
foreach ($vocabularies as $name => $vid) {
|
|
901 |
foreach ($vocabularies as $vid) { |
|
855 | 902 |
// Get term children (only first level). |
856 | 903 |
// Only load entities if i18n_taxonomy or entity_translation is |
857 | 904 |
// installed. |
... | ... | |
862 | 909 |
if (module_exists('i18n_taxonomy')) { |
863 | 910 |
$term_name = i18n_taxonomy_term_name($term, $langcode); |
864 | 911 |
} |
865 |
else if (module_exists('entity_translation')) {
|
|
912 |
elseif (module_exists('entity_translation')) { |
|
866 | 913 |
$term_name = entity_label('taxonomy_term', $term); |
867 | 914 |
} |
868 | 915 |
$terms[$vocabulary_cache_key][$langcode][$parent][$term->tid] = $term_name; |
... | ... | |
904 | 951 |
* |
905 | 952 |
* @see shs_term_get_children() |
906 | 953 |
*/ |
907 |
function shs_json_term_get_children($vid, $parent = array(), $settings = array(), $field = NULL) {
|
|
954 |
function shs_json_term_get_children($vid, array $parent = array(), array $settings = array(), $field = NULL) {
|
|
908 | 955 |
$scope = $result = array(); |
909 | 956 |
foreach ($parent as $tid) { |
910 | 957 |
$scope[] = shs_term_get_children($vid, $tid, $settings); |
... | ... | |
975 | 1022 |
/** |
976 | 1023 |
* Adds a term with ajax. |
977 | 1024 |
* |
1025 |
* @param string $token |
|
1026 |
* Custom validation token. |
|
978 | 1027 |
* @param int $vid |
979 | 1028 |
* ID of vocabulary to create the term in. |
980 | 1029 |
* @param int $parent |
... | ... | |
987 | 1036 |
* @return mixed |
988 | 1037 |
* Array with tid and name or FALSE on error. |
989 | 1038 |
*/ |
990 |
function shs_json_term_add($vid, $parent, $term_name, $field = NULL) { |
|
1039 |
function shs_json_term_add($token, $vid, $parent, $term_name, $field = NULL) {
|
|
991 | 1040 |
global $language_content; |
1041 |
if (empty($token)) { |
|
1042 |
return FALSE; |
|
1043 |
} |
|
1044 |
if (!is_numeric($vid)) { |
|
1045 |
return FALSE; |
|
1046 |
} |
|
992 | 1047 |
if (!shs_add_term_access($vid, $parent, $field)) { |
993 | 1048 |
// Sorry, but this user may not add a term to this vocabulary. |
994 | 1049 |
return FALSE; |
995 | 1050 |
} |
996 | 1051 |
|
997 | 1052 |
$term = (object) array( |
998 |
'vid' => $vid,
|
|
999 |
'parent' => $parent,
|
|
1000 |
'name' => str_replace('&', '&', filter_xss($term_name)),
|
|
1001 |
'language' => $language_content->language,
|
|
1053 |
'vid' => $vid, |
|
1054 |
'parent' => $parent, |
|
1055 |
'name' => str_replace('&', '&', filter_xss($term_name)), |
|
1056 |
'language' => $language_content->language, |
|
1002 | 1057 |
); |
1003 | 1058 |
// Save term. |
1004 | 1059 |
$status = taxonomy_term_save($term); |
... | ... | |
1068 | 1123 |
/** |
1069 | 1124 |
* Helper function to get all instances of widgets with type "taxonomy_shs". |
1070 | 1125 |
* |
1071 |
* @param <string> $entity_type
|
|
1126 |
* @param string $entity_type
|
|
1072 | 1127 |
* Name of entity type. |
1073 |
* @param <string> $bundle
|
|
1128 |
* @param string $bundle
|
|
1074 | 1129 |
* Name of bundle (optional). |
1075 | 1130 |
* |
1076 |
* @return <array>
|
|
1131 |
* @return array
|
|
1077 | 1132 |
* List of instances keyed by field name. |
1078 | 1133 |
*/ |
1079 | 1134 |
function _shs_get_instances($entity_type, $bundle = NULL) { |
... | ... | |
1102 | 1157 |
/** |
1103 | 1158 |
* Helper function to create a pseudo hash needed for javascript settings. |
1104 | 1159 |
* |
1105 |
* @param <int> $length
|
|
1160 |
* @param int $length
|
|
1106 | 1161 |
* Lenght of string to return. |
1107 | 1162 |
* |
1108 |
* @return <string>
|
|
1163 |
* @return string
|
|
1109 | 1164 |
* Random string. |
1110 | 1165 |
* |
1111 | 1166 |
* @see DrupalTestCase::randomName() |
... | ... | |
1127 | 1182 |
* Either a vocabulary ID or an array with the following keys: |
1128 | 1183 |
* - field_name: Name of field which sends the request. |
1129 | 1184 |
* |
1130 |
* @return boolean
|
|
1185 |
* @return bool |
|
1131 | 1186 |
* TRUE if validation passes, otherwise FALSE. |
1132 | 1187 |
*/ |
1133 | 1188 |
function shs_json_validation_vocabulary_identifier($identifier) { |
... | ... | |
1135 | 1190 |
} |
1136 | 1191 |
|
1137 | 1192 |
/** |
1138 |
* Helper function to get the vocabularies used as filter in entityreference |
|
1139 |
* views. |
|
1193 |
* Helper function to get the vocabularies used in entityreference views. |
|
1140 | 1194 |
* |
1141 | 1195 |
* @param string $view_name |
1142 | 1196 |
* Name of view. |
1143 | 1197 |
* @param string $display_id |
1144 | 1198 |
* Name of display. |
1145 | 1199 |
* |
1146 |
* return string[] |
|
1200 |
* return string[]
|
|
1147 | 1201 |
* List of vocabulary identifiers. |
1148 | 1202 |
*/ |
1149 | 1203 |
function _shs_entityreference_views_get_vocabularies($view_name, $display_id) { |
drupal7/sites/all/modules/views/handlers/views_handler_argument_null.inc | ||
---|---|---|
44 | 44 |
*/ |
45 | 45 |
public function default_actions($which = NULL) { |
46 | 46 |
if ($which) { |
47 |
if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) { |
|
47 |
if (in_array($which, array('ignore', 'not found', 'empty', 'default', 'access denied'))) {
|
|
48 | 48 |
return parent::default_actions($which); |
49 | 49 |
} |
50 | 50 |
return; |
drupal7/sites/all/modules/views/handlers/views_handler_field_serialized.inc | ||
---|---|---|
71 | 71 |
return check_plain($value[$this->options['key']]); |
72 | 72 |
} |
73 | 73 |
|
74 |
return $value;
|
|
74 |
return check_plain($value);
|
|
75 | 75 |
} |
76 | 76 |
|
77 | 77 |
} |
drupal7/sites/all/modules/views/includes/handlers.inc | ||
---|---|---|
996 | 996 |
return $this->handler->table_alias; |
997 | 997 |
} |
998 | 998 |
|
999 |
// Case 2: it's an 'and' or an 'or'.
|
|
999 |
// Case 2: it's anything but an 'or'.
|
|
1000 | 1000 |
// We do one join per selected value. |
1001 |
if ($this->handler->operator != 'not') { |
|
1002 |
// Clone the join for each table. |
|
1003 |
$this->handler->table_aliases = array(); |
|
1004 |
foreach ($this->handler->value as $value) { |
|
1005 |
$join = $this->get_join(); |
|
1006 |
if ($this->handler->operator == 'and') { |
|
1007 |
$join->type = 'INNER'; |
|
1008 |
} |
|
1009 |
$join->extra = array( |
|
1010 |
array( |
|
1011 |
'field' => $this->handler->real_field, |
|
1012 |
'value' => $value, |
|
1013 |
'numeric' => !empty($this->handler->definition['numeric']), |
|
1014 |
), |
|
1015 |
); |
|
1016 | 1001 |
|
1017 |
// The table alias needs to be unique to this value across the |
|
1018 |
// multiple times the filter or argument is called by the view. |
|
1019 |
if (!isset($this->handler->view->many_to_one_aliases[$field][$value])) { |
|
1020 |
if (!isset($this->handler->view->many_to_one_count[$this->handler->table])) { |
|
1021 |
$this->handler->view->many_to_one_count[$this->handler->table] = 0; |
|
1022 |
} |
|
1023 |
$this->handler->view->many_to_one_aliases[$field][$value] = $this->handler->table . '_value_' . ($this->handler->view->many_to_one_count[$this->handler->table]++); |
|
1002 |
// Clone the join for each table: |
|
1003 |
$this->handler->table_aliases = []; |
|
1004 |
foreach ($this->handler->value as $value) { |
|
1005 |
$join = $this->get_join(); |
|
1006 |
if ($this->handler->operator == 'and') { |
|
1007 |
$join->type = 'INNER'; |
|
1008 |
} |
|
1009 |
if (empty($join->extra)) { |
|
1010 |
$join->extra = []; |
|
1011 |
} |
|
1012 |
$join->extra[] = [ |
|
1013 |
'field' => $this->handler->real_field, |
|
1014 |
'value' => $value, |
|
1015 |
'numeric' => !empty($this->handler->definition['numeric']), |
|
1016 |
]; |
|
1017 |
// The table alias needs to be unique to this value across the |
|
1018 |
// multiple times the filter or argument is called by the view. |
|
1019 |
if (!isset($this->handler->view->many_to_one_aliases[$field][$value])) { |
|
1020 |
if (!isset($this->handler->view->many_to_one_count[$this->handler->table])) { |
|
1021 |
$this->handler->view->many_to_one_count[$this->handler->table] = 0; |
|
1024 | 1022 |
} |
1025 |
$alias = $this->handler->table_aliases[$value] = $this->add_table($join, $this->handler->view->many_to_one_aliases[$field][$value]); |
|
1026 |
|
|
1023 |
$this->handler->view->many_to_one_aliases[$field][$value] = $this->handler->table . '_value_' . ($this->handler->view->many_to_one_count[$this->handler->table]++); |
|
1024 |
$alias = $this->handler->table_aliases[$value] = $this->add_table($join, |
|
1025 |
$this->handler->view->many_to_one_aliases[$field][$value]); |
|
1027 | 1026 |
// and set table_alias to the first of these. |
1028 | 1027 |
if (empty($this->handler->table_alias)) { |
1029 | 1028 |
$this->handler->table_alias = $alias; |
1030 | 1029 |
} |
1031 | 1030 |
} |
1032 | 1031 |
} |
1033 |
// Case 3: it's a 'not'. |
|
1034 |
// We just do one join. We'll add a where clause during the query phase |
|
1035 |
// to ensure that $table.$field IS NULL. |
|
1036 |
else { |
|
1037 |
$join = $this->get_join(); |
|
1038 |
$join->type = 'LEFT'; |
|
1039 |
$join->extra = array(); |
|
1040 |
$join->extra_type = 'OR'; |
|
1041 |
foreach ($this->handler->value as $value) { |
|
1042 |
$join->extra[] = array( |
|
1043 |
'field' => $this->handler->real_field, |
|
1044 |
'value' => $value, |
|
1045 |
'numeric' => !empty($this->handler->definition['numeric']), |
|
1046 |
); |
|
1047 |
} |
|
1048 |
|
|
1049 |
$this->handler->table_alias = $this->add_table($join); |
|
1050 |
} |
|
1051 | 1032 |
} |
1052 | 1033 |
return $this->handler->table_alias; |
1053 | 1034 |
} |
... | ... | |
1081 | 1062 |
// Determine whether a single expression is enough(FALSE) or the conditions |
1082 | 1063 |
// should be added via an db_or()/db_and() (TRUE). |
1083 | 1064 |
$add_condition = TRUE; |
1084 |
if ($operator == 'not') { |
|
1085 |
$value = NULL; |
|
1086 |
$operator = 'IS NULL'; |
|
1087 |
$add_condition = FALSE; |
|
1088 |
} |
|
1089 |
elseif ($operator == 'or' && empty($options['reduce_duplicates'])) { |
|
1065 |
if ($operator == 'or' && empty($options['reduce_duplicates'])) { |
|
1090 | 1066 |
if (count($value) > 1) { |
1091 | 1067 |
$operator = 'IN'; |
1092 | 1068 |
} |
... | ... | |
1120 | 1096 |
$field = $this->handler->real_field; |
1121 | 1097 |
$clause = $operator == 'or' ? db_or() : db_and(); |
1122 | 1098 |
foreach ($this->handler->table_aliases as $value => $alias) { |
1099 |
if ($operator == 'not') { |
|
1100 |
$value = NULL; |
|
1101 |
} |
|
1123 | 1102 |
$clause->condition("$alias.$field", $value); |
1124 | 1103 |
} |
1125 | 1104 |
|
drupal7/sites/all/modules/views/includes/view.inc | ||
---|---|---|
1236 | 1236 |
if (!empty($this->build_info['fail'])) { |
1237 | 1237 |
return; |
1238 | 1238 |
} |
1239 |
if (!empty($this->view->build_info['denied'])) {
|
|
1239 |
if (!empty($this->build_info['denied'])) { |
|
1240 | 1240 |
return; |
1241 | 1241 |
} |
1242 | 1242 |
|
drupal7/sites/all/modules/views/plugins/views_plugin_display_feed.inc | ||
---|---|---|
51 | 51 |
*/ |
52 | 52 |
public function execute() { |
53 | 53 |
$output = $this->view->render(); |
54 |
if (!empty($this->view->build_info['denied'])) { |
|
55 |
return MENU_ACCESS_DENIED; |
|
56 |
} |
|
54 | 57 |
if (empty($output)) { |
55 | 58 |
return MENU_NOT_FOUND; |
56 | 59 |
} |
drupal7/sites/all/modules/views/tests/views_argument_validator.test | ||
---|---|---|
40 | 40 |
$this->assertTrue($view->argument['null']->validate_arg(12)); |
41 | 41 |
} |
42 | 42 |
|
43 |
/** |
|
44 |
* Make sure argument validation works properly. |
|
45 |
*/ |
|
46 |
function testArgumentValidatePhpFailure() { |
|
47 |
$view = $this->view_test_argument_validate_php_failure(); |
|
48 |
$view->save(); |
|
49 |
$this->drupalGet('test-php-failure'); |
|
50 |
|
|
51 |
// This should return a 403, indicating that the arguments validation fails. |
|
52 |
$this->assertResponse(403); |
|
53 |
|
|
54 |
$this->drupalGet('test-php-failure-feed'); |
|
55 |
|
|
56 |
// This should return a 403, indicating that the arguments validation fails. |
|
57 |
$this->assertResponse(403); |
|
58 |
} |
|
59 |
|
|
43 | 60 |
function view_test_argument_validate_php($string) { |
44 | 61 |
$code = 'return $argument == \'' . $string . '\';'; |
45 | 62 |
$view = new view(); |
46 |
$view->name = 'view_argument_validate_numeric';
|
|
63 |
$view->name = 'view_argument_validate_php';
|
|
47 | 64 |
$view->description = ''; |
48 | 65 |
$view->tag = ''; |
49 | 66 |
$view->view_php = ''; |
... | ... | |
104 | 121 |
return $view; |
105 | 122 |
} |
106 | 123 |
|
124 |
/** |
|
125 |
* |
|
126 |
* |
|
127 |
* @return view $view |
|
128 |
* The required view object. |
|
129 |
*/ |
|
130 |
function view_test_argument_validate_php_failure() { |
|
131 |
$view = new view(); |
|
132 |
$view->name = 'view_argument_validate_php_failure'; |
|
133 |
$view->description = ''; |
|
134 |
$view->tag = ''; |
|
135 |
$view->base_table = 'node'; |
|
136 |
$view->human_name = ''; |
|
137 |
$view->core = 0; |
|
138 |
$view->api_version = '3.0'; |
|
139 |
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ |
|
140 |
|
|
141 |
/* Display: Master */ |
|
142 |
$handler = $view->new_display('default', 'Master', 'default'); |
|
143 |
$handler->display->display_options['use_more_always'] = FALSE; |
|
144 |
$handler->display->display_options['access']['type'] = 'none'; |
|
145 |
$handler->display->display_options['cache']['type'] = 'none'; |
|
146 |
$handler->display->display_options['query']['type'] = 'views_query'; |
|
147 |
$handler->display->display_options['exposed_form']['type'] = 'basic'; |
|
148 |
$handler->display->display_options['pager']['type'] = 'none'; |
|
149 |
$handler->display->display_options['style_plugin'] = 'default'; |
|
150 |
$handler->display->display_options['row_plugin'] = 'fields'; |
|
151 |
/* Field: Content: Title */ |
|
152 |
$handler->display->display_options['fields']['title']['id'] = 'title'; |
|
153 |
$handler->display->display_options['fields']['title']['table'] = 'node'; |
|
154 |
$handler->display->display_options['fields']['title']['field'] = 'title'; |
|
155 |
$handler->display->display_options['fields']['title']['label'] = ''; |
|
156 |
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE; |
|
157 |
$handler->display->display_options['fields']['title']['link_to_node'] = FALSE; |
|
158 |
/* Contextual filter: Global: Null */ |
|
159 |
$handler->display->display_options['arguments']['null']['id'] = 'null'; |
|
160 |
$handler->display->display_options['arguments']['null']['table'] = 'views'; |
|
161 |
$handler->display->display_options['arguments']['null']['field'] = 'null'; |
|
162 |
$handler->display->display_options['arguments']['null']['default_action'] = 'default'; |
|
163 |
$handler->display->display_options['arguments']['null']['default_argument_type'] = 'fixed'; |
|
164 |
$handler->display->display_options['arguments']['null']['default_argument_options']['argument'] = 'No filter'; |
|
165 |
$handler->display->display_options['arguments']['null']['summary']['number_of_records'] = '0'; |
|
166 |
$handler->display->display_options['arguments']['null']['summary']['format'] = 'default_summary'; |
|
167 |
$handler->display->display_options['arguments']['null']['summary_options']['items_per_page'] = '25'; |
|
168 |
$handler->display->display_options['arguments']['null']['specify_validation'] = TRUE; |
|
169 |
$handler->display->display_options['arguments']['null']['validate']['type'] = 'php'; |
|
170 |
$handler->display->display_options['arguments']['null']['validate_options']['code'] = 'return FALSE;'; |
|
171 |
$handler->display->display_options['arguments']['null']['validate']['fail'] = 'access denied'; |
|
172 |
|
|
173 |
/* Display: Page */ |
|
174 |
$handler = $view->new_display('page', 'Page', 'page_1'); |
|
175 |
$handler->display->display_options['path'] = 'test-php-failure'; |
|
176 |
|
|
177 |
/* Display: Feed */ |
|
178 |
$handler = $view->new_display('feed', 'Feed', 'feed_1'); |
|
179 |
$handler->display->display_options['path'] = 'test-php-failure-feed'; |
|
180 |
$handler->display->display_options['pager']['type'] = 'none'; |
|
181 |
$handler->display->display_options['pager']['options']['offset'] = '0'; |
|
182 |
$handler->display->display_options['style_plugin'] = 'rss'; |
|
183 |
$handler->display->display_options['row_plugin'] = 'node_rss'; |
|
184 |
|
|
185 |
return $view; |
|
186 |
} |
|
187 |
|
|
107 | 188 |
} |
drupal7/sites/all/modules/views/tests/views_handler_filter.test | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* Definition of ViewsHandlerFilterTest. |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* Tests filter handler. |
|
10 |
*/ |
|
11 |
class ViewsHandlerFilterTest extends ViewsSqlTest { |
|
12 |
|
|
13 |
/** |
|
14 |
* {@inheritdoc} |
|
15 |
*/ |
|
16 |
public static function getInfo() { |
|
17 |
return array( |
|
18 |
'name' => 'Handler filter test', |
|
19 |
'description' => 'test filter handler definitions', |
|
20 |
'group' => 'Views', |
|
21 |
); |
|
22 |
} |
|
23 |
|
|
24 |
/** |
|
25 |
* {@inheritdoc} |
|
26 |
*/ |
|
27 |
protected function setUp() { |
|
28 |
// The Views and Views UI modules will be enabled with this. |
|
29 |
parent::setUp(); |
|
30 |
|
|
31 |
// Assign vocabulary 'tag' to user entity. |
|
32 |
$field_definition = field_read_field('field_tags'); |
|
33 |
$instance_definition = array( |
|
34 |
'field_name' => $field_definition['field_name'], |
|
35 |
'entity_type' => 'user', |
|
36 |
'bundle' => 'user', |
|
37 |
'widget' => array( |
|
38 |
'type' => 'taxonomy_autocomplete', |
|
39 |
), |
|
40 |
'display' => array( |
|
41 |
'default' => array( |
|
42 |
'type' => 'taxonomy_term_reference_link', |
|
43 |
'weight' => 10, |
|
44 |
), |
|
45 |
'teaser' => array( |
|
46 |
'type' => 'taxonomy_term_reference_link', |
|
47 |
'weight' => 10, |
|
48 |
), |
|
49 |
), |
|
50 |
); |
|
51 |
field_create_instance($instance_definition); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Tests "is all of" of filter operation. |
|
56 |
*/ |
|
57 |
function testFilterInOperatorUi() { |
|
58 |
$term = $this->drupalCreateTerm(1); |
|
59 |
|
|
60 |
$node1 = $this->drupalCreateNode(array('type' => 'article','field_tags_tid' => $term->tid, 'created' => REQUEST_TIME)); |
|
61 |
$node2 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 1)); |
|
62 |
$user2 = $this->drupalCreateUser(array('access content')); |
|
63 |
// $this->drupalLogin($this->drupalCreateUser(['administer users']); |
|
64 |
$this->drupalLogin($this->drupalCreateUser(['administer users', 'access administration pages', 'administer site configuration', 'administer nodes', 'bypass node access'])); |
|
65 |
|
|
66 |
$this->drupalGet('node/1/edit'); |
|
67 |
$edit['field_tags' . '[' . LANGUAGE_NONE . ']'] = $term->name; |
|
68 |
$this->drupalPost('node/' . $node1->nid . '/edit', $edit, t('Save')); |
|
69 |
|
|
70 |
$edit['field_tags' . '[' . LANGUAGE_NONE . ']'] = $term->name; |
|
71 |
$this->drupalPost('user/' . $user2->uid . '/edit', $edit, t('Save')); |
|
72 |
|
|
73 |
$result[] = array('nid' => $node1->nid); |
|
74 |
$view = $this->get_sample_view(); |
|
75 |
$this->executeView($view); |
|
76 |
$this->assertIdenticalResultset($view, $result); |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Sample view. |
|
81 |
* |
|
82 |
* @return \view |
|
83 |
*/ |
|
84 |
protected function get_sample_view() { |
|
85 |
$view = new view(); |
|
86 |
$view->name = 'article'; |
|
87 |
$view->description = ''; |
|
88 |
$view->tag = 'default'; |
|
89 |
$view->base_table = 'node'; |
|
90 |
$view->human_name = 'Article'; |
|
91 |
$view->core = 7; |
|
92 |
$view->api_version = '3.0'; |
|
93 |
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ |
|
94 |
|
|
95 |
/* Display: Master */ |
|
96 |
$handler = $view->new_display('default', 'Master', 'default'); |
|
97 |
$handler->display->display_options['title'] = 'Article'; |
|
98 |
$handler->display->display_options['use_more_always'] = FALSE; |
|
99 |
$handler->display->display_options['access']['type'] = 'perm'; |
|
100 |
$handler->display->display_options['cache']['type'] = 'none'; |
|
101 |
$handler->display->display_options['query']['type'] = 'views_query'; |
|
102 |
$handler->display->display_options['exposed_form']['type'] = 'basic'; |
|
103 |
$handler->display->display_options['pager']['type'] = 'full'; |
|
104 |
$handler->display->display_options['pager']['options']['items_per_page'] = '10'; |
|
105 |
$handler->display->display_options['style_plugin'] = 'table'; |
|
106 |
$handler->display->display_options['style_options']['columns'] = array( |
|
107 |
'title' => 'title', |
|
108 |
); |
|
109 |
$handler->display->display_options['style_options']['default'] = '-1'; |
|
110 |
$handler->display->display_options['style_options']['info'] = array( |
|
111 |
'title' => array( |
|
112 |
'sortable' => 0, |
|
113 |
'default_sort_order' => 'asc', |
|
114 |
'align' => '', |
|
115 |
'separator' => '', |
|
116 |
'empty_column' => 0, |
|
117 |
), |
|
118 |
); |
|
119 |
/* Field: Content: Nid */ |
|
120 |
$handler->display->display_options['fields']['nid']['id'] = 'nid'; |
|
121 |
$handler->display->display_options['fields']['nid']['table'] = 'node'; |
|
122 |
$handler->display->display_options['fields']['nid']['field'] = 'nid'; |
|
123 |
$handler->display->display_options['fields']['nid']['label'] = ''; |
|
124 |
$handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE; |
|
125 |
/* Sort criterion: Content: Post date */ |
|
126 |
$handler->display->display_options['sorts']['created']['id'] = 'created'; |
|
127 |
$handler->display->display_options['sorts']['created']['table'] = 'node'; |
|
128 |
$handler->display->display_options['sorts']['created']['field'] = 'created'; |
|
129 |
$handler->display->display_options['sorts']['created']['order'] = 'DESC'; |
|
130 |
/* Filter criterion: Content: Published */ |
|
131 |
$handler->display->display_options['filters']['status']['id'] = 'status'; |
|
132 |
$handler->display->display_options['filters']['status']['table'] = 'node'; |
|
133 |
$handler->display->display_options['filters']['status']['field'] = 'status'; |
|
134 |
$handler->display->display_options['filters']['status']['value'] = 1; |
|
135 |
$handler->display->display_options['filters']['status']['group'] = 1; |
|
136 |
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; |
|
137 |
/* Filter criterion: Field: Tags (field_tags) */ |
|
138 |
$handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid'; |
|
139 |
$handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags'; |
|
140 |
$handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid'; |
|
141 |
$handler->display->display_options['filters']['field_tags_tid']['operator'] = 'and'; |
|
142 |
$handler->display->display_options['filters']['field_tags_tid']['value'] = array( |
|
143 |
0 => '1', |
|
144 |
); |
|
145 |
$handler->display->display_options['filters']['field_tags_tid']['expose']['operator_id'] = 'field_tags_tid_op'; |
|
146 |
$handler->display->display_options['filters']['field_tags_tid']['expose']['label'] = 'Tags (field_tags)'; |
|
147 |
$handler->display->display_options['filters']['field_tags_tid']['expose']['operator'] = 'field_tags_tid_op'; |
|
148 |
$handler->display->display_options['filters']['field_tags_tid']['expose']['identifier'] = 'field_tags_tid'; |
|
149 |
$handler->display->display_options['filters']['field_tags_tid']['expose']['remember_roles'] = array( |
|
150 |
2 => '2', |
|
151 |
); |
|
152 |
$handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags'; |
|
153 |
|
|
154 |
/* Display: Page */ |
|
155 |
$handler = $view->new_display('page', 'Page', 'page'); |
|
156 |
$handler->display->display_options['path'] = 'article'; |
|
157 |
|
|
158 |
return $view; |
|
159 |
} |
|
160 |
|
|
161 |
} |
drupal7/sites/all/modules/views/tests/views_query.test | ||
---|---|---|
135 | 135 |
$this->verbose('<pre>Executed view: ' . ((string) $view->build_info['query']) . '</pre>'); |
136 | 136 |
} |
137 | 137 |
|
138 |
/** |
|
139 |
* Log in as user 1. |
|
140 |
*/ |
|
141 |
protected function loginUser1() { |
|
142 |
$password = user_password(); |
|
143 |
// Reset the user 1 password. |
|
144 |
$account = user_load(1); |
|
145 |
$edit = array( |
|
146 |
'pass' => $password, |
|
147 |
); |
|
148 |
$account = user_save($account, $edit); |
|
149 |
$account->pass_raw = $password; |
|
150 |
|
|
151 |
// Log in as user 1. |
|
152 |
$this->drupalLogin($account); |
|
153 |
} |
|
154 |
|
|
138 | 155 |
} |
139 | 156 |
|
140 | 157 |
/** |
... | ... | |
167 | 184 |
$this->checkPermissions(array(), TRUE); |
168 | 185 |
} |
169 | 186 |
|
187 |
/** |
|
188 |
* Create a term. |
|
189 |
* |
|
190 |
* @param int $vid |
|
191 |
* The vocabulary ID that the term is to be added to. |
|
192 |
* |
|
193 |
* @return object |
|
194 |
* A full term object with a random name. |
|
195 |
*/ |
|
196 |
protected function drupalCreateTerm($vid) { |
|
197 |
$term = new stdClass(); |
|
198 |
$term->name = $this->randomName(); |
|
199 |
$term->description = $this->randomName(); |
|
200 |
$term->vid = $vid; |
|
201 |
taxonomy_term_save($term); |
|
202 |
return $term; |
|
203 |
} |
|
204 |
|
|
170 | 205 |
/** |
171 | 206 |
* This function allows to enable views ui from a higher class which can't |
172 | 207 |
* change the setup function anymore. |
drupal7/sites/all/modules/views/tests/views_test.info | ||
---|---|---|
5 | 5 |
dependencies[] = views |
6 | 6 |
hidden = TRUE |
7 | 7 |
|
8 |
; Information added by Drupal.org packaging script on 2018-04-14
|
|
9 |
version = "7.x-3.20"
|
|
8 |
; Information added by Drupal.org packaging script on 2019-03-13
|
|
9 |
version = "7.x-3.21"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "views" |
12 |
datestamp = "1523668093" |
|
12 |
datestamp = "1552486703" |
drupal7/sites/all/modules/views/views.info | ||
---|---|---|
308 | 308 |
files[] = tests/field/views_fieldapi.test |
309 | 309 |
files[] = tests/views_glossary.test |
310 | 310 |
files[] = tests/views_groupby.test |
311 |
files[] = tests/views_handler_filter.test |
|
311 | 312 |
files[] = tests/views_handlers.test |
312 | 313 |
files[] = tests/views_module.test |
313 | 314 |
files[] = tests/views_pager.test |
... | ... | |
328 | 329 |
files[] = tests/views_view.test |
329 | 330 |
files[] = tests/views_ui.test |
330 | 331 |
|
331 |
; Information added by Drupal.org packaging script on 2018-04-14
|
|
332 |
version = "7.x-3.20"
|
|
332 |
; Information added by Drupal.org packaging script on 2019-03-13
|
|
333 |
version = "7.x-3.21"
|
|
333 | 334 |
core = "7.x" |
334 | 335 |
project = "views" |
335 |
datestamp = "1523668093" |
|
336 |
datestamp = "1552486703" |
drupal7/sites/all/modules/views/views_ui.info | ||
---|---|---|
8 | 8 |
files[] = views_ui.module |
9 | 9 |
files[] = plugins/views_wizard/views_ui_base_views_wizard.class.php |
10 | 10 |
|
11 |
; Information added by Drupal.org packaging script on 2018-04-14
|
|
12 |
version = "7.x-3.20"
|
|
11 |
; Information added by Drupal.org packaging script on 2019-03-13
|
|
12 |
version = "7.x-3.21"
|
|
13 | 13 |
core = "7.x" |
14 | 14 |
project = "views" |
15 |
datestamp = "1523668093" |
|
15 |
datestamp = "1552486703" |
Formats disponibles : Unified diff
Weekly update of contrib modules