You are here

function biblio_import in Bibliography Module 6.2

Same name and namespace in other branches
  1. 6 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()

Imports 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 includes/biblio.import.export.inc
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

File

includes/biblio.import.export.inc, line 472
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;
  $nids = 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->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;
    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;
}