You are here

function variable_variable_type_info in Variable 6

Same name and namespace in other branches
  1. 7.2 variable.variable.inc \variable_variable_type_info()
  2. 7 variable.variable.inc \variable_variable_type_info()

Implements hook_variable_type_info().

File

./variable.variable.inc, line 26
Variable module hook implementations

Code

function variable_variable_type_info() {

  // Array of values
  $type['array'] = array(
    'title' => t('Array'),
    'element' => array(
      '#type' => 'fieldset',
      '#tree' => TRUE,
    ),
    // Properties for each array item
    'repeat' => array(
      'element' => array(
        '#type' => 'textfield',
      ),
    ),
    'format callback' => 'variable_format_array',
    'element callback' => 'variable_form_element_array',
    'default' => array(),
  );

  // TRUE / FALSE value, checkbox
  $type['boolean'] = array(
    'title' => t('Boolean'),
    'element' => array(
      '#type' => 'checkbox',
    ),
    'format callback' => 'variable_format_boolean',
  );

  // Default type for variables with no other type
  $type['default'] = array(
    'title' => t('Default'),
    'element' => array(
      '#type' => 'textfield',
    ),
    'access' => 'administer site configuration',
  );

  // Enable/Disable
  $type['enable'] = array(
    'title' => t('Enable'),
    'options' => array(
      t('Disabled'),
      t('Enabled'),
    ),
    'default' => 0,
    'element' => array(
      '#type' => 'radios',
    ),
    'format callback' => 'variable_format_selection',
  );

  // Multiple variable that will spawn into multiple elements
  $type['multiple'] = array(
    'title' => t('Multiple'),
    'element' => array(
      '#type' => 'fieldset',
    ),
    'build callback' => 'variable_build_multiple',
    'format callback' => 'variable_format_multiple',
    'element callback' => 'variable_form_element_multiple',
    'value callback' => 'variable_multiple_get_value',
    'default callback' => 'variable_multiple_get_default',
  );
  $type['mail_address'] = array(
    'title' => t('E-mail address'),
    'element' => array(
      '#type' => 'textfield',
    ),
    'token' => TRUE,
  );
  $type['mail_text'] = array(
    'title' => t('Mail text'),
    'multiple' => array(
      'subject' => t('Subject'),
      'body' => t('Body'),
    ),
    'build callback' => 'variable_build_mail_text',
    'localize' => TRUE,
    'type' => 'multiple',
  );
  $type['number'] = array(
    'title' => t('Number'),
    'element' => array(
      '#type' => 'textfield',
      '#size' => 15,
      '#maxlength' => 10,
    ),
  );

  // Select multiple options from multiple choices
  $type['options'] = array(
    'title' => t('Options'),
    'options' => TRUE,
    'element' => array(
      '#type' => 'checkboxes',
    ),
    'element callback' => 'variable_form_element_options',
    'format callback' => 'variable_format_options',
  );

  // Select single option from multiple choices
  $type['select'] = array(
    'title' => t('Select'),
    'options' => TRUE,
    // This will become radios or drop-down depending on the number of options
    'element callback' => 'variable_form_element_options',
    'format callback' => 'variable_format_selection',
  );

  // Select number from array of values. Options array that can be list of numbers will be converted to a value => value
  $type['select_number'] = array(
    'title' => t('Select'),
    'options' => TRUE,
    'element callback' => 'variable_form_element_options',
    'options callback' => 'variable_options_select_number',
  );
  $type['string'] = array(
    'title' => t('String'),
    'element' => array(
      '#type' => 'textfield',
    ),
    'localize' => TRUE,
    'token' => TRUE,
  );
  $type['text'] = array(
    'title' => t('Text'),
    'element' => array(
      '#type' => 'textarea',
    ),
    'localize' => TRUE,
    'format callback' => 'variable_format_text',
    'token' => TRUE,
  );

  // Default type for variables with no other type
  $type['unknown'] = array(
    'title' => t('Unknown'),
    'access' => 'administer site configuration',
    'format' => 'variable_format_unknown',
    'element callback' => 'variable_form_element_unknown',
    'element' => array(
      '#type' => 'item',
    ),
  );
  $type['url'] = array(
    'title' => t('URL'),
    'element' => array(
      '#type' => 'textfield',
      '#size' => 30,
      '#maxlength' => 255,
    ),
  );
  $type['mail_part'] = array(
    'title' => t('Mail parts'),
    'options' => array(
      'subject' => t('Subject'),
      'body' => t('Body'),
    ),
  );
  return $type;
}