You are here

function views_calc_import_form in Views Calc 7

Same name and namespace in other branches
  1. 6.3 views_calc.module \views_calc_import_form()
  2. 6 views_calc.module \views_calc_import_form()

FAPI import_form.

Field import form.

1 string reference to 'views_calc_import_form'
views_calc_menu in ./views_calc.module
Implements hook_menu().

File

./views_calc.module, line 512
This module will allow you to add calculated fields to views tables and compute (SUM, COUNT, AVG, etc) columns of numeric data in a views table.

Code

function views_calc_import_form($form, &$form_state, $type_name = '') {
  $form['#prefix'] = t('This form will import Views Calc custom fields.');
  $form['macro'] = array(
    '#type' => 'textarea',
    '#rows' => 20,
    '#title' => t('Import data'),
    '#required' => TRUE,
    '#description' => t('Paste the text created by a Views Calc export into this field.'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Import'),
  );

  // Read in a file if there is one and set it as the default macro value.
  if (isset($_REQUEST['macro_file']) && ($file = file_get_contents($_REQUEST['macro_file']))) {
    $form['macro']['#default_value'] = $file;
    if (isset($_REQUEST['type_name'])) {
      $form['type_name']['#default_value'] = $_REQUEST['type_name'];
    }
    $form['#prefix'] .= '<p class="error">' . t('A file has been pre-loaded for import.') . '</p>';
  }
  $form_state['#redirect'] = 'admin/config/views_calc';
  return $form;
}