View source
<?php
function biblio_style_ama_info() {
return array(
'ama' => 'American Medical Association (AMA)',
);
}
function biblio_style_ama_author_options() {
$author_options = array(
'BetweenAuthorsDelimStandard' => ', ',
'BetweenAuthorsDelimLastAuthor' => ', ',
'AuthorsInitialsDelimFirstAuthor' => ' ',
'AuthorsInitialsDelimStandard' => ' ',
'betweenInitialsDelim' => '',
'initialsBeforeAuthorFirstAuthor' => FALSE,
'initialsBeforeAuthorStandard' => FALSE,
'shortenGivenNames' => TRUE,
'numberOfAuthorsTriggeringEtAl' => 6,
'includeNumberOfAuthors' => 3,
'customStringAfterFirstAuthors' => ', et al.',
'encodeHTML' => TRUE,
);
return $author_options;
}
function biblio_style_ama($node, $base = 'biblio', $inline = FALSE) {
$output = '';
$markupPatternsArray = array(
"italic-prefix" => "<i>",
"italic-suffix" => "<\\/i>",
"endash" => '-',
);
$author_options = biblio_style_ama_author_options();
if (isset($node->biblio_contributors[1])) {
$authors = theme('biblio_format_authors', $node->biblio_contributors[1], $author_options, $inline);
}
if (!empty($node->biblio_citekey) && variable_get('biblio_display_citation_key', 0)) {
$output .= '[' . check_plain($node->biblio_citekey) . '] ';
}
switch ($node->biblio_type) {
case 102:
case 105:
case 106:
if (!empty($authors)) {
$output .= '<span class="biblio-authors">';
$output .= $authors;
if (!preg_match("/\\. *\$/", $authors)) {
$output .= ".";
}
$output .= "</span>";
}
if (!empty($node->title)) {
if (!empty($authors)) {
$output .= " ";
}
$output .= '"';
$output .= '<span class="biblio-title-ama">';
$url = biblio_get_title_url_info($node);
$output .= l($node->title, $url['link'], $url['options']);
$output .= "</span>";
if (!preg_match("/[?!.]\$/", $node->title)) {
$output .= ".";
}
$output .= '"';
}
if (!empty($node->biblio_alternate_title)) {
$output .= " <i>" . $node->biblio_alternate_title . "</i>";
}
elseif (!empty($node->biblio_secondary_title)) {
$output .= " <i>" . $node->biblio_secondary_title . "</i>";
}
if ($node->biblio_type == 105 || $node->biblio_type == 106 and !preg_match("/^\\d+\$/", $node->biblio_volume)) {
if (!empty($node->biblio_volume)) {
$output .= ". " . $node->biblio_volume;
}
if (!empty($node->biblio_issue)) {
$output .= " " . $node->biblio_issue;
}
if (!empty($node->biblio_year)) {
$output .= ", " . $node->biblio_year;
}
}
else {
if (!empty($node->biblio_year)) {
$output .= ". " . $node->biblio_year;
}
if (!empty($node->biblio_volume) || !empty($node->biblio_issue)) {
$output .= ";";
}
if (!empty($node->biblio_volume)) {
$output .= $node->biblio_volume;
}
if (!empty($node->biblio_issue)) {
$output .= "(" . $node->biblio_issue . ")";
}
}
if (!empty($node->biblio_pages)) {
if (!empty($node->biblio_year) || !empty($node->biblio_volume) || !empty($node->biblio_issue) || !empty($node->biblio_alternate_title) || !empty($node->biblio_secondary_title)) {
$output .= ":";
}
$output .= theme_biblio_page_number($node->biblio_pages, $markupPatternsArray["endash"]);
}
if (isset($node->online_publication)) {
$today = date("F j, Y");
if (!empty($row['online_citation'])) {
if (!empty($node->biblio_year) || !empty($node->biblio_volume) || !empty($node->biblio_issue) || !empty($node->biblio_alternate_title) || !empty($node->biblio_secondary_title)) {
if (empty($node->biblio_pages)) {
$output .= ":";
}
else {
$output .= ",";
}
}
$output .= $row['online_citation'];
}
if (!empty($row['doi'])) {
if (!empty($row['online_citation']) or empty($row['online_citation']) and !empty($node->biblio_year) || !empty($node->biblio_volume) || !empty($node->biblio_issue) || !empty($node->biblio_alternate_title) || !empty($node->biblio_secondary_title)) {
$output .= ".";
}
if ($encodeHTML) {
$output .= " " . encodeHTML("http://dx.doi.org/" . $row['doi']) . ". Accessed " . $today;
}
else {
$output .= " " . "http://dx.doi.org/" . $row['doi'] . ". Accessed " . $today;
}
}
elseif (!empty($row['url'])) {
if (!empty($row['online_citation']) or empty($row['online_citation']) and !empty($node->biblio_year) || !empty($node->biblio_volume) || !empty($node->biblio_issue) || !empty($node->biblio_alternate_title) || !empty($node->biblio_secondary_title)) {
$output .= ".";
}
if ($encodeHTML) {
$output .= " " . encodeHTML($row['url']) . ". Accessed " . $today;
}
else {
$output .= " " . $row['url'] . ". Accessed " . $today;
}
}
}
if (!preg_match("/\\. *\$/", $output)) {
$output .= ".";
}
break;
case 101:
case 103:
if (!empty($authors)) {
$output .= '<span class="biblio-authors">';
$output .= $authors;
if (!preg_match("/\\. *\$/", $authors)) {
$output .= ".";
}
$output .= '</span>';
}
if (!empty($node->title)) {
if (!empty($authors)) {
$output .= " ";
}
$output .= '"<i>';
$output .= '<span class="biblio-title-ama">';
$url = biblio_get_title_url_info($node);
$output .= l($node->title, $url['link'], $url['options']);
$output .= "</span>";
$output .= '</i>';
if (!preg_match("/[?!.]\$/", $node->title)) {
$output .= ".";
}
$output .= '"';
}
if (!empty($node->biblio_contributors[2])) {
$editor_options = array(
'BetweenAuthorsDelimStandard' => ', ',
'BetweenAuthorsDelimLastAuthor' => ', ',
'AuthorsInitialsDelimFirstAuthor' => ' ',
'AuthorsInitialsDelimStandard' => ' ',
'betweenInitialsDelim' => '',
'initialsBeforeAuthorFirstAuthor' => FALSE,
'initialsBeforeAuthorStandard' => FALSE,
'shortenGivenNames' => TRUE,
'numberOfAuthorsTriggeringEtAl' => 6,
'includeNumberOfAuthors' => 3,
'customStringAfterFirstAuthors' => ' et al.',
'encodeHTML' => TRUE,
);
$editor = theme('biblio_format_authors', $node->biblio_contributors[2], $editor_options, $inline);
$output .= " In: " . $editor . ", ";
if (count($node->biblio_contributors[2]) > 1) {
$output .= "eds";
}
else {
$output .= "ed";
}
}
$publication = preg_replace("/[ \r\n]*\\(Eds?:[^\\)\r\n]*\\)/", "", $node->biblio_secondary_title);
if (!empty($publication)) {
if (!preg_match("/[?!.] *\$/", $output)) {
$output .= ".";
}
if (empty($editor)) {
$output .= " In:";
}
$output .= " <i>" . $publication . "</i>";
}
if (!empty($node->biblio_volume)) {
if (!preg_match("/[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$/", $output)) {
$output .= ".";
}
$output .= " Vol. " . $node->biblio_volume;
}
if (!empty($node->biblio_edition) && !preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $node->biblio_edition)) {
if (!preg_match("/[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$/", $output)) {
$output .= ".";
}
if (preg_match("/^\\d{1,3}\$/", $node->biblio_edition)) {
if ($node->biblio_edition == "2") {
$editionSuffix = "nd";
}
elseif ($node->biblio_edition == "3") {
$editionSuffix = "rd";
}
else {
$editionSuffix = "th";
}
}
else {
$editionSuffix = "";
}
if (!preg_match("/( ed\\.?| edition)\$/i", $node->biblio_edition)) {
$editionSuffix .= " ed.";
}
$output .= " " . $node->biblio_edition . $editionSuffix;
}
if (!preg_match("/[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$/", $output)) {
$output .= ".";
}
if (!empty($node->biblio_place_published)) {
$output .= " " . $node->biblio_place_published;
}
if (!empty($node->biblio_publisher)) {
if (!empty($node->biblio_place_published)) {
$output .= ":";
}
$output .= " " . $node->biblio_publisher;
}
if (!empty($node->biblio_year)) {
$output .= "; " . $node->biblio_year;
}
if (!empty($node->biblio_pages)) {
$output .= ":" . theme('biblio_page_number', $node->biblio_pages, $markupPatternsArray["endash"]);
}
if (!empty($node->biblio_alternate_title) or !empty($node->biblio_tertiary_title)) {
if (!preg_match("/[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$/", $output)) {
$output .= ".";
}
$output .= " ";
if (!empty($node->biblio_alternate_title)) {
$output .= $node->biblio_alternate_title;
}
elseif (!empty($node->biblio_tertiary_title)) {
$output .= $node->biblio_tertiary_title;
}
if (!empty($node->biblio_volume) || !empty($node->biblio_issue)) {
$output .= " ";
}
if (!empty($node->biblio_volume)) {
$output .= $node->biblio_volume;
}
if (!empty($node->biblio_issue)) {
$output .= "(" . $node->biblio_issue . ")";
}
}
if (!preg_match("/\\. *\$/", $output)) {
$output .= ".";
}
break;
default:
if (!empty($authors)) {
$output .= '<span class="biblio-authors">';
$output .= $authors;
if (!preg_match("/\\. *\$/", $authors)) {
$output .= ".";
}
$output .= '</span>';
}
if (!empty($node->title)) {
if (!empty($authors)) {
$output .= " ";
}
$output .= '<i>';
$output .= '<span class="biblio-title-ama">';
$url = biblio_get_title_url_info($node);
$output .= l($node->title, $url['link'], $url['options']);
$output .= "</span>";
$output .= '</i>';
}
if ($node->biblio_type == "Software") {
$output .= " [computer program]";
}
if (!empty($node->biblio_volume) and $node->biblio_type != "Software") {
if (!preg_match("/[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$/", $output)) {
$output .= ".";
}
$output .= " Vol. " . $node->biblio_volume;
}
if (!empty($node->biblio_edition)) {
if (!preg_match("/[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$/", $output)) {
$output .= ".";
}
if ($row['type'] == "Software") {
$output .= " Version " . $node->biblio_edition;
}
elseif (!preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $node->biblio_edition)) {
if (preg_match("/^\\d{1,3}\$/", $node->biblio_edition)) {
if ($node->biblio_edition == "2") {
$editionSuffix = "nd";
}
elseif ($node->biblio_edition == "3") {
$editionSuffix = "rd";
}
else {
$editionSuffix = "th";
}
}
else {
$editionSuffix = "";
}
if (!preg_match("/( ed\\.?| edition)\$/i", $node->biblio_edition)) {
$editionSuffix .= " ed.";
}
$output .= " " . $node->biblio_edition . $editionSuffix;
}
}
if (count($node->biblio_contributors[2])) {
$editor_options = array(
'BetweenAuthorsDelimStandard' => ', ',
'BetweenAuthorsDelimLastAuthor' => ', ',
'AuthorsInitialsDelimFirstAuthor' => ' ',
'AuthorsInitialsDelimStandard' => ' ',
'betweenInitialsDelim' => '',
'initialsBeforeAuthorFirstAuthor' => FALSE,
'initialsBeforeAuthorStandard' => FALSE,
'shortenGivenNames' => TRUE,
'numberOfAuthorsTriggeringEtAl' => 6,
'includeNumberOfAuthors' => 3,
'customStringAfterFirstAuthors' => ' et al.',
'encodeHTML' => true,
);
$editor = theme('biblio_format_authors', $node->biblio_contributors[2], $editor_options, $inline);
if (!preg_match("/[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$/", $output)) {
$output .= ".";
}
$output .= " " . $editor;
if (count($node->biblio_contributors[2]) > 1) {
$output .= ", eds";
}
else {
$output .= ", ed";
}
}
if (!empty($row['thesis'])) {
$output .= " [" . $row['thesis'] . "]";
}
if (!preg_match("/[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$/", $output)) {
$output .= ".";
}
if (!empty($node->biblio_place_published)) {
$output .= " " . $node->biblio_place_published;
}
if (!empty($node->biblio_publisher)) {
if (!empty($node->biblio_place_published)) {
$output .= ":";
}
$output .= " " . $node->biblio_publisher;
}
$output .= ";";
if ($row['type'] == "Software") {
if (!empty($node->biblio_volume)) {
$output .= " " . $node->biblio_volume;
}
if (!empty($node->biblio_issue)) {
$output .= " " . $node->biblio_issue;
}
$output .= ",";
}
if (!empty($node->biblio_year)) {
$output .= " " . $node->biblio_year;
}
if (!empty($node->biblio_alternate_title) or !empty($node->biblio_tertiary_title)) {
if (!preg_match("/[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$/", $output)) {
$output .= ".";
}
$output .= " ";
if (!empty($node->biblio_alternate_title)) {
$output .= $node->biblio_alternate_title;
}
elseif (!empty($node->biblio_tertiary_title)) {
$output .= $node->biblio_tertiary_title;
}
if (!empty($node->biblio_volume) || !empty($node->biblio_issue)) {
$output .= " ";
}
if (!empty($node->biblio_volume)) {
$output .= $node->biblio_volume;
}
if (!empty($node->biblio_issue)) {
$output .= "(" . $node->biblio_issue . ")";
}
}
if ($row['online_publication'] == "yes" || $row['type'] == "Software") {
$today = date("F j, Y");
if (!empty($row['online_citation'])) {
if (!preg_match("/\\. *\$/", $output)) {
$output .= ".";
}
$output .= $row['online_citation'];
}
if (!empty($row['doi'])) {
if (!preg_match("/\\. *\$/", $output)) {
$output .= ".";
}
if ($encodeHTML) {
$output .= " " . encodeHTML("http://dx.doi.org/" . $row['doi']) . ". Accessed " . $today;
}
else {
$output .= " " . "http://dx.doi.org/" . $row['doi'] . ". Accessed " . $today;
}
}
elseif (!empty($row['url'])) {
if (!preg_match("/\\. *\$/", $output)) {
$output .= ".";
}
if ($encodeHTML) {
$output .= " " . encodeHTML($row['url']) . ". Accessed " . $today;
}
else {
$output .= " " . $row['url'] . ". Accessed " . $today;
}
}
}
if (!preg_match("/\\. *\$/", $output)) {
$output .= ".";
}
break;
}
return filter_xss($output, biblio_get_allowed_tags());
}