You are here

function biblio_import in Bibliography Module 7

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.2 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()
BiblioImportExportWebTestCase::testBiblioBibtexFileImport in tests/BiblioImportExportWebTestCase.test
BiblioImportExportWebTestCase::testBiblioRISFileImport in tests/BiblioImportExportWebTestCase.test
BiblioImportExportWebTestCase::testBiblioTaggedFileImport in tests/BiblioImportExportWebTestCase.test
BiblioImportExportWebTestCase::testBiblioXMLFileImport in tests/BiblioImportExportWebTestCase.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 496
Functions that are used to import and export biblio data.

Code

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

    // Comma separated variable file.
    case 'csv':

      // $file_content = @ file_get_contents($import_file->uri);
      //        $parsed = biblio_csv_import($file_content, $node_template, $node_array);.
      break;

    // A complete backup of all biblio information.
    case 'biblio_backup':
      $file_content = @file_get_contents($import_file->uri);
      $parsed = biblio_restore($file_content, $node_template, $node_array);
      break;
    default:
      list($nids, $dups) = module_invoke($type, 'biblio_import', $import_file, $terms, $batch, $session_id);
      break;
  }
  $context['results']['nids'] = $nids;
  $context['results']['dups'] = $dups;
  $context['results']['format'] = $type;
  $context['results']['userid'] = $userid;
  $context['results']['user'] = $user;
  $context['results']['file'] = $import_file;
  return $batch ? NULL : $nids;
}