You are here

function biblio_endnote_tagged_export in Bibliography Module 6

Export data in EndNote tagged format.

Parameters

$result: a database pointer to a result set

Return value

none

1 call to biblio_endnote_tagged_export()
_biblio_export in ./biblio.import.export.inc

File

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

Code

function biblio_endnote_tagged_export($node) {
  $tagged = "";
  $tagged .= "%0 " . _endnote_tagged_type_map($node->biblio_type) . "\r\n";
  switch ($node->biblio_type) {
    case 100:
    case 101:
    case 103:
    case 104:
    case 105:
    case 108:
    case 119:
      if (!empty($node->biblio_secondary_title)) {
        $tagged .= "%B " . trim($node->biblio_secondary_title) . "\r\n";
      }
      break;
    case 102:
      if (!empty($node->biblio_secondary_title)) {
        $tagged .= "%J " . trim($node->biblio_secondary_title) . "\r\n";
      }
      break;
  }
  if (isset($node->biblio_year) && $node->biblio_year < 9998) {
    $tagged .= "%D " . trim($node->biblio_year) . "\r\n";
  }
  if (!empty($node->title)) {
    $tagged .= "%T " . trim($node->title) . "\r\n";
  }
  foreach ((array) $node->biblio_contributors[1] as $auth) {
    $tagged .= "%A " . trim($auth['name']) . "\r\n";
  }
  foreach ((array) $node->biblio_contributors[2] as $auth) {
    $tagged .= "%E " . trim($auth['name']) . "\r\n";
  }
  foreach ((array) $node->biblio_contributors[3] as $auth) {
    $tagged .= "%Y " . trim($auth['name']) . "\r\n";
  }
  if (!empty($node->biblio_place_published)) {
    $tagged .= "%C " . trim($node->biblio_place_published) . "\r\n";
  }
  if (!empty($node->biblio_publisher)) {
    $tagged .= "%I " . trim($node->biblio_publisher) . "\r\n";
  }
  $kw_array = array();
  if (!empty($node->terms)) {
    foreach ($node->terms as $term) {
      $kw_array[] = $term->name;
    }
  }
  if (!empty($node->biblio_keywords)) {
    foreach ($node->biblio_keywords as $term) {
      $kw_array[] = $term;
    }
  }
  if (!empty($kw_array)) {
    $kw_array = array_unique($kw_array);
    foreach ($kw_array as $term) {
      $tagged .= "%K " . trim($term) . "\r\n";
    }
  }
  if (!empty($node->biblio_call_number)) {
    $tagged .= "%L " . trim($node->biblio_call_number) . "\r\n";
  }
  if (!empty($node->biblio_accession_number)) {
    $tagged .= "%M " . trim($node->biblio_accession_number) . "\r\n";
  }
  if (!empty($node->biblio_issue)) {
    $tagged .= "%N " . trim($node->biblio_issue) . "\r\n";
  }
  if (!empty($node->biblio_pages)) {
    $tagged .= "%P " . trim($node->biblio_pages) . "\r\n";
  }
  if (!empty($node->biblio_doi)) {
    $tagged .= "%R " . trim($node->biblio_doi) . "\r\n";
  }
  if (!empty($node->biblio_tertiary_title)) {
    $tagged .= "%S " . trim($node->biblio_tertiary_title) . "\r\n";
  }
  if (!empty($node->biblio_url)) {
    $tagged .= "%U " . trim($node->biblio_url) . "\r\n";
  }
  if (!empty($node->biblio_volume)) {
    $tagged .= "%V " . trim($node->biblio_volume) . "\r\n";
  }
  $abst = "";
  if (!empty($node->biblio_abst_e)) {
    $abst .= trim($node->biblio_abst_e);
  }
  if (!empty($node->biblio_abst_f)) {
    $abst .= trim($node->biblio_abst_f);
  }
  if ($abst) {
    $search = array(
      "/\r/",
      "/\n/",
    );
    $replace = " ";
    $abst = preg_replace($search, $replace, $abst);
    $tagged .= "%X " . $abst . "\r\n";
  }
  if (!empty($node->biblio_notes)) {
    $tagged .= "%Z " . trim($node->biblio_notes) . "\r\n";
  }
  if (!empty($node->biblio_edition)) {
    $tagged .= "%7 " . trim($node->biblio_edition) . "\r\n";
  }
  if (!empty($node->biblio_date)) {
    $tagged .= "%8 " . trim($node->biblio_date) . "\r\n";
  }
  if (!empty($node->biblio_type_of_work)) {
    $tagged .= "%9 " . trim($node->biblio_type_of_work) . "\r\n";
  }
  if (!empty($node->biblio_isbn)) {
    $tagged .= "%@ " . trim($node->biblio_isbn) . "\r\n";
  }
  if (!empty($node->files) && count($node->files) && user_access('view uploaded files')) {
    foreach ($node->files as $file) {
      $tagged .= "%> " . file_create_url($file->filepath) . "\r\n";

      // insert file here.
    }
  }
  $tagged .= "\r\n";
  return $tagged;
}