You are here

function _biblio_export in Bibliography Module 5

Same name and namespace in other branches
  1. 6 biblio.import.export.inc \_biblio_export()
1 string reference to '_biblio_export'
biblio_menu in ./biblio.module
Implementation of hook_menu().

File

./biblio.module, line 2477

Code

function _biblio_export($format = "tagged", $nid = null, $version = 7) {
  $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 * FROM {node} n left join {biblio} b  on n.vid=b.vid\n                WHERE n.nid=%d ");
    $params[] = $nid;
  }
  else {
    return;
  }
  $result = db_query($query, $params);
  while ($node = db_fetch_object($result)) {
    $results[] = $node;
  }
  if (count($results)) {
    switch ($format) {
      case "tagged":
        header('Content-type:   application/x-endnote-refer');
        header('Content-Disposition:  filename="Drupal-Biblio.enw"');
        print _endnote_tagged_export($results);
        break;
      case "xml":
        header('Content-type: application/xml; charset=utf-8');
        header('Content-Disposition: attachment; filename="Biblio-EndNote' . $version . '.xml"');
        print _endnote_XML_export($results, $version);
        break;
      case "bib":
        header('Content-type:   application/text charset=utf-8');
        header('Content-Disposition:  filename="Biblio-Bibtex.bib"');
        print _bibtex_export($results);
        break;
    }
  }
}