Projet

Général

Profil

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

root / drupal7 / sites / all / modules / recaptcha / recaptcha.admin.inc @ 87dbc3bf

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_ajax_api'] = array(
36
    '#type' => 'checkbox',
37
    '#title' => t('AJAX API'),
38
    '#default_value' => variable_get('recaptcha_ajax_api', FALSE),
39
    '#description' => t('Use the AJAX API to display reCAPTCHA.'),
40
  );
41
  $form['recaptcha_nocookies'] = array(
42
    '#type' => 'checkbox',
43
    '#title' => t('Disable Client-Side Cookies'),
44
    '#default_value' => variable_get('recaptcha_nocookies', FALSE),
45
    '#description' => t('Add flag to disable third-party cookies set by reCAPTCHA.'),
46
  );
47
  $form['recaptcha_theme_settings'] = array(
48
    '#type' => 'fieldset',
49
    '#title' => t('Theme Settings'),
50
    '#collapsible' => TRUE,
51
    '#collapsed' => TRUE,
52
  );
53
  $form['recaptcha_theme_settings']['recaptcha_theme'] = array(
54
    '#type' => 'select',
55
    '#title' => t('Theme'),
56
    '#description' => t('Defines which theme to use for reCAPTCHA.'),
57
    '#options' => array(
58
      'red' => t('Red'),
59
      'white' => t('White'),
60
      'blackglass' => t('Black Glass'),
61
      'clean' => t('Clean'),
62
      'custom' => t('Custom'),
63
    ),
64
    '#default_value' => variable_get('recaptcha_theme', 'red'),
65
    '#required' => TRUE,
66
  );
67
  $form['recaptcha_theme_settings']['recaptcha_tabindex'] = array(
68
    '#type' => 'textfield',
69
    '#title' => t('Tab Index'),
70
    '#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')),
71
    '#default_value' => variable_get('recaptcha_tabindex', ''),
72
    '#size' => 4,
73
  );
74

    
75
  return system_settings_form($form);
76
}
77

    
78
/**
79
 * Validation function for recaptcha_admin_settings().
80
 *
81
 * @see recaptcha_admin_settings()
82
 */
83
function recaptcha_admin_settings_validate($form, &$form_state) {
84
  $tabindex = $form_state['values']['recaptcha_tabindex'];
85
  if (!empty($tabindex) && !is_numeric($tabindex)) {
86
    form_set_error('recaptcha_tabindex', t('The Tab Index must be an integer.'));
87
  }
88
}