Projet

Général

Profil

Paste
Télécharger (3,61 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / recaptcha / recaptcha.admin.inc @ ba09eb79

1
<?php
2

    
3
/**
4
 * @file
5
 * Provides the reCAPTCHA administration settings.
6
 */
7

    
8
/**
9
 * Form callback; administrative settings for reCaptcha.
10
 */
11
function recaptcha_admin_settings() {
12
  // Load the recaptcha library. Error if library does not load.
13
  if (!_recaptcha_load_library()) {
14
    drupal_set_message(t('Error loading recaptchalib.'), 'error');
15
    return FALSE;
16
  }
17

    
18
  $form = array();
19
  $form['recaptcha_public_key'] = array(
20
    '#type' => 'textfield',
21
    '#title' => t('Public Key'),
22
    '#default_value' => variable_get('recaptcha_public_key', ''),
23
    '#maxlength' => 40,
24
    '#description' => t('The public key given to you when you <a href="@url" target="_blank">register for reCAPTCHA</a>.', array('@url' => url(recaptcha_get_signup_url($_SERVER['SERVER_NAME'], variable_get('site_name', ''))))),
25
    '#required' => TRUE,
26
  );
27
  $form['recaptcha_private_key'] = array(
28
    '#type' => 'textfield',
29
    '#title' => t('Private Key'),
30
    '#default_value' => variable_get('recaptcha_private_key', ''),
31
    '#maxlength' => 40,
32
    '#description' => t('The private key given to you when you <a href="@url" target="_blank">register for reCAPTCHA</a>.', array('@url' => url(recaptcha_get_signup_url($_SERVER['SERVER_NAME'], variable_get('site_name', ''))))),
33
    '#required' => TRUE,
34
  );
35
  $form['recaptcha_server_status_check_interval'] = array(
36
    '#type' => 'textfield',
37
    '#title' => t('Captcha server check interval'),
38
    '#default_value' => variable_get('recaptcha_server_status_check_interval', 5),
39
    '#description' => t('Number of minutes to cache reCAPTCHA server status.'),
40
    '#size' => 10,
41
  );
42
  $form['recaptcha_ajax_api'] = array(
43
    '#type' => 'checkbox',
44
    '#title' => t('AJAX API'),
45
    '#default_value' => variable_get('recaptcha_ajax_api', FALSE),
46
    '#description' => t('Use the AJAX API to display reCAPTCHA.'),
47
  );
48
  $form['recaptcha_nocookies'] = array(
49
    '#type' => 'checkbox',
50
    '#title' => t('Disable Client-Side Cookies'),
51
    '#default_value' => variable_get('recaptcha_nocookies', FALSE),
52
    '#description' => t('Add flag to disable third-party cookies set by reCAPTCHA.'),
53
  );
54
  $form['recaptcha_theme_settings'] = array(
55
    '#type' => 'fieldset',
56
    '#title' => t('Theme Settings'),
57
    '#collapsible' => TRUE,
58
    '#collapsed' => TRUE,
59
  );
60
  $form['recaptcha_theme_settings']['recaptcha_theme'] = array(
61
    '#type' => 'select',
62
    '#title' => t('Theme'),
63
    '#description' => t('Defines which theme to use for reCAPTCHA.'),
64
    '#options' => array(
65
      'red' => t('Red'),
66
      'white' => t('White'),
67
      'blackglass' => t('Black Glass'),
68
      'clean' => t('Clean'),
69
      'custom' => t('Custom'),
70
    ),
71
    '#default_value' => variable_get('recaptcha_theme', 'red'),
72
    '#required' => TRUE,
73
  );
74
  $form['recaptcha_theme_settings']['recaptcha_tabindex'] = array(
75
    '#type' => 'textfield',
76
    '#title' => t('Tab Index'),
77
    '#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')),
78
    '#default_value' => variable_get('recaptcha_tabindex', ''),
79
    '#size' => 4,
80
  );
81

    
82
  return system_settings_form($form);
83
}
84

    
85
/**
86
 * Validation function for recaptcha_admin_settings().
87
 *
88
 * @see recaptcha_admin_settings()
89
 */
90
function recaptcha_admin_settings_validate($form, &$form_state) {
91
  $tabindex = $form_state['values']['recaptcha_tabindex'];
92
  if (!empty($tabindex) && !is_numeric($tabindex)) {
93
    form_set_error('recaptcha_tabindex', t('The Tab Index must be an integer.'));
94
  }
95
}