You are here

function biblio_contextObject in Bibliography Module 7

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

File

includes/biblio.util.inc, line 80

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;
  $i = 0;

  // $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"] = check_plain($node->title);
    }
    if (!empty($node->biblio_secondary_title)) {
      $co["rft.title"] = check_plain($node->biblio_secondary_title);
      if ($node->biblio_type == 101) {
        $co["rft.btitle"] = check_plain($node->biblio_secondary_title);
      }
    }
  }
  elseif (!empty($node->title)) {
    $co["rft.title"] = check_plain($node->title);
  }
  if ($node->biblio_type == 100 && !empty($node->biblio_secondary_title)) {
    $co["rft.btitle"] = check_plain($node->biblio_secondary_title);
  }

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

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

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

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

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

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

  // Issue.
  if (!empty($node->biblio_issue)) {
    $co["rft.issue"] = check_plain($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 (preg_match("/[0-9] *- *[0-9]/", $node->biblio_pages)) {
      list($pagestart, $pageend) = preg_split('/\\s*[-]\\s*/', $node->biblio_pages);
      if ($pagestart < $pageend) {
        $co["rft.spage"] = check_plain($pagestart);
        $co["rft.epage"] = check_plain($pageend);
      }
    }
    elseif ($node->biblio_type == 100) {
      $pagetotal = preg_replace('/^(\\d+)\\s*pp?\\.?$/', "\\1", $node->biblio_pages);
      $co["rft.tpages"] = check_plain($pagetotal);
    }
    else {
      $co["rft.spage"] = check_plain($node->biblio_pages);
    }
  }

  // aulast, aufirst, author (author)
  if (!empty($node->biblio_contributors)) {
    if (!empty($node->biblio_contributors[0]['lastname'])) {
      $co["rft.aulast"] = check_plain($node->biblio_contributors[0]['lastname']);
    }
    if (!empty($node->biblio_contributors[0]['firstname'])) {
      $co["rft.aufirst"] = check_plain($node->biblio_contributors[0]['firstname']);
    }
    elseif (!empty($node->biblio_contributors[0]['initials'])) {
      $co["rft.auinit"] = check_plain($node->biblio_contributors[0]['initials']);
    }
    for ($i = 1; $i < count($node->biblio_contributors); $i++) {
      $author = $node->biblio_contributors[$i];
      if ($author['auth_category'] == 1) {
        if (!empty($author['lastname'])) {
          $au = $author['lastname'];
          if (!empty($author['firstname']) || !empty($author['initials'])) {
            $au .= ", ";
          }
        }
        if (!empty($author['firstname'])) {
          $au .= $author['firstname'];
        }
        elseif (!empty($author['initials'])) {
          $au .= $author['initials'];
        }
        if (!empty($au)) {
          $co["rft.au" . $i] = $au;
        }
      }
    }
  }

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

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

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

  // Elseif (!empty($node->biblio_url)) {
  //    $co["rft_id"] = $node->biblio_url;
  //  }.
  return $co;
}