Révision 211d6cee
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/file_entity/file_entity.file.inc | ||
---|---|---|
197 | 197 |
/** |
198 | 198 |
* Implements hook_entitycache_ENTITY_TYPE_load(). |
199 | 199 |
*/ |
200 |
function file_entitycache_file_load($files) { |
|
200 |
function file_entity_entitycache_file_load($files) {
|
|
201 | 201 |
// Integrates with entitycache - ensures the alt and title text on images is |
202 | 202 |
// localized. |
203 | 203 |
file_entity_set_title_alt_properties($files); |
... | ... | |
210 | 210 |
file_entity_set_title_alt_properties_on_file_fields($entities, $entity_type); |
211 | 211 |
} |
212 | 212 |
|
213 |
/** |
|
214 |
* Implements hook_entitycache_load(). |
|
215 |
*/ |
|
216 |
function file_entity_entitycache_load($entities, $entity_type) { |
|
217 |
file_entity_set_title_alt_properties_on_file_fields($entities, $entity_type); |
|
218 |
} |
|
219 |
|
|
220 | 213 |
/** |
221 | 214 |
* Sets the title / alt properties on file fields attached to entities. |
222 | 215 |
* |
drupal7/sites/all/modules/file_entity/file_entity.info | ||
---|---|---|
32 | 32 |
; We have to add a fake version so Git checkouts do not fail Media dependencies |
33 | 33 |
version = 7.x-2.x-dev |
34 | 34 |
|
35 |
; Information added by Drupal.org packaging script on 2018-04-11
|
|
36 |
version = "7.x-2.20"
|
|
35 |
; Information added by Drupal.org packaging script on 2018-05-02
|
|
36 |
version = "7.x-2.21"
|
|
37 | 37 |
core = "7.x" |
38 | 38 |
project = "file_entity" |
39 |
datestamp = "1523461700" |
|
39 |
datestamp = "1525293788" |
drupal7/sites/all/modules/file_entity/file_entity.tokens.inc | ||
---|---|---|
284 | 284 |
* Either a single value, the first of the array, or an array of values. |
285 | 285 |
*/ |
286 | 286 |
function _file_entity_tokens_get_property($files, $property, $array_handler = 'first') { |
287 |
|
|
287 |
$value = NULL; |
|
288 | 288 |
// If we only need the first variable |
289 | 289 |
$return_first = ($array_handler == 'first' || empty($array_handler) || $array_handler == 'value:0'); |
290 | 290 |
|
... | ... | |
302 | 302 |
|
303 | 303 |
// If values are: image, height, width, https-image |
304 | 304 |
elseif (!empty($info[$file['fid']])) { |
305 |
$value = isset($info[$file['fid']][$property]) ?: NULL; |
|
305 |
if (isset($info[$file['fid']][$property])) { |
|
306 |
$value = $info[$file['fid']][$property]; |
|
307 |
} else { |
|
308 |
$value = NULL; |
|
309 |
} |
|
306 | 310 |
} |
307 | 311 |
// If values are files types |
308 | 312 |
else { |
... | ... | |
329 | 333 |
$info[$file['fid']]['https-image'] = str_replace('http://', 'https://', $info[$file['fid']]['image']); |
330 | 334 |
} |
331 | 335 |
|
332 |
$value = isset($info[$file['fid']][$property]) ?: NULL; |
|
336 |
if (isset($info[$file['fid']][$property])) { |
|
337 |
$value = $info[$file['fid']][$property]; |
|
338 |
} else { |
|
339 |
$value = NULL; |
|
340 |
} |
|
333 | 341 |
} |
334 | 342 |
|
335 | 343 |
if ($return_first) { |
drupal7/sites/all/modules/file_entity/tests/file_entity_test.info | ||
---|---|---|
5 | 5 |
dependencies[] = file_entity |
6 | 6 |
hidden = TRUE |
7 | 7 |
|
8 |
; Information added by Drupal.org packaging script on 2018-04-11
|
|
9 |
version = "7.x-2.20"
|
|
8 |
; Information added by Drupal.org packaging script on 2018-05-02
|
|
9 |
version = "7.x-2.21"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "file_entity" |
12 |
datestamp = "1523461700" |
|
12 |
datestamp = "1525293788" |
drupal7/sites/all/modules/hidden_captcha/hidden_captcha.info | ||
---|---|---|
5 | 5 |
dependencies[] = captcha |
6 | 6 |
configure = admin/config/people/captcha/hidden_captcha |
7 | 7 |
|
8 |
; Information added by Drupal.org packaging script on 2017-01-23
|
|
9 |
version = "7.x-1.1"
|
|
8 |
; Information added by Drupal.org packaging script on 2018-04-27
|
|
9 |
version = "7.x-1.2"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "hidden_captcha" |
12 |
datestamp = "1485204485" |
|
13 |
|
|
12 |
datestamp = "1524848584" |
drupal7/sites/all/modules/hidden_captcha/hidden_captcha.install | ||
---|---|---|
8 | 8 |
/** |
9 | 9 |
* Implements hook_uninstall(). |
10 | 10 |
* |
11 |
* On uninstall: Remove module variables and clear variable cache.
|
|
11 |
* Remove module variables, simulating variable_del().
|
|
12 | 12 |
*/ |
13 | 13 |
function hidden_captcha_uninstall() { |
14 |
db_query("DELETE FROM {variable} WHERE name LIKE 'hidden_captcha_%%'"); |
|
14 |
global $conf; |
|
15 |
db_delete('variable') |
|
16 |
->condition('name', 'hidden\_captcha\_%', 'LIKE') |
|
17 |
->execute(); |
|
18 |
cache_clear_all('variables', 'cache_bootstrap'); |
|
19 |
foreach (array_keys($conf) as $name) { |
|
20 |
if (strpos($name, 'hidden_captcha_') === 0) { |
|
21 |
unset($conf[$name]); |
|
22 |
} |
|
23 |
} |
|
15 | 24 |
} |
drupal7/sites/all/modules/hidden_captcha/hidden_captcha.module | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* All code for the Foo Bar module, except installation-related code.
|
|
5 |
* All code for the Hidden CAPTCHA module, except installation-related code.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
... | ... | |
26 | 26 |
'page arguments' => array('hidden_captcha_settings_form'), |
27 | 27 |
'access arguments' => array('administer CAPTCHA settings'), |
28 | 28 |
'type' => MENU_LOCAL_TASK, |
29 |
'weight' => -10 |
|
29 |
'weight' => -10,
|
|
30 | 30 |
); |
31 | 31 |
return $items; |
32 | 32 |
} |
... | ... | |
39 | 39 |
$form['hidden_captcha_label'] = array( |
40 | 40 |
'#type' => 'textfield', |
41 | 41 |
'#title' => t('Hidden text field label'), |
42 |
'#description' => t( |
|
43 |
"This is the hidden captcha form field's label, describing the expected input.<br />" . |
|
44 |
"<strong>It is highly recommended to change it!</strong><br />" . |
|
45 |
"The label should be as \"machine-readable\" as possible, encouraging spambots to fill in the field. An example might be a simple math challenge.<br />" . |
|
46 |
"The label will only be visible to people who do not have CSS enabled and to robots." |
|
47 |
), |
|
42 |
'#description' => t("This is the hidden captcha form field's label, describing the expected input.<br /><strong>It is highly recommended to change it!</strong><br />The label should be as \"machine-readable\" as possible, encouraging spambots to fill in the field. An example might be a simple math challenge.<br />The label will only be visible to people who do not have CSS enabled and to robots."), |
|
48 | 43 |
'#default_value' => variable_get('hidden_captcha_label', 'Website URL'), |
49 | 44 |
); |
50 | 45 |
return system_settings_form($form); |
... | ... | |
55 | 50 |
*/ |
56 | 51 |
function hidden_captcha_captcha($op, $captcha_type = '') { |
57 | 52 |
switch ($op) { |
58 |
case 'list': return array('Hidden CAPTCHA'); |
|
53 |
case 'list': |
|
54 |
return array('Hidden CAPTCHA'); |
|
55 |
|
|
59 | 56 |
case 'generate': |
60 | 57 |
if ($captcha_type == 'Hidden CAPTCHA') { |
61 | 58 |
$captcha = array(); |
62 | 59 |
$captcha['solution'] = ''; |
60 |
|
|
61 |
// Ensure this captcha is cacheable. |
|
62 |
// @see https://www.drupal.org/project/captcha/issues/2449209 |
|
63 |
$captcha['cacheable'] = TRUE; |
|
64 |
|
|
65 |
// The CAPTCHA solution provided by hook_captcha() is updated in the |
|
66 |
// 'captcha_session' table on pre-render phase of element process. |
|
67 |
// @see captcha_pre_render_process() |
|
68 |
// @see _captcha_update_captcha_session() |
|
69 |
// However, if the cache is enabled, solution would be empty for the |
|
70 |
// first attempt of the cached form. For the next attempt, there will |
|
71 |
// not be any 'sid' in form_state |
|
72 |
// (i.e. $form_state['captcha_info']['captcha_sid'] = null). |
|
73 |
// So a new solution would get generated at captcha_element_process(). |
|
74 |
// The default 'captcha_validate' function, |
|
75 |
// captcha_validate_strict_equality(), would fail in this case. |
|
76 |
// @see captcha_validate() |
|
77 |
// Adding custom validation function to check solution is always empty. |
|
78 |
$captcha['captcha_validate'] = 'hidden_captcha_captcha_validate'; |
|
79 |
|
|
63 | 80 |
$captcha['form']['captcha_response'] = array( |
64 | 81 |
'#type' => 'textfield', |
65 | 82 |
'#title' => variable_get('hidden_captcha_label', 'Website URL'), |
... | ... | |
72 | 89 |
} |
73 | 90 |
} |
74 | 91 |
|
92 |
/** |
|
93 |
* CAPTCHA validation callback; checks that the response is empty. |
|
94 |
*/ |
|
95 |
function hidden_captcha_captcha_validate($solution, $captcha_response, $element, $form_state) { |
|
96 |
return $captcha_response === ''; |
|
97 |
} |
|
98 |
|
|
75 | 99 |
/** |
76 | 100 |
* Implements hook_theme(). |
77 | 101 |
*/ |
... | ... | |
79 | 103 |
return array( |
80 | 104 |
'captcha' => array( |
81 | 105 |
'arguments' => array('element' => NULL), |
82 |
'function' => 'theme_hidden_captcha_captcha' |
|
83 |
) |
|
106 |
'function' => 'theme_hidden_captcha_captcha',
|
|
107 |
),
|
|
84 | 108 |
); |
85 | 109 |
} |
86 | 110 |
|
... | ... | |
90 | 114 |
function theme_hidden_captcha_captcha($element) { |
91 | 115 |
$captcha = theme_captcha($element); |
92 | 116 |
if (strncmp($element["element"]["#captcha_type"], "hidden_captcha/", 15) == 0) { |
93 |
//generate a random class name
|
|
117 |
// Generate a random class name.
|
|
94 | 118 |
$chars = "abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
95 | 119 |
$class = ""; |
96 |
for ($i = 0; $i < 64; ++$i) $class .= substr($chars, rand(0, strlen($chars)-1), 1); |
|
97 |
//hide the random class via css |
|
98 |
drupal_add_css(".$class{width:0;height:0;overflow:hidden;}", "inline"); // TODO: move the random class to an external file |
|
99 |
//html for the captcha |
|
120 |
for ($i = 0; $i < 64; ++$i) { |
|
121 |
$class .= substr($chars, rand(0, strlen($chars) - 1), 1); |
|
122 |
} |
|
123 |
// Hide the random class via CSS. |
|
124 |
// @todo Move the random class to an external file. |
|
125 |
drupal_add_css(".$class{width:0;height:0;overflow:hidden;}", "inline"); |
|
126 |
// HTML for the captcha. |
|
100 | 127 |
$captcha = "<div class=\"$class\">" . $captcha . "</div>"; |
101 | 128 |
} |
102 | 129 |
return $captcha; |
Formats disponibles : Unified diff
Weekly update of contrib modules