You are here

function biblio_form_import in Bibliography Module 5

1 string reference to 'biblio_form_import'
biblio_menu in ./biblio.module
Implementation of hook_menu().

File

./biblio.module, line 2798

Code

function biblio_form_import() {
  global $user;
  if (biblio_access('import')) {

    // && !user_access('administer nodes')) {
    $form['#attributes']['enctype'] = 'multipart/form-data';
    $form["file_upload"] = array(
      '#type' => 'file',
      '#title' => t('Import file'),
      '#default_value' => '',
      '#size' => 60,
    );
    $form['filetype'] = array(
      '#type' => 'radios',
      '#title' => t('File Type'),
      '#default_value' => '',
      '#options' => array(
        'tagged' => t('EndNote Tagged'),
        'ris' => t('RIS'),
        'xml' => t('EndNote 7 XML'),
        'xml8' => t('EndNote 8+ XML'),
        'bib' => t('BibTex'),
      ),
    );
    if ($user->uid) {
      $form['userid'] = _biblio_admin_build_user_select($user->uid);
    }

    // Get the vocabularies  attached to the biblio node type ...
    $vocabularies = module_invoke('taxonomy', 'get_vocabularies', 'biblio');

    // ... and print a form to select the terms in each of them
    $form['import_taxonomy'] = array(
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#title' => t('Taxonomy Settings'),
      '#description' => t('Here you may select terms to be assigned to imported records (if any vocabularies are assigned to the biblio node type)'),
    );
    if (count($vocabularies)) {
      $i = 0;
      foreach ($vocabularies as $vocabulary) {
        $form['import_taxonomy']['vocabulary' . $i] = module_invoke('taxonomy', 'form', $vocabulary->vid, 0);
        $form['import_taxonomy']['vocabulary' . $i++]['#description'] = t("Select taxonomy term to assigned to imported entries");
      }
    }
    else {
      $vocab_msg = t('There are currently no vocabularies assigned to the biblio node type, please go the the !url page to fix this', array(
        '!url' => l(t('admin/content/taxonomy'), 'admin/content/taxonomy'),
      ));
      $form['import_taxonomy']['vocabulary_message'] = array(
        '#value' => '<p><div>' . $vocab_msg . '</div></p>',
      );
    }
    if (variable_get('biblio_keyword_freetagging', 0)) {
      $freetag_vocab = module_invoke('taxonomy', 'get_vocabulary', variable_get('biblio_freetagging_vocab', 0));
      $msg = t('Keywords will be added to the <b>@name</b> vocabulary as specified in the Taxonomy section of the !url page.', array(
        '@name' => $freetag_vocab->name,
        '!url' => l(t('admin/settings/biblio'), 'admin/settings/biblio'),
      ));
    }
    else {
      $msg = t('Keywords will <b>NOT</b> be added to the vocabulary as specified in the Taxonomy section of the !url page.', array(
        '!url' => l(t('admin/settings/biblio'), 'admin/settings/biblio'),
      ));
    }
    $form['import_taxonomy']['freetagging_information'] = array(
      '#value' => '<p><div>' . $msg . '</div></p>',
    );
    $form['button'] = array(
      '#type' => 'submit',
      '#value' => t('Import'),
    );
    return $form;

    //print theme('page', form($form, 'post', null, $attributes));
  }
  else {
    drupal_set_message("You are not authorized to access the biblio import page", 'error');
    print theme('page', '');
  }
}