View source
<?php
function biblio_style_mla_info() {
return array(
'mla' => 'Modern Language Association (MLA)',
);
}
function biblio_style_mla_author_options() {
$author_options = array(
'oldAuthorsInitialsDelim' => ',',
'BetweenAuthorsDelimStandard' => ', ',
'BetweenAuthorsDelimLastAuthor' => ', and ',
'AuthorsInitialsDelimFirstAuthor' => ', ',
'AuthorsInitialsDelimStandard' => ' ',
'betweenInitialsDelim' => '. ',
'initialsBeforeAuthorFirstAuthor' => false,
'initialsBeforeAuthorStandard' => true,
'shortenGivenNames' => FALSE,
'numberOfAuthorsTriggeringEtAl' => 3,
'includeNumberOfAuthors' => 1,
'customStringAfterFirstAuthors' => ', et al.',
'encodeHTML' => true,
);
return $author_options;
}
function biblio_style_mla($node, $base = 'biblio', $inline = false) {
$author_options = biblio_style_mla_author_options();
$authors = theme('biblio_format_authors', $node->biblio_authors, $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)) {
if (!ereg("\\. *\$", $authors)) {
$output .= $authors . ".";
}
else {
$output .= $authors;
}
}
if (!empty($node->title)) {
if (!empty($authors)) {
$output .= " ";
}
$output .= '"';
$link = variable_get('biblio_link_title_url', 0) && !empty($node->biblio_url) ? $node->biblio_url : ($inline ? "{$base}/viewinline/{$node->nid}" : "node/{$node->nid}");
$attrib = variable_get('biblio_links_target_new_window', null) && variable_get('biblio_link_title_url', 0) && !empty($node->biblio_url) ? array(
'target' => '_blank',
) : null;
$output .= l($node->title, $link, $attrib);
if (!ereg("[?!.]\$", $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 (!empty($node->biblio_volume)) {
if (!empty($node->biblio_alternate_title) || !empty($node->biblio_secondary_title)) {
$output .= ".";
}
$output .= " " . $node->biblio_volume;
}
if (!empty($node->biblio_issue)) {
$output .= "." . $node->biblio_issue;
}
if (!empty($node->biblio_year)) {
$output .= " (" . $node->biblio_year . ")";
}
if ($node->online_publication == "yes") {
$today = date("j M. Y");
if (!empty($node->online_citation)) {
if (!empty($node->biblio_volume) || !empty($node->biblio_issue) || !empty($node->biblio_alternate_title) || !empty($node->biblio_secondary_title)) {
$output .= ":";
}
$output .= " " . $node->online_citation;
}
if (!empty($node->doi)) {
if (!empty($node->online_citation) or empty($node->online_citation) and !empty($node->biblio_volume) || !empty($node->biblio_issue) || !empty($node->biblio_alternate_title) || !empty($node->biblio_secondary_title)) {
$output .= ".";
}
if ($encodeHTML) {
$output .= " " . $today . encodeHTML(" <http://dx.doi.org/" . $node->doi . ">");
}
else {
$output .= " " . $today . " <http://dx.doi.org/" . $node->doi . ">";
}
}
elseif (!empty($node->url)) {
if (!empty($node->online_citation) or empty($node->online_citation) and !empty($node->biblio_volume) || !empty($node->biblio_issue) || !empty($node->biblio_alternate_title) || !empty($node->biblio_secondary_title)) {
$output .= ".";
}
if ($encodeHTML) {
$output .= " " . $today . encodeHTML(" <" . $node->url . ">");
}
else {
$output .= " " . $today . " <" . $node->url . ">";
}
}
}
else {
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);
}
}
if (!ereg("\\. *\$", $output)) {
$output .= ".";
}
break;
case 101:
case 103:
if (!empty($authors)) {
if (!ereg("\\. *\$", $authors)) {
$output .= $authors . ".";
}
else {
$output .= $authors;
}
if (!empty($node->title)) {
if (!empty($authors)) {
$output .= " ";
}
$output .= '"<i>';
$link = variable_get('biblio_link_title_url', 0) && !empty($node->biblio_url) ? $node->biblio_url : ($inline ? "{$base}/viewinline/{$node->nid}" : "node/{$node->nid}");
$attrib = variable_get('biblio_links_target_new_window', null) && variable_get('biblio_link_title_url', 0) && !empty($node->biblio_url) ? array(
'target' => '_blank',
) : null;
$output .= l($node->title, $link, $attrib);
$output .= '</i>';
if (!ereg("[?!.]\$", $node->title)) {
$output .= ".";
}
$output .= '"';
}
$publication = ereg_replace("[ \r\n]*\\(Eds?:[^\\)\r\n]*\\)", "", $node->biblio_secondary_title);
if (!empty($publication)) {
$output .= " <i>{$publication}</i>";
}
if (!empty($node->biblio_secondary_authors)) {
$editor_options = array(
'oldAuthorsInitialsDelim' => ',',
'BetweenAuthorsDelimStandard' => ', ',
'BetweenAuthorsDelimLastAuthor' => ', and ',
'AuthorsInitialsDelimFirstAuthor' => ' ',
'AuthorsInitialsDelimStandard' => ' ',
'betweenInitialsDelim' => '. ',
'initialsBeforeAuthorFirstAuthor' => true,
'initialsBeforeAuthorStandard' => true,
'shortenGivenNames' => false,
'numberOfAuthorsTriggeringEtAl' => 3,
'includeNumberOfAuthors' => 1,
'customStringAfterFirstAuthors' => ', et al.',
'encodeHTML' => true,
);
$editor = theme('biblio_format_authors', $node->biblio_secondary_authors, $editor_options, $inline);
if (!ereg("[?!.][ \"" . '</i>' . "]*\$", $output)) {
$output .= ".";
}
if (!empty($node->biblio_secondary_authors) > 1) {
$output .= " Eds. " . $editor;
}
else {
$output .= " Ed. " . $editor;
}
}
if (!empty($node->biblio_edition) && !preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $node->biblio_edition)) {
if (!ereg("[?!.][ \"" . '</i>' . "]*\$", $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("/^(Rev\\.?|Revised)( ed\\.?| edition)?\$/i", $node->biblio_edition)) {
$node->biblio_edition = "Rev.";
}
elseif (preg_match("/^(Abr\\.?|Abridged)( ed\\.?| edition)?\$/i", $node->biblio_edition)) {
$node->biblio_edition = "Abr.";
}
if (!preg_match("/( ed\\.?| edition)\$/i", $node->biblio_edition)) {
$editionSuffix .= " ed.";
}
$output .= " " . $node->biblio_edition . $editionSuffix;
}
if (!empty($node->biblio_volume)) {
if (!ereg("[?!.][ \"" . '</i>' . "]*\$", $output)) {
$output .= ".";
}
$output .= " Vol. " . $node->biblio_volume;
}
if (!empty($node->biblio_alternate_title) or !empty($node->biblio_tertiary_title)) {
if (!ereg("[?!.][ \"" . '</i>' . "]*\$", $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 (!ereg("[?!.][ \"" . '</i>' . "]*\$", $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);
}
if (!ereg("\\. *\$", $output)) {
$output .= ".";
}
}
break;
default:
if (!empty($authors)) {
if (!ereg("\\. *\$", $authors)) {
$output .= $authors . ".";
}
else {
$output .= $authors;
}
}
if (!empty($node->title)) {
if (!empty($authors)) {
$output .= " ";
}
if (!empty($node->thesis)) {
$output .= '"' . $node->title;
if (!ereg("[?!.]\$", $node->title)) {
$output .= ".";
}
$output .= '"';
}
else {
$output .= '<i>';
}
$link = variable_get('biblio_link_title_url', 0) && !empty($node->biblio_url) ? $node->biblio_url : ($inline ? "{$base}/viewinline/{$node->nid}" : "node/{$node->nid}");
$attrib = variable_get('biblio_links_target_new_window', null) && variable_get('biblio_link_title_url', 0) && !empty($node->biblio_url) ? array(
'target' => '_blank',
) : null;
$output .= l($node->title, $link, $attrib);
$output .= '</i>';
}
if (!empty($node->biblio_secondary_authors)) {
$editor_options = array(
'oldAuthorsInitialsDelim' => ',',
'BetweenAuthorsDelimStandard' => ', ',
'BetweenAuthorsDelimLastAuthor' => ', and ',
'AuthorsInitialsDelimFirstAuthor' => ' ',
'AuthorsInitialsDelimStandard' => ' ',
'betweenInitialsDelim' => '. ',
'initialsBeforeAuthorFirstAuthor' => true,
'initialsBeforeAuthorStandard' => true,
'shortenGivenNames' => false,
'numberOfAuthorsTriggeringEtAl' => 3,
'includeNumberOfAuthors' => 1,
'customStringAfterFirstAuthors' => ', et al.',
'encodeHTML' => true,
);
$editor = theme('biblio_format_authors', $node->biblio_secondary_authors, $editor_options, $inline);
if (!ereg("[?!.][ \"" . '</i>' . "]*\$", $output)) {
$output .= ".";
}
if (!empty($node->biblio_secondary_authors)) {
$output .= " Eds. " . $editor;
}
else {
$output .= " Ed. " . $editor;
}
}
if (!empty($node->biblio_edition) && !preg_match("/^(1|1st|first|one)( ed\\.?| edition)?\$/i", $node->biblio_edition)) {
if (!ereg("[?!.][ \"" . '</i>' . "]*\$", $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("/^(Rev\\.?|Revised)( ed\\.?| edition)?\$/i", $node->biblio_edition)) {
$node->biblio_edition = "Rev.";
}
elseif (preg_match("/^(Abr\\.?|Abridged)( ed\\.?| edition)?\$/i", $node->biblio_edition)) {
$node->biblio_edition = "Abr.";
}
if (!preg_match("/( ed\\.?| edition)\$/i", $node->biblio_edition)) {
$editionSuffix .= " ed.";
}
$output .= " " . $node->biblio_edition . $editionSuffix;
}
if (!empty($node->biblio_volume)) {
if (!ereg("[?!.][ \"" . '</i>' . "]*\$", $output)) {
$output .= ".";
}
$output .= " Vol. " . $node->biblio_volume;
}
if (!empty($node->biblio_alternate_title) or !empty($node->biblio_secondary_title)) {
if (!ereg("[?!.][ \"" . '</i>' . "]*\$", $output)) {
$output .= ".";
}
$output .= " ";
if (!empty($node->biblio_alternate_title)) {
$output .= $node->biblio_alternate_title;
}
elseif (!empty($node->biblio_secondary_title)) {
$output .= $node->biblio_secondary_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 (!empty($node->thesis)) {
if (!ereg("[?!.][ \"" . '</i>' . "]*\$", $output)) {
$output .= ".";
}
$output .= " " . $node->thesis;
$output .= ", " . $node->biblio_publisher;
}
else {
if (!ereg("[?!.][ \"" . '</i>' . "]*\$", $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->year)) {
$output .= ", " . $node->year;
}
if ($node->online_publication == "yes") {
$today = date("j M. Y");
if (!empty($node->online_citation)) {
if (!ereg("\\. *\$", $output)) {
$output .= ".";
}
$output .= " " . $node->online_citation;
}
if (!empty($node->doi)) {
if (!ereg("\\. *\$", $output)) {
$output .= ".";
}
if ($encodeHTML) {
$output .= " " . $today . encodeHTML(" <http://dx.doi.org/" . $node->doi . ">");
}
else {
$output .= " " . $today . " <http://dx.doi.org/" . $node->doi . ">";
}
}
elseif (!empty($node->url)) {
if (!ereg("\\. *\$", $output)) {
$output .= ".";
}
if ($encodeHTML) {
$output .= " " . $today . encodeHTML(" <" . $node->url . ">");
}
else {
$output .= " " . $today . " <" . $node->url . ">";
}
}
}
if (!ereg("\\. *\$", $output)) {
$output .= ".";
}
break;
}
return filter_xss($output, biblio_get_allowed_tags());
}