<?php

/**
 * @file
 * Declares a form to test FAPI encryption.
 */

/**
 * Implements hook_menu().
 */
function encryptfapi_menu() {
  $items = array();

  $items['encryptfapi_test'] = array(
    'title' => 'Encrypt FAPI Test',
    'description' => 'A test page for the Encrypt FAPI module.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('encryptfapi_test_form'),
    'access callback' => TRUE,
  );

  return $items;
}

/**
 * The form.
 */
function encryptfapi_test_form() {
  $form = array();

  $form['encryptfapi_textfield_simple'] = array(
    '#type' => 'textfield',
    '#title' => t('Textfield Simple'),
    '#default_value' => variable_get('encryptfapi_textfield_simple', ''),
    '#encrypt' => TRUE,
  );

  $form['encryptfapi_textfield_complex'] = array(
    '#type' => 'textfield',
    '#title' => t('Textfield Complex'),
    '#default_value' => variable_get('encryptfapi_textfield_complex', ''),
    '#encrypt' => array(
      'method' => 'mcrypt_rij_256',
    ),
  );

  $default = variable_get('encrypt_tree', array());
  $form['encrypt_tree'] = array(
    '#type' => 'fieldset',
    '#tree' => TRUE,
  );
  $form['encrypt_tree']['encryptfapi_textfield_nested'] = array(
    '#type' => 'textfield',
    '#title' => t('Nested Textfield'),
    '#default_value' => isset($default['encryptfapi_textfield_nested']) ? $default['encryptfapi_textfield_nested'] : '',
    '#encrypt' => TRUE,
  );

  return system_settings_form($form);
}
