You are here

function biblio_export in Bibliography Module 6.2

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

Exports biblio nodes in a given file format.

Parameters

$format: The file format to export the nodes in (tagged, XML, bibTEX)

$nid: If not NULL, then export only the given node ID, else we will use the session variable which holds the most recent query. If neither $nid or the session variable are set, then nothing is exported

$version: The version of EndNote XML to use. There is one format for ver. 1-7 and a different format for versions 8 and greater.

Return value

??

1 string reference to 'biblio_export'
biblio_menu in ./biblio.module
Implements hook_menu().

File

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

Code

function biblio_export($format = "tagged", $nid = null, $popup = false, $version = 8) {
  $params = array();
  if ($nid === null && isset($_SESSION['last_biblio_query']) && !empty($_SESSION['last_biblio_query'])) {
    $query = $_SESSION['last_biblio_query'];
    $params = $_SESSION['last_biblio_query_terms'];
  }
  elseif (!empty($nid)) {
    $query = db_rewrite_sql("SELECT DISTINCT(n.nid) FROM {node} n  WHERE n.nid=%d ");
    $params[] = $nid;
  }
  else {
    return;
  }
  $result = db_query($query, $params);
  $count = 0;
  while ($node = db_fetch_object($result)) {
    $node = node_load($node->nid, FALSE, TRUE);
    $count++;
    set_time_limit(30);
    switch ($format) {
      case "csv":
        drupal_set_header('Content-Type: application/text; charset=utf-8');
        drupal_set_header('Content-Disposition: attachment; filename=Biblio-export.csv');
        print biblio_csv_export($node);
        break;
    }
  }
  if ($popup && !empty($popup_data)) {
    return '<pre>' . $popup_data . '</pre>';
  }
}