You are here

function biblio_contextObject in Bibliography Module 5

Same name and namespace in other branches
  1. 6.2 includes/biblio.util.inc \biblio_contextObject()
  2. 6 biblio.module \biblio_contextObject()
  3. 7 includes/biblio.util.inc \biblio_contextObject()
  4. 7.2 includes/biblio.util.inc \biblio_contextObject()
2 calls to biblio_contextObject()
biblio_coins in ./biblio.module
biblio_openURL in ./biblio.module

File

./biblio.module, line 3740

Code

function biblio_contextObject($node) {

  // Copyright:          Matthias Steffens <mailto:refbase@extracts.de> and the file's
  //                     original author.
  // Original Author:    Richard Karnesky <mailto:karnesky@gmail.com>  //
  // Adapted for biblio: Ron Jerome
  global $base_url;

  // $openurl_base = variable_get('biblio_baseopenurl','');
  $co = array();

  // rfr_id
  $co["rfr_id"] = "info:sid/" . ereg_replace("http://", "", $base_url);

  // genre (type)
  if (isset($node->biblio_type)) {
    if ($node->biblio_type == 102) {
      $co["rft.genre"] = "article";
    }
    elseif ($node->biblio_type == 101) {
      $co["rft.genre"] = "bookitem";
    }
    elseif ($node->biblio_type == 100) {
      $co["rft.genre"] = "book";
    }
    elseif ($node->biblio_type == "Journal") {
      $co["rft.genre"] = "journal";
    }
  }

  // atitle, btitle, title (title, publication)
  if ($node->biblio_type == 102 || $node->biblio_type == 101) {
    if (!empty($node->title)) {
      $co["rft.atitle"] = $node->title;
    }
    if (!empty($node->biblio_secondary_title)) {
      $co["rft.title"] = $node->biblio_secondary_title;
      if ($node->biblio_type == 101) {
        $co["rft.btitle"] = $node->biblio_secondary_title;
      }
    }
  }
  elseif (!empty($node->title)) {
    $co["rft.title"] = $node->title;
  }
  if ($node->biblio_type == 100 && !empty($node->title)) {
    $co["rft.btitle"] = $node->title;
  }

  // stitle (abbrev_journal)
  if (!empty($node->biblio_short_title)) {
    $co["rft.stitle"] = $node->biblio_short_title;
  }

  // series (series_title)
  if (!empty($node->biblio_tertiary_title)) {
    $co["rft.series"] = $node->biblio_tertiary_title;
  }

  // issn
  if (!empty($node->biblio_issn)) {
    $co["rft.issn"] = $node->biblio_issn;
  }

  // isbn
  if (!empty($node->biblio_isbn)) {
    $co["rft.isbn"] = $node->biblio_isbn;
  }

  // date (year)
  if (!empty($node->biblio_year)) {
    $co["rft.date"] = $node->biblio_year;
  }

  // volume
  if (!empty($node->biblio_volume)) {
    $co["rft.volume"] = $node->biblio_volume;
  }

  // issue
  if (!empty($node->biblio_issue)) {
    $co["rft.issue"] = $node->biblio_issue;
  }

  // spage, epage, tpages (pages)
  // NOTE: lifted from modsxml.inc.php--should throw some into a new include file
  if (!empty($node->biblio_pages)) {
    if (ereg("[0-9] *- *[0-9]", $node->biblio_pages)) {
      list($pagestart, $pageend) = preg_split('/\\s*[-]\\s*/', $node->biblio_pages);
      if ($pagestart < $pageend) {
        $co["rft.spage"] = $pagestart;
        $co["rft.epage"] = $pageend;
      }
    }
    elseif ($node->biblio_type == 100) {

      //"Book Whole") {
      $pagetotal = preg_replace('/^(\\d+)\\s*pp?\\.?$/', "\\1", $node->biblio_pages);
      $co["rft.tpages"] = $pagetotal;
    }
    else {
      $co["rft.spage"] = $node->biblio_pages;
    }
  }

  // aulast, aufirst, author (author)
  if (!empty($node->biblio_authors)) {
    $author_array = explode(";", $node->biblio_authors);
    $creators = _parse_author_array($author_array);
    if (!empty($creators[0]['last_name'])) {
      $co["rft.aulast"] = $creators[0]['last_name'];
    }
    if (!empty($creators[0]['first_name'])) {
      $co["rft.aufirst"] = $creators[0]['first_name'];
    }
    elseif (!empty($creators[0]['initials'])) {
      $co["rft.aufirst"] = $creators[0]['initials'];
    }

    // TODO: cleanup and put this function in include.inc.php?
    $authorcount = count($creators);
    for ($i = 1; $i < $authorcount; $i++) {
      if (!empty($creators[$i]['last_name'])) {
        $au = $creators[$i]['last_name'];
        if (!empty($creators[$i]['first_name']) || !empty($creators[$i]['initials'])) {
          $au .= ", ";
        }
      }
      if (!empty($creators[$i]['first_name'])) {
        $au .= $creators[$i]['first_name'];
      }
      elseif (!empty($creators[$i]['initials'])) {
        $au .= $creators[$i]['initials'];
      }
      if (!empty($au)) {
        $co["rft.au" . $i] = $au;
      }
    }
  }

  // pub (publisher)
  if (!empty($node->biblio_publisher)) {
    $co["rft.pub"] = $node->biblio_publisher;
  }

  // place
  if (!empty($node->biblio_place_published)) {
    $co["rft.place"] = $node->biblio_place_published;
  }

  // id (doi, url)
  if (!empty($node->biblio_doi)) {
    $co["rft_id"] = "info:doi/" . $node->biblio_doi;
  }
  elseif (!empty($node->biblio_url)) {
    $co["rft_id"] = $node->biblio_url;
  }
  return $co;
}