You are here

function biblio_admin_field_mapper_form in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 includes/biblio.admin.inc \biblio_admin_field_mapper_form()
  2. 7 includes/biblio.admin.inc \biblio_admin_field_mapper_form()
  3. 7.2 includes/biblio.admin.inc \biblio_admin_field_mapper_form()
1 string reference to 'biblio_admin_field_mapper_form'
biblio_menu in ./biblio.module
Implementation of hook_menu().

File

./biblio.admin.inc, line 1070

Code

function biblio_admin_field_mapper_form($form_state, $format = 'bibtex', $op = 'map') {
  module_load_include('inc', 'biblio', 'biblio.type.mapper');
  $map = biblio_get_field_map($format);
  $export_map = biblio_get_export_map($format);
  $form['fileformat'] = array(
    '#type' => 'hidden',
    '#value' => $format,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset to Defaults'),
  );
  $form['#redirect'] = 'admin/settings/biblio/fields/fieldmap';
  if ($op == 'map') {
    $schema = drupal_get_schema('biblio');
    $fieldnames = array_keys($schema['fields']);
    asort($fieldnames);
    $biblio_field_options[''] = t('-none-');
    foreach ($fieldnames as $field) {
      $biblio_field_options[$field] = $field;
    }
    $biblio_field_select = array(
      '#type' => 'select',
      '#options' => $biblio_field_options,
    );
    foreach ($map as $key => $value) {
      $biblio_field_select['#default_value'] = $map[$key];
      $form['type'][$key] = array(
        'format' => array(
          '#value' => "<b>" . $key . "</b>",
        ),
        'biblio' => $biblio_field_select,
        'export' => array(
          '#type' => 'checkbox',
          '#default_value' => $export_map[$value],
        ),
        '#tree' => 1,
      );
    }
  }
  elseif ($op == 'add') {
    $form['type_name'] = array(
      '#type' => 'textfield',
      '#title' => 'Publication Type',
      '#required' => TRUE,
      '#description' => t('This is the name of the type identifier, exactly as it appears in the file'),
    );
    $form['type_desc'] = array(
      '#type' => 'textfield',
      '#title' => 'Description',
    );
    $form['submit']['#value'] = t('Add');
    unset($form['reset']);
    $form['#redirect'] = 'admin/settings/biblio/fields/typemap/' . $format;
  }
  return $form;
}