You are here

function biblio_admin_type_mapper_form in Bibliography Module 6

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

File

./biblio.admin.inc, line 944

Code

function biblio_admin_type_mapper_form($form_state, $format = 'bibtex', $op = 'map') {
  module_load_include('inc', 'biblio', 'biblio.type.mapper');
  $names = biblio_get_type_names($format);
  $map = biblio_get_type_map($format);
  ksort($names);
  $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/typemap';
  if ($op == 'map') {
    $result = db_query('SELECT t.* FROM {biblio_types} as t WHERE t.tid > 0');
    while ($type = db_fetch_object($result)) {
      $biblio_type_options[$type->tid] = $type->name;
    }
    asort($biblio_type_options);
    $biblio_type_select = array(
      '#type' => 'select',
      '#options' => $biblio_type_options,
    );
    foreach ($names as $key => $value) {
      $biblio_type_select['#default_value'] = $map[$key];
      $form['type'][$key] = array(
        'format' => array(
          '#value' => "<b>" . check_plain($key) . "</b> (<i>" . check_plain($value) . "</i>)",
        ),
        'biblio' => $biblio_type_select,
        '#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;
}