You are here

function biblio_import in Bibliography Module 7.2

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

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

Parameters

$userid: The user id 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 of node id's of the items imported

5 calls to biblio_import()
BiblioImportExportUnitTest::testBiblioBibtexFileImport in tests/import.export.test
BiblioImportExportUnitTest::testBiblioRISFileImport in tests/import.export.test
BiblioImportExportUnitTest::testBiblioTaggedFileImport in tests/import.export.test
BiblioImportExportUnitTest::testBiblioXMLFileImport in tests/import.export.test
biblio_import_form_submit in includes/biblio.import.export.inc
Implementation of hook_submit() for the biblio_import_form.
2 string references to 'biblio_import'
biblio_import_batch_operations in includes/biblio.import.export.inc
biblio_import_form_submit in includes/biblio.import.export.inc
Implementation of hook_submit() for the biblio_import_form.

File

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

Code

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

      // comma separated variable file
      //        $file_content = @ file_get_contents($import_file->uri);
      //        $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->uri);
      $parsed = biblio_restore($file_content, $node_template, $node_array);
      break;
    default:
      list($bids, $dups) = module_invoke($type, 'biblio_import', $import_file, $terms, $batch, $session_id);
      break;
  }
  $context['results']['bids'] = $bids;
  $context['results']['dups'] = $dups;
  $context['results']['format'] = $type;
  $context['results']['userid'] = $userid;
  $context['results']['user'] = $user;
  $context['results']['file'] = $import_file;
  return $batch ? NULL : $bids;
}