| 1 |
|
<?php |
| 2 |
|
// $Id$ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* @file |
| 6 |
|
* Provides the reCAPTCHA administration settings. |
| 7 |
|
*/ |
| 8 |
|
|
| 9 |
|
/** |
| 10 |
|
* Form callback; administrative settings for reCaptcha. |
| 11 |
|
*/ |
| 12 |
|
function recaptcha_admin_settings() { |
| 13 |
|
// Load the recaptcha library. |
| 14 |
|
_recaptcha_load_library(); |
| 15 |
|
|
| 16 |
|
$form = array(); |
| 17 |
|
$form['recaptcha_public_key'] = array( |
| 18 |
|
'#type' => 'textfield', |
| 19 |
|
'#title' => t('Public Key'), |
| 20 |
|
'#default_value' => variable_get('recaptcha_public_key', ''), |
| 21 |
|
'#maxlength' => 40, |
| 22 |
|
'#description' => t('The public key given to you when you <a href="@url" target="_blank">registered at reCAPTCHA.net</a>.', array('@url' => url(recaptcha_get_signup_url($_SERVER['SERVER_NAME'], variable_get('site_name', ''))))), |
| 23 |
|
'#required' => TRUE, |
| 24 |
|
); |
| 25 |
|
$form['recaptcha_private_key'] = array( |
| 26 |
|
'#type' => 'textfield', |
| 27 |
|
'#title' => t('Private Key'), |
| 28 |
|
'#default_value' => variable_get('recaptcha_private_key', ''), |
| 29 |
|
'#maxlength' => 40, |
| 30 |
|
'#description' => t('The private key given to you when you <a href="@url" target="_blank">registered at reCAPTCHA.net</a>.', array('@url' => url(recaptcha_get_signup_url($_SERVER['SERVER_NAME'], variable_get('site_name', ''))))), |
| 31 |
|
'#required' => TRUE, |
| 32 |
|
); |
| 33 |
|
$form['recaptcha_secure_connection'] = array( |
| 34 |
|
'#type' => 'checkbox', |
| 35 |
|
'#title' => t('Secure Connection'), |
| 36 |
|
'#default_value' => variable_get('recaptcha_secure_connection', FALSE), |
| 37 |
|
'#description' => t('Connect to the reCAPTCHA server using a secure connection.'), |
| 38 |
|
); |
| 39 |
|
$form['recaptcha_theme_settings'] = array( |
| 40 |
|
'#type' => 'fieldset', |
| 41 |
|
'#title' => t('Theme Settings'), |
| 42 |
|
'#collapsible' => TRUE, |
| 43 |
|
'#collapsed' => TRUE, |
| 44 |
|
); |
| 45 |
|
$form['recaptcha_theme_settings']['recaptcha_theme'] = array( |
| 46 |
|
'#type' => 'select', |
| 47 |
|
'#title' => t('Theme'), |
| 48 |
|
'#description' => t('Defines which theme to use for reCAPTCHA.'), |
| 49 |
|
'#options' => array( |
| 50 |
|
'red' => t('Red'), |
| 51 |
|
'white' => t('White'), |
| 52 |
|
'blackglass' => t('Black Glass'), |
| 53 |
|
'clean' => t('Clean'), |
| 54 |
|
'custom' => t('Custom'), |
| 55 |
|
), |
| 56 |
|
'#default_value' => variable_get('recaptcha_theme', 'red'), |
| 57 |
|
'#required' => TRUE, |
| 58 |
|
); |
| 59 |
|
$form['recaptcha_theme_settings']['recaptcha_tabindex'] = array( |
| 60 |
|
'#type' => 'textfield', |
| 61 |
|
'#title' => t('Tab Index'), |
| 62 |
|
'#description' => t('Sets a <a href="@tabindex" target="_blank">tabindex</a> for the reCAPTCHA text box. If other elements in the form use a tabindex, this should be set so that navigation is easier for the user.', array('@tabindex' => 'http://www.w3.org/TR/html4/interact/forms.html#adef-tabindex')), |
| 63 |
|
'#default_value' => variable_get('recaptcha_tabindex', ''), |
| 64 |
|
'#size' => 4, |
| 65 |
|
); |
| 66 |
|
|
| 67 |
|
return system_settings_form($form); |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
/** |
| 71 |
|
* Validation function for recaptcha_admin_settings(). |
| 72 |
|
* |
| 73 |
|
* @see recaptcha_admin_settings() |
| 74 |
|
*/ |
| 75 |
|
function recaptcha_admin_settings_validate($form, &$form_state) { |
| 76 |
|
$tabindex = $form_state['values']['recaptcha_tabindex']; |
| 77 |
|
if (!empty($tabindex) && !is_numeric($tabindex)) { |
| 78 |
|
form_set_error('recaptcha_tabindex', t('The Tab Index must be an integer.')); |
| 79 |
|
} |
| 80 |
|
} |