function biblio_style_vancouver in Bibliography Module 7
Same name and namespace in other branches
- 5 biblio_style_vancouver.inc \biblio_style_vancouver()
- 6.2 styles/biblio_style_vancouver.inc \biblio_style_vancouver()
- 6 biblio_style_vancouver.inc \biblio_style_vancouver()
- 7.2 styles/biblio_style_vancouver.inc \biblio_style_vancouver()
File
- styles/biblio_style_vancouver.inc, line 66
- The Vancouver style.
Code
function biblio_style_vancouver($node) {
module_load_include('inc', 'biblio', '/includes/biblio.contributors');
$output = $authors = $editor = '';
$markupPatternsArray = array(
"italic-prefix" => '<i>',
"italic-suffix" => '<\\/i>',
"endash" => '-',
);
$author_options = biblio_style_vancouver_author_options();
$primary_authors = biblio_get_contributor_category($node->biblio_contributors, 1);
$editors = biblio_get_contributor_category($node->biblio_contributors, 2);
if (!empty($primary_authors)) {
$authors = theme('biblio_format_authors', array(
'contributors' => $primary_authors,
'options' => $author_options,
));
}
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 .= '<span class="biblio-title-vancouver">';
$url = biblio_get_title_url_info($node);
$output .= l($node->title, $url['link'], $url['options']);
$output .= "</span>";
if (!preg_match("/[?!.]\$/", $node->title)) {
$output .= ".";
}
}
if (!empty($node->biblio_alternate_title)) {
$output .= " " . preg_replace("/\\./", "", $node->biblio_alternate_title);
}
elseif (!empty($node->biblio_secondary_title)) {
$output .= " " . $node->biblio_secondary_title;
}
if (isset($node->online_publication)) {
$output .= " [Internet]";
}
if (!empty($node->biblio_year)) {
$output .= ". " . $node->biblio_year;
}
if (isset($node->online_publication)) {
$output .= " [cited " . date("Y M j") . "]";
}
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', array(
'orig_page_info' => $node->biblio_pages,
'page_range_delim' => $markupPatternsArray["endash"],
'shorten_page_range_end' => TRUE,
));
}
if (isset($node->online_publication)) {
if (!empty($node->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 .= $node->online_citation;
}
if (!empty($node->doi) || !empty($node->url)) {
if (!empty($node->online_citation) or empty($node->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 .= ".";
}
$output .= " Available from: " . $markupPatternsArray["underline-prefix"];
if (!empty($node->doi)) {
$uri = "http://dx.doi.org/" . $node->doi;
}
else {
$uri = $node->url;
}
if ($encodeHTML) {
$output .= encodeHTML($uri);
}
else {
$output .= $uri;
}
$output .= $markupPatternsArray["underline-suffix"];
}
}
if (!preg_match("/\\. *\$/", $output) and !isset($node->online_publication)) {
$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 .= '<span class="biblio-title-vancouver">';
$url = biblio_get_title_url_info($node);
$output .= l($node->title, $url['link'], $url['options']);
$output .= "</span>";
if (!preg_match("/[?!.]\$/", $node->title)) {
$output .= ".";
}
}
if (!empty($editors)) {
$editor_options = array(
'BetweenAuthorsDelimStandard' => ', ',
'BetweenAuthorsDelimLastAuthor' => ', ',
'AuthorsInitialsDelimFirstAuthor' => ' ',
'AuthorsInitialsDelimStandard' => ' ',
'betweenInitialsDelim' => '',
'initialsBeforeAuthorFirstAuthor' => FALSE,
'initialsBeforeAuthorStandard' => FALSE,
'shortenGivenNames' => TRUE,
'numberOfAuthorsTriggeringEtAl' => 6,
'includeNumberOfAuthors' => 6,
'customStringAfterFirstAuthors' => ' et al.',
'encodeHTML' => TRUE,
);
$editor = theme('biblio_format_authors', array(
'contributors' => $editors,
'options' => $editor_options,
));
$output .= " In: " . $editor . ", ";
if (count($editors) > 1) {
$output .= "editors";
}
else {
$output .= "editor";
}
}
$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 .= " " . $publication;
}
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"], "p. ", "p. ", "", "", "", "", TRUE);
}
$output .= ". " . theme('biblio_page_number', array(
'orig_page_info' => $node->biblio_pages,
'page_range_delim' => $markupPatternsArray["endash"],
'single_page_prefix' => "p. ",
'page_range_prefix' => "p. ",
'shorten_page_range_end' => TRUE,
));
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 .= preg_replace("/\\./", "", $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 .= "vol " . $node->biblio_volume;
}
if (!empty($node->biblio_volume) && !empty($node->biblio_issue)) {
$output .= "; ";
}
if (!empty($node->biblio_issue)) {
$output .= "no " . $node->biblio_issue;
}
$output .= ")";
}
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 .= '<span class="biblio-title-vancouver">';
$url = biblio_get_title_url_info($node);
$output .= l($node->title, $url['link'], $url['options']);
$output .= "</span>";
}
if ($node->type == "Software") {
$output .= " [computer program]";
}
if (isset($node->online_publication) and empty($node->thesis)) {
$output .= " [Internet]";
}
if (!empty($node->biblio_volume) and $node->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 ($node->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 (!empty($editors)) {
$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', array(
'contributors' => $editors,
'options' => $editor_options,
));
if (!preg_match("/[?!.][ \"" . $markupPatternsArray["italic-suffix"] . "]*\$/", $output)) {
$output .= ".";
}
$output .= " " . $editor;
if (count($editors) > 1) {
$output .= ", editors";
}
else {
$output .= ", editor";
}
}
if (!empty($node->thesis)) {
$output .= " [" . $node->thesis;
if (isset($node->online_publication)) {
$output .= " on the Internet]";
}
else {
$output .= "]";
}
}
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 (!empty($node->biblio_year)) {
$output .= " " . $node->biblio_year;
}
if ($node->type == "Software") {
if (!empty($node->biblio_volume)) {
$output .= " " . $node->biblio_volume;
}
if (!empty($node->biblio_issue)) {
$output .= " " . $node->biblio_issue;
}
}
if (isset($node->online_publication)) {
$output .= " [cited " . date("Y M j") . "]";
}
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 .= preg_replace("/\\./", "", $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 .= "vol " . $node->biblio_volume;
}
if (!empty($node->biblio_volume) && !empty($node->biblio_issue)) {
$output .= "; ";
}
if (!empty($node->biblio_issue)) {
$output .= "no " . $node->biblio_issue;
}
$output .= ")";
}
if (isset($node->online_publication) || $node->type == "Software") {
if (!empty($node->online_citation)) {
if (!preg_match("/\\. *\$/", $output)) {
$output .= ".";
}
$output .= $node->online_citation;
}
if (!empty($node->doi) || !empty($node->url)) {
if (!preg_match("/\\. *\$/", $output)) {
$output .= ".";
}
$output .= " Available from: " . $markupPatternsArray["underline-prefix"];
if (!empty($node->doi)) {
$uri = "http://dx.doi.org/" . $node->doi;
}
else {
$uri = $node->url;
}
if ($encodeHTML) {
$output .= encodeHTML($uri);
}
else {
$output .= $uri;
}
$output .= $markupPatternsArray["underline-suffix"];
}
}
if (!preg_match("/\\. *\$/", $output) and !isset($node->online_publication) and $node->type != "Software") {
$output .= ".";
}
break;
}
return filter_xss($output, biblio_get_allowed_tags());
}