1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Provides the Google No CAPTCHA administration settings.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Form callback; administrative settings for Google No CAPTCHA.
|
10
|
*/
|
11
|
function recaptcha_admin_settings() {
|
12
|
$form['recaptcha_general_settings'] = array(
|
13
|
'#type' => 'fieldset',
|
14
|
'#title' => t('General settings'),
|
15
|
);
|
16
|
$form['recaptcha_general_settings']['recaptcha_site_key'] = array(
|
17
|
'#type' => 'textfield',
|
18
|
'#title' => t('Site key'),
|
19
|
'#default_value' => variable_get('recaptcha_site_key', ''),
|
20
|
'#maxlength' => 40,
|
21
|
'#description' => t('The site key given to you when you <a href="@url">register for reCAPTCHA</a>.', array('@url' => 'http://www.google.com/recaptcha/admin')),
|
22
|
'#required' => TRUE,
|
23
|
);
|
24
|
$form['recaptcha_general_settings']['recaptcha_secret_key'] = array(
|
25
|
'#type' => 'textfield',
|
26
|
'#title' => t('Secret key'),
|
27
|
'#default_value' => variable_get('recaptcha_secret_key', ''),
|
28
|
'#maxlength' => 40,
|
29
|
'#description' => t('The secret key given to you when you <a href="@url">register for reCAPTCHA</a>.', array('@url' => 'http://www.google.com/recaptcha/admin')),
|
30
|
'#required' => TRUE,
|
31
|
);
|
32
|
|
33
|
$form['recaptcha_widget_settings'] = array(
|
34
|
'#type' => 'fieldset',
|
35
|
'#title' => t('Widget settings'),
|
36
|
'#collapsible' => TRUE,
|
37
|
'#collapsed' => FALSE,
|
38
|
);
|
39
|
$form['recaptcha_widget_settings']['recaptcha_theme'] = array(
|
40
|
'#type' => 'select',
|
41
|
'#title' => t('Theme'),
|
42
|
'#description' => t('Defines which theme to use for reCAPTCHA.'),
|
43
|
'#options' => array(
|
44
|
'light' => t('Light (default)'),
|
45
|
'dark' => t('Dark'),
|
46
|
),
|
47
|
'#default_value' => variable_get('recaptcha_theme', 'light'),
|
48
|
);
|
49
|
$form['recaptcha_widget_settings']['recaptcha_type'] = array(
|
50
|
'#type' => 'select',
|
51
|
'#title' => t('Type'),
|
52
|
'#description' => t('The type of CAPTCHA to serve.'),
|
53
|
'#options' => array(
|
54
|
'image' => t('Image (default)'),
|
55
|
'audio' => t('Audio'),
|
56
|
),
|
57
|
'#default_value' => variable_get('recaptcha_type', 'image'),
|
58
|
);
|
59
|
$form['recaptcha_widget_settings']['recaptcha_size'] = array(
|
60
|
'#default_value' => variable_get('recaptcha_size', ''),
|
61
|
'#description' => t('The size of CAPTCHA to serve.'),
|
62
|
'#options' => array(
|
63
|
'' => t('Normal (default)'),
|
64
|
'compact' => t('Compact'),
|
65
|
),
|
66
|
'#title' => t('Size'),
|
67
|
'#type' => 'select',
|
68
|
);
|
69
|
$form['recaptcha_widget_settings']['recaptcha_tabindex'] = array(
|
70
|
'#type' => 'textfield',
|
71
|
'#title' => t('Tabindex'),
|
72
|
'#description' => t('Set the <a href="@tabindex">tabindex</a> of the widget and challenge (Default = 0). If other elements in your page use tabindex, it should be set to make user navigation easier.', array('@tabindex' => 'http://www.w3.org/TR/html4/interact/forms.html#adef-tabindex')),
|
73
|
'#default_value' => variable_get('recaptcha_tabindex', 0),
|
74
|
'#size' => 4,
|
75
|
);
|
76
|
$form['recaptcha_widget_settings']['recaptcha_noscript'] = array(
|
77
|
'#type' => 'checkbox',
|
78
|
'#title' => t('Enable fallback for browsers with JavaScript disabled'),
|
79
|
'#default_value' => variable_get('recaptcha_noscript', 0),
|
80
|
'#description' => t('If JavaScript is a requirement for your site, you should <strong>not</strong> enable this feature. With this enabled, a compatibility layer will be added to the captcha to support non-js users.'),
|
81
|
);
|
82
|
|
83
|
return system_settings_form($form);
|
84
|
}
|
85
|
|
86
|
/**
|
87
|
* Validation function for recaptcha_admin_settings().
|
88
|
*
|
89
|
* @see recaptcha_admin_settings()
|
90
|
*/
|
91
|
function recaptcha_admin_settings_validate($form, &$form_state) {
|
92
|
$tabindex = $form_state['values']['recaptcha_tabindex'];
|
93
|
if (!is_numeric($tabindex)) {
|
94
|
form_set_error('recaptcha_tabindex', t('The tabindex must be an integer.'));
|
95
|
}
|
96
|
}
|