You are here

function biblio_import in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 includes/biblio.import.export.inc \biblio_import()
  2. 7 includes/biblio.import.export.inc \biblio_import()
  3. 7.2 includes/biblio.import.export.inc \biblio_import()

Import data from a file and return the node ids created.

Parameters

$userid: The user id of that will be assigned to each node imported

$filename: The name of the file containing the data to import

$type: The format of the file to be imported (tagged, XML, RIS, bibTEX)

$terms: the vocabulary that the imported nodes will be associated with

Return value

An array the node id's of the items imported

1 call to biblio_import()
biblio_import_form_submit in ./biblio.import.export.inc
Implementation of hook_submit() for the biblio_import_form.
2 string references to 'biblio_import'
biblio_import_batch_operations in ./biblio.import.export.inc
biblio_import_form_submit in ./biblio.import.export.inc
Implementation of hook_submit() for the biblio_import_form.

File

./biblio.import.export.inc, line 413
Functions that are used to import and export biblio data.

Code

function biblio_import($import_file, $type, $userid = 1, $terms = NULL, $batch_proc = FALSE, $session_id = NULL, &$context) {
  global $user;
  $parsed = 0;
  $node_ids = array();
  $dups = array();
  if (isset($context['message'])) {
    $context['message'] = t('Parsing file');
  }
  switch ($type) {
    case 'tagged':

      // EndNote Tagged
      module_load_include('inc', 'biblio', 'tagged_parser');
      $node_ids = _endnote_tagged_import($import_file, $terms, $batch_proc, $session_id);
      break;
    case 'ris':

      // RIS
      module_load_include('inc', 'biblio', 'ris_parser');
      $node_ids = _ris_tagged_import($import_file, $terms, $batch_proc, $session_id);
      break;
    case 'xml':

      // EndNote 7 XML
      $node_ids = biblio_endnote_XML_import($import_file, $terms, $batch_proc, $session_id, 7);
      break;
    case 'xml8':

      // EndNote 8+ XML
      $node_ids = biblio_endnote_XML_import($import_file, $terms, $batch_proc, $session_id, 8);
      break;
    case 'bib':

      // BibTex
      $node_ids = biblio_bibtex_import($import_file, $terms, $batch_proc, $session_id);
      break;
    case 'marc':

      // MARC
      $node_ids = biblio_marc_import($import_file, $terms, $batch_proc, $session_id);
      break;
    case 'pubmed':
      list($node_ids, $dups) = biblio_pm_biblio_import($import_file, $terms, $batch_proc, $session_id);
      break;
    case 'pubmed_xml':
      list($node_ids, $dups) = biblio_pm_biblio_xml_import($import_file, $terms, $batch_proc, $session_id);
      break;
    case 'csv':

      // comma separated variable file
      //        $file_content = @ file_get_contents($import_file->filepath);
      //        $parsed = biblio_csv_import($file_content, $node_template, $node_array);
      break;
    case 'biblio_backup':

      // a complete backup of all biblio information
      $file_content = @file_get_contents($import_file->filepath);
      $parsed = biblio_restore($file_content, $node_template, $node_array);
      break;
  }
  $context['results']['nids'] = $node_ids;
  $context['results']['dups'] = $dups;
  $context['results']['format'] = $type;
  $context['results']['userid'] = $userid;
  $context['results']['user'] = $user;
  $context['results']['file'] = $import_file;
  return;
}