function tripal_pub_create_citation

2.x tripal_pub.pub_citation.inc tripal_pub_create_citation($pub)
3.x tripal_chado.module.DEPRECATED.api.inc tripal_pub_create_citation($pub)
1.x tripal_pub.api.inc tripal_pub_create_citation($pub)

This function generates citations for publications. It requires an array structure with keys being the terms in the Tripal publication ontology. This function is intended to be used for any function that needs to generate a citation.

Parameters

$pub: An array structure containing publication details where the keys are the publication ontology term names and values are the corresponding details. The pub array can contain the following keys with corresponding values:

  • Publication Type: an array of publication types. a publication can have more than one type
  • Authors: a string containing all of the authors of a publication
  • Journal Name: a string containing the journal name
  • Journal Abbreviation: a string containing the journal name abbreviation
  • Series Name: a string containing the series (e.g. conference proceedings) name
  • Series Abbreviation: a string containing the series name abbreviation
  • Volume: the serives volume number
  • Issue: the series issue number
  • Pages: the page numbers for the publication
  • Publication Date: A date in the format "Year Month Day"

Return value

A text string containing the citation

6 calls to tripal_pub_create_citation()
chado_pub_insert in tripal_pub/tripal_pub.module
Implementation of tripal_pub_insert().
chado_pub_update in tripal_pub/tripal_pub.module
chado_pub_validate in tripal_pub/includes/pub_form.inc
tripal_pub_AGL_parse_pubxml in tripal_pub/includes/importers/AGL.inc
tripal_pub_create_citations in tripal_pub/includes/pub_citation.inc

... See full list

File

tripal_pub/api/tripal_pub.api.inc, line 1178
The Tripal Pub API

Code

function tripal_pub_create_citation($pub) {
  $citation = '';
  $pub_type = '';

  // An article may have more than one publication type. For example,
  // a publication type can be 'Journal Article' but also a 'Clinical Trial'.
  // Therefore, we need to select the type that makes most sense for 
  // construction of the citation. Here we'll iterate through them all
  // and select the one that matches best.
  if (is_array($pub['Publication Type'])) {
    foreach ($pub['Publication Type'] as $ptype) {
      if ($ptype == 'Journal Article') {
        $pub_type = $ptype;
        break;
      }
      else if ($ptype == 'Conference Proceedings') {
        $pub_type = $ptype;
        break;
      }
      else if ($ptype == 'Book') {
        $pub_type = $ptype;
        break;
      }
      else if ($ptype == 'Letter') {
        $pub_type = $ptype;
        break;
      }
      else if ($ptype == 'Book Chapter') {
        $pub_type = $ptype;
        break;
      }
      else if ($ptype == "Research Support, Non-U.S. Gov't") {
        $pub_type = $ptype;
        // we don't break because if the article is also a Journal Article
        // we prefer that type
      }
    }
    if (!$pub_type) {
      watchdog('tripal_pub', "Cannot generate citation for publication type: %types", 
      array('%types' => print_r($pub['Publication Type'], TRUE)), WATCHDOG_WARNING);
      return FALSE;
    }
  }
  else {
    $pub_type = $pub['Publication Type'];
  }
  //----------------------
  // Journal Article
  //----------------------
  if ($pub_type == 'Journal Article') {
    $citation = $pub['Authors'] . '. ' . $pub['Title'] . '. ';

    if ($pub['Journal Name']) {
      $citation .= $pub['Journal Name'] . '. ';
    }
    elseif ($pub['Journal Abbreviation']) {
      $citation .= $pub['Journal Abbreviation'] . '. ';
    }
    elseif ($pub['Series Name']) {
      $citation .= $pub['Series Name'] . '. ';
    }
    elseif ($pub['Series Abbreviation']) {
      $citation .= $pub['Series Abbreviation'] . '. ';
    }
    if ($pub['Publication Date']) {
      $citation .= $pub['Publication Date'];
    }
    elseif ($pub['Year']) {
      $citation .= $pub['Year'];
    }
    if ($pub['Volume'] or $pub['Issue'] or $pub['Pages']) {
      $citation .= '; ';
    }
    if ($pub['Volume']) {
      $citation .= $pub['Volume'];
    }
    if ($pub['Issue']) {
      $citation .= '(' . $pub['Issue'] . ')';
    }
    if ($pub['Pages']) {
      if ($pub['Volume']) {
        $citation .= ':';
      }
      $citation .= $pub['Pages'];
    }
    $citation .= '.';
  }
  //----------------------
  // Research Support, Non-U.S. Gov't
  //----------------------
  elseif ($pub_type == "Research Support, Non-U.S. Gov't") {
    $citation = $pub['Authors'] . '. ' . $pub['Title'] . '. ';

    if ($pub['Journal Name']) {
      $citation .= $pub['Journal Name'] . '. ';
    }
    if ($pub['Publication Date']) {
      $citation .= $pub['Publication Date'];
    }
    elseif ($pub['Year']) {
      $citation .= $pub['Year'];
    }
    $citation .= '.';
  }
  //----------------------
  // Letter
  //----------------------
  elseif ($pub_type == 'Letter') {
    $citation = $pub['Authors'] . '. ' . $pub['Title'] . '. ';

    if ($pub['Journal Name']) {
      $citation .= $pub['Journal Name'] . '. ';
    }
    elseif ($pub['Journal Abbreviation']) {
      $citation .= $pub['Journal Abbreviation'] . '. ';
    }
    elseif ($pub['Series Name']) {
      $citation .= $pub['Series Name'] . '. ';
    }
    elseif ($pub['Series Abbreviation']) {
      $citation .= $pub['Series Abbreviation'] . '. ';
    }
    if ($pub['Publication Date']) {
      $citation .= $pub['Publication Date'];
    }
    elseif ($pub['Year']) {
      $citation .= $pub['Year'];
    }
    if ($pub['Volume'] or $pub['Issue'] or $pub['Pages']) {
      $citation .= '; ';
    }
    if ($pub['Volume']) {
      $citation .= $pub['Volume'];
    }
    if ($pub['Issue']) {
      $citation .= '(' . $pub['Issue'] . ')';
    }
    if ($pub['Pages']) {
      if ($pub['Volume']) {
        $citation .= ':';
      }
      $citation .= $pub['Pages'];
    }
    $citation .= '.';
  }
  //----------------------
  // Book
  //----------------------
  elseif ($pub_type == 'Book') {

  }
  //----------------------
  // Book Chapter
  //----------------------
  elseif ($pub_type == 'Book Chapter') {

  }
  //----------------------
  // Conference Proceedings
  //----------------------
  elseif ($pub_type == 'Conference Proceedings') {
    $citation = $pub['Authors'] . '. ' . $pub['Title'] . '. ';

    if ($pub['Conference Name']) {
      $citation .= $pub['Conference Name'] . '. ';
    }
    elseif ($pub['Series Name']) {
      $citation .= $pub['Series Name'] . '. ';
    }
    elseif ($pub['Series Abbreviation']) {
      $citation .= $pub['Series Abbreviation'] . '. ';
    }
    if ($pub['Publication Date']) {
      $citation .= $pub['Publication Date'];
    }
    elseif ($pub['Year']) {
      $citation .= $pub['Year'];
    }
    if ($pub['Volume'] or $pub['Issue'] or $pub['Pages']) {
      $citation .= '; ';
    }
    if ($pub['Volume']) {
      $citation .= $pub['Volume'];
    }
    if ($pub['Issue']) {
      $citation .= '(' . $pub['Issue'] . ')';
    }
    if ($pub['Pages']) {
      if ($pub['Volume']) {
        $citation .= ':';
      }
      $citation .= $pub['Pages'];
    }
    $citation .= '.';
  }

  return $citation;
}