You are here

function biblio_admin_field_mapper_form in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 includes/biblio.admin.inc \biblio_admin_field_mapper_form()
  2. 6 biblio.admin.inc \biblio_admin_field_mapper_form()
  3. 7.2 includes/biblio.admin.inc \biblio_admin_field_mapper_form()

Parameters

$format:

$exportable:

Return value

Ambigous <multitype:string multitype:string NULL , multitype:number multitype:string multitype:string Ambigous <> Ambigous <string, unknown> , multitype:string >

1 call to biblio_admin_field_mapper_form()
biblio_admin_io_mapper_form in includes/biblio.admin.inc
1 string reference to 'biblio_admin_field_mapper_form'
biblio_admin_io_mapper_form in includes/biblio.admin.inc

File

includes/biblio.admin.inc, line 1394
biblio.admin.inc

Code

function biblio_admin_field_mapper_form($format, $exportable = TRUE) {
  $formats = module_invoke_all('biblio_mapper_options');
  $form['#file_format_title'] = isset($formats[$format]) ? $formats[$format]['title'] : '';
  $form['#file_format'] = $format;
  $exportable = isset($formats[$format]['export']) ? $formats[$format]['export'] : $exportable;
  $form['#file_format_export'] = $exportable;
  $map = biblio_get_map('field_map', $format);
  $export_map = biblio_get_map('export_map', $format);
  ksort($map);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save field mapping'),
    '#submit' => array(
      'biblio_admin_field_mapper_form_submit',
    ),
  );
  $form['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset field mapping to default'),
    '#submit' => array(
      'biblio_admin_field_mapper_form_reset_submit',
    ),
  );
  $schema = drupal_get_schema('biblio');
  $fieldnames = array_keys($schema['fields']);
  asort($fieldnames);
  $biblio_field_options[''] = t('-none-');
  $biblio_field_options['title'] = 'title';
  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(
        '#markup' => "<b>" . $key . "</b>",
      ),
      'biblio' => $biblio_field_select,
      '#tree' => 1,
    );
    if ($exportable) {
      $form['type'][$key]['export'] = array(
        '#type' => 'checkbox',
        '#default_value' => isset($export_map[$value]) ? $export_map[$value] : '',
      );
    }
  }
  return $form;
}