You are here

function barcodes_block_configure in Barcodes 7

Implements hook_block_configure().

File

./barcodes.module, line 24
Contains barcodes.module.

Code

function barcodes_block_configure($delta = '') {
  $form = array();
  if ($delta === 'barcode') {
    $generator = new BarcodeGenerator();
    $form['settings'] = array(
      '#type' => 'fieldset',
      '#title' => t('Barcode settings'),
    );
    $form['settings']['value'] = [
      '#type' => 'textfield',
      '#title' => t('Value'),
      '#description' => t('The Barcode value.'),
      '#default_value' => variable_get('barcodes_value', ''),
    ];
    if (module_exists('token')) {
      $form['settings']['value'] = [
        '#element_validate' => array(
          'token_element_validate',
        ),
        '#token_types' => array(),
      ];
      $form['settings']['token_help'] = [
        '#theme' => 'token_tree_link',
        '#token_types' => [],
      ];
    }
    $form['settings']['type'] = [
      '#type' => 'select',
      '#title' => t('Barcode Type'),
      '#description' => t('The Barcode type.'),
      '#options' => array_combine($generator
        ->getTypes(), $generator
        ->getTypes()),
      '#default_value' => variable_get('barcodes_type', 'QRCODE'),
    ];
    $form['settings']['color'] = [
      '#type' => 'textfield',
      '#title' => t('Color'),
      '#default_value' => variable_get('barcodes_color', '#000000'),
      '#description' => t('The color code.'),
    ];
    $form['settings']['height'] = [
      '#type' => 'textfield',
      '#title' => t('Height'),
      '#size' => 10,
      '#default_value' => variable_get('barcodes_height', 100),
      '#description' => t('The height in pixels.'),
    ];
    $form['settings']['width'] = [
      '#type' => 'textfield',
      '#title' => t('Width'),
      '#size' => 10,
      '#default_value' => variable_get('barcodes_width', 100),
      '#description' => t('The width in pixels'),
    ];
    $form['settings']['padding_top'] = [
      '#type' => 'textfield',
      '#title' => t('Padding-Top'),
      '#size' => 4,
      '#maxlength' => 4,
      '#default_value' => variable_get('barcodes_padding_top', 0),
      '#description' => t('The top padding in pixels'),
    ];
    $form['settings']['padding_right'] = [
      '#type' => 'textfield',
      '#title' => t('Padding-Right'),
      '#size' => 4,
      '#maxlength' => 4,
      '#default_value' => variable_get('barcodes_padding_right', 0),
      '#description' => t('The right padding in pixels'),
    ];
    $form['settings']['padding_bottom'] = [
      '#type' => 'textfield',
      '#title' => t('Padding-Bottom'),
      '#size' => 4,
      '#maxlength' => 4,
      '#default_value' => variable_get('barcodes_padding_bottom', 0),
      '#description' => t('The bottom padding in pixels'),
    ];
    $form['settings']['padding_left'] = [
      '#type' => 'textfield',
      '#title' => t('Padding-Left'),
      '#size' => 4,
      '#maxlength' => 4,
      '#default_value' => variable_get('barcodes_padding_left', 0),
      '#description' => t('The left padding in pixels'),
    ];
    $form['settings']['show_value'] = [
      '#type' => 'checkbox',
      '#title' => t('Show value'),
      '#default_value' => variable_get('barcodes_show_value', FALSE),
      '#description' => t('Show the actual value in addition to the barcode'),
    ];
  }
  return $form;
}