Skip to content

Instantly share code, notes, and snippets.

@windhamdavid
Created April 22, 2013 13:15
Show Gist options
  • Save windhamdavid/5434800 to your computer and use it in GitHub Desktop.
Save windhamdavid/5434800 to your computer and use it in GitHub Desktop.
--- /Users/dwindha/Sites/ndpc/sites/all/modules/biblio/_old-styles/biblio_style_apa copy.inc 2012-01-23 13:14:18.000000000 -0500
+++ /Users/dwindha/Sites/ndpc/sites/all/modules/biblio/_old-styles/biblio_style_apa.inc 2011-09-12 09:55:15.000000000 -0400
@@ -1,6 +1,7 @@
<?php
+// $Id: biblio_style_apa.inc,v 1.9.2.17 2009/09/30 15:48:25 rjerome Exp $
/**
* Get the style information
*
@@ -18,15 +19,15 @@
'BetweenAuthorsDelimStandard' => ', ', //4
'BetweenAuthorsDelimLastAuthor' => ', & ', //5
'AuthorsInitialsDelimFirstAuthor' => ', ', //7
- 'AuthorsInitialsDelimStandard' => ' ', //8
+ 'AuthorsInitialsDelimStandard' => ', ', //8
'betweenInitialsDelim' => '. ', //9
'initialsBeforeAuthorFirstAuthor' => FALSE, //10
- 'initialsBeforeAuthorStandard' => FALSE, //11
+ 'initialsBeforeAuthorStandard' => FALSE, //11
'shortenGivenNames' => TRUE, //12
'numberOfAuthorsTriggeringEtAl' => 6, //13
'includeNumberOfAuthors' => 6, //14
'customStringAfterFirstAuthors' => ', et al.',//15
- 'encodeHTML' => TRUE
+ 'encodeHTML' => true
);
return $author_options;
}
@@ -46,59 +47,281 @@
* The styled biblio entry
*/
function biblio_style_apa($node, $base = 'biblio', $inline = FALSE) {
- $output = '';
$author_options = biblio_style_apa_author_options();
$authors = theme('biblio_format_authors', $node->biblio_contributors[1], $author_options, $inline);
if (empty($authors) && count($node->biblio_contributors[5])) {// if no authors substitute corp author if available
foreach ($node->biblio_contributors[5] as $rank => $author) {
$authors .= (empty($authors)) ? '' : ', ';
- $authors .= (variable_get('biblio_author_links', 1)) ? theme('biblio_author_link', $author) : $author['name'];
+ $authors .= (variable_get('biblio_author_links', 1)) ? theme('biblio_author_link',$author['name'], $author['cid'], variable_get('biblio_base', 'biblio'), $inline) : $author['name'];
}
}
- if (empty($authors)) $authors = '[' . t('Anonymous') . ']'; // use anonymous if we still have nothing.
+ if (empty($authors) && count($node->biblio_contributors[2])) { // if no authors or corp author, substitute editors if available
+ foreach ($node->biblio_contributors[2] as $rank => $author) {
+ $author_options = biblio_style_apa_author_options();
+ $authors = theme('biblio_format_authors', $node->biblio_contributors[2], $author_options, $inline);
+ }
+ $authors .= (count($node->biblio_contributors[2]) > 1) ? ' (Eds.).' : ' (Ed.).';
+ }
+ if (empty($authors)) $authors = ''; // DO NOT use anonymous if we still have no authors - use nothing.
if (!empty ($node->biblio_citekey)&&(variable_get('biblio_display_citation_key',0))) {
$output .= '[' . check_plain($node->biblio_citekey) . '] ';
}
$output .= '<span class="biblio-authors">' . $authors . "</span> \n";
- $output .= (strrpos($authors, '.') == strlen($authors)) ? ".&nbsp;&nbsp;" : " ";
+ if (!empty($authors)) {
+ $output .= (strrpos($authors, '.') == strlen($authors)) ? ".&nbsp;&nbsp;" : " ";
+ }
+
+
switch ($node->biblio_type) {
- case 1 : // Journal Article
- case 2 : //Conference Paper
- case 3 : // are all
- case 4 :
- case 5 :
- case 6 :
- case 7 :
- case 8 :
- case 9 :
- default :
- if (isset ($node->biblio_year)) {
+ case 100 : // Book
+ case 109 : // Report
+ case 1001 : // Booklet
+ if ( !empty($authors) && strlen($node->biblio_year) ) { // year goes before title, if authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ $output .= '<span class="biblio-title"><i>';
+ $url = biblio_get_title_url_info($node);
+ $output .= l($node->title, $url['link'], $url['options']);
+ $output .= "</i>. </span> \n";
+ if ( empty($authors) && strlen($node->biblio_year) ) { // year goes after title, if no authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+
+ $output .= ($node->biblio_secondary_title) ? '<i>' . check_plain($node->biblio_secondary_title) . '</i>. ' : ' ';
+
+ if ($node->biblio_place_published) $output .= check_plain($node->biblio_place_published);
+ if ($node->biblio_place_published && $node->biblio_publisher) $output .= ' : ';
+ if ($node->biblio_publisher) $output .= check_plain($node->biblio_publisher);
+ if ($node->biblio_place_published || $node->biblio_publisher) $output .= '.';
+ $output .= ($node->biblio_access_date) ? ' Retrieved ' . check_plain($node->biblio_access_date) . ($url ? ', from: ' . l(check_plain($node->biblio_url), $url['link'], $url['options']) . '.' : '.') : ' ';
+ break; // 100
+
+ case 101 : // Book Chapter
+ // title = chapter/section/article title
+ // biblio_secondary_title = the book title
+ if ( !empty($authors) && isset ($node->biblio_year) ) { // year goes before title, if authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ $output .= '<span class="biblio-title">';
+ $url = biblio_get_title_url_info($node);
+ $output .= l($node->title, $url['link'], $url['options']);
+ $output .= ". </span> \n";
+ if ( empty($authors) && isset ($node->biblio_year) ) { // year goes after title, if no authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ $book_eds = ''; // editors (authors of book)
+ if (!empty($node->biblio_contributors[2]))
+ {
+ $editor_options = array(
+ 'BetweenAuthorsDelimStandard' => ', ',
+ 'BetweenAuthorsDelimLastAuthor' => ' & ',
+ 'AuthorsInitialsDelimFirstAuthor' => ' ',
+ 'AuthorsInitialsDelimStandard' => ' ',
+ 'betweenInitialsDelim' => '. ',
+ 'initialsBeforeAuthorFirstAuthor' => TRUE,
+ 'initialsBeforeAuthorStandard' => TRUE,
+ 'shortenGivenNames' => TRUE,
+ 'numberOfAuthorsTriggeringEtAl' => 3,
+ 'includeNumberOfAuthors' => 3,
+ 'customStringAfterFirstAuthors' => ' et al.',
+ 'encodeHTML' => true
+ );
+
+ $book_eds = theme('biblio_format_authors', $node->biblio_contributors[2], $editor_options, $inline);
+
+ $book_eds .= (count($node->biblio_contributors[2]) > 1) ? ' (Eds.)' : ' (Ed.)';
+ }
+
+ $output .= ($node->biblio_secondary_title) ? ' In ' . (strlen($book_eds) ? $book_eds . ', ' : '') . ' <i>' . check_plain($node->biblio_secondary_title) . '</i>' . (($node->biblio_pages) ? ' (pp. ' . check_plain($node->biblio_pages) . ').' : '.') : ' ';
+
+ if ($node->biblio_place_published) $output .= ' ' . check_plain($node->biblio_place_published);
+ if ($node->biblio_place_published && $node->biblio_publisher) $output .= ' : ';
+ if ($node->biblio_publisher) $output .= check_plain($node->biblio_publisher);
+ if ($node->biblio_place_published || $node->biblio_publisher) $output .= '.';
+ break; // 101
+
+ case 103 : // Conference Paper
+ // title = paper title
+ // biblio_secondary_title = the conference name
+ // biblio_date = month
+ if ( !empty($authors) && strlen($node->biblio_year) ) { // year goes before title, if authors.
+ $output .= "(" . check_plain($node->biblio_year) . ($node->biblio_date ? ', ' . check_plain($node->biblio_date) : '') .").&nbsp;&nbsp;";
+ }
+ $output .= '<span class="biblio-title"><i>';
+ $url = biblio_get_title_url_info($node);
+ $output .= l($node->title, $url['link'], $url['options']);
+ $output .= "</i>. </span> \n";
+ if ( empty($authors) && strlen($node->biblio_year) ) { // year goes after title, if no authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ $output .= ($node->biblio_secondary_title) ? 'Paper presented at the ' . check_plain($node->biblio_secondary_title) . ', ' : '';
+ if ($node->biblio_place_published) $output .= check_plain($node->biblio_place_published);
+ if ($node->biblio_place_published || $node->biblio_secondary_title) $output .= '.';
+ $output .= ($node->biblio_access_date) ? ' Retrieved ' . check_plain($node->biblio_access_date) . ($url ? ', from: ' . l(check_plain($node->biblio_url), $url['link'], $url['options']) . '.' : '.') : ' ';
+ break; // 103
+
+ case 105 : // Newspaper Article
+ // title = article title
+ // biblio_secondary_title = the newspaper title
+ // biblio_date = issue date
+ if ( !empty($authors) && isset ($node->biblio_year) ) { // year goes before title, if authors.
+ $output .= "(" . check_plain($node->biblio_year) . ($node->biblio_date ? ', ' . check_plain($node->biblio_date) : '') .").&nbsp;&nbsp;";
+ }
+ $output .= '<span class="biblio-title">';
+ $url = biblio_get_title_url_info($node);
+ $output .= l($node->title, $url['link'], $url['options']);
+ $output .= ". </span> \n";
+ if ( empty($authors) && isset ($node->biblio_year) ) { // year goes after title, if no authors.
$output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+
+ $output .= ($node->biblio_secondary_title) ? '<i>' . check_plain($node->biblio_secondary_title) . '</i>' . (($node->biblio_pages) ? ', pp. ' . check_plain($node->biblio_pages) . '.' : '.') : ' ';
+ $output .= ($node->biblio_access_date) ? ' Retrieved ' . check_plain($node->biblio_access_date) . ($url ? ', from: ' . l(check_plain($node->biblio_url), $url['link'], $url['options']) . '.' : '.') : ' ';
+ break; // 105
+
+ case 106 : // Magazine Article
+ // title = article title
+ // biblio_secondary_title = the magazine title
+ // biblio_date = issue date
+ if ( !empty($authors) && isset ($node->biblio_year) ) { // year goes before title, if authors.
+ $output .= "(" . check_plain($node->biblio_year) . ($node->biblio_date ? ', ' . check_plain($node->biblio_date) : '') .").&nbsp;&nbsp;";
}
$output .= '<span class="biblio-title">';
- $url = biblio_get_title_url_info($node, $base, $inline);
+ $url = biblio_get_title_url_info($node);
$output .= l($node->title, $url['link'], $url['options']);
$output .= ". </span> \n";
- $output .= !empty ($node->biblio_contributors[2]) ? '(' . theme('biblio_authors', $node->biblio_contributors[2], 'apa', 2, $inline) . ', Ed.).' : "";
- $output .= ($node->biblio_secondary_title) ? '<u>' . check_plain($node->biblio_secondary_title) . '. ' : '<u>';
- $output .= ($node->biblio_volume) ? check_plain($node->biblio_volume) . ($node->biblio_issue ? '</u>(' . check_plain($node->biblio_issue) . '),&nbsp;' : ',</u> ') : '</u> ';
- // $output .= ($node->biblio_issue) ? '('. check_plain($node->biblio_issue).')' :'';
+ if ( empty($authors) && isset ($node->biblio_year) ) { // year goes after title, if no authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ $output .= ($node->biblio_secondary_title) ? '<i>' . check_plain($node->biblio_secondary_title) . '</i>' : '';
+ $output .= ($node->biblio_volume) ? (($node->biblio_secondary_title) ? ', ' : ' ') . check_plain($node->biblio_volume) . ($node->biblio_issue ? '(' . check_plain($node->biblio_issue) . ')' : '') : '';
+ $output .= ($node->biblio_pages) ? (($node->biblio_volume || $node->biblio_secondary_title) ? ', ' : ' ') . (($node->biblio_volume || $node->biblio_issue) ? '' : 'pp. ') . check_plain($node->biblio_pages) . '.' : '';
+ $output .= ($node->biblio_access_date) ? ' Retrieved ' . check_plain($node->biblio_access_date) . ($url ? ', from: ' . l(check_plain($node->biblio_url), $url['link'], $url['options']) . '.' : '.') : ' ';
+ break; // 106
+
+ case 107 : // Web Article
+ case 125 : // Database
+ if ( !empty($authors) && strlen($node->biblio_year) ) { // year goes before title, if authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ $output .= '<span class="biblio-title"><i>';
+ $url = biblio_get_title_url_info($node);
+ $output .= l($node->title, $url['link'], $url['options']);
+ $output .= "</i>. </span> \n";
+ if ( empty($authors) && strlen($node->biblio_year) ) { // year goes after title, if no authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ // biblio_volume = was access year
+ // biblio number = was access date
+ // biblio_secondary_title = series title
+ $output .= ($node->biblio_secondary_title) ? '<i>' . check_plain($node->biblio_secondary_title) . '</i>. ' : '';
$output .= ($node->biblio_pages) ? check_plain($node->biblio_pages) . '.' : '';
+ // $output .= ($node->biblio_volume) ? 'Retrieved ' . ($node->biblio_number ? check_plain($node->biblio_number) . ', ' : '') . check_plain($node->biblio_volume) . ($url ? ', from: ' . l(check_plain($node->biblio_url), $url['link'], $url['options']) . '.' : '.') : ' ';
+ $output .= ($node->biblio_access_date) ? 'Retrieved ' . check_plain($node->biblio_access_date) . ($url ? ', from: ' . l(check_plain($node->biblio_url), $url['link'], $url['options']) . '.' : '.') : ' ';
+ break; // 107 and 125
+
+ case 114 : // Audiovisual
+ if ( !empty($authors) && strlen($node->biblio_year) ) { // year goes before title, if authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ $output .= '<span class="biblio-title">';
+ $url = biblio_get_title_url_info($node);
+ $output .= l($node->title, $url['link'], $url['options']);
+ $output .= ". </span> \n";
+ if ( empty($authors) && strlen($node->biblio_year) ) { // year goes after title, if no authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+
+ $output .= ($node->biblio_secondary_title) ? '<i>' . check_plain($node->biblio_secondary_title) . '.</i>' : '';
+ $output .= ($node->biblio_volume) ? (($node->biblio_secondary_title) ? ', ' : ' ') . check_plain($node->biblio_volume) . ($node->biblio_issue ? '(' . check_plain($node->biblio_issue) . ')' : '') : '';
+ $output .= ($node->biblio_pages) ? (($node->biblio_volume || $node->biblio_secondary_title) ? ', ' : ' ') . (($node->biblio_volume || $node->biblio_issue) ? '' : 'pp. ') . check_plain($node->biblio_pages) . '.' : '';
+ $output .= ($node->biblio_access_date) ? ' Retrieved ' . check_plain($node->biblio_access_date) . ($url ? ', from: ' . l(check_plain($node->biblio_url), $url['link'], $url['options']) . '.' : '.') : ' ';
+ break; // 114
+
+ case 1003 : // Journal (the periodical as a whole, not an article or issue)
+ if ( !empty($authors) && strlen($node->biblio_year) ) { // year goes before title, if authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ $output .= '<span class="biblio-title"><i>';
+ $url = biblio_get_title_url_info($node);
+ $output .= l($node->title, $url['link'], $url['options']);
+ $output .= "</i>. </span> \n";
+ if ( empty($authors) && strlen($node->biblio_year) ) { // year goes after title, if no authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ // $output .= !empty ($node->biblio_contributors[2]) ? '(' . theme('biblio_authors', $node->biblio_contributors[2], 'apa', 2, $inline) . ', Ed.).' : "";
+
+ $output .= ($node->biblio_secondary_title) ? '<i>' . check_plain($node->biblio_secondary_title) . '</i>' : '';
+ $output .= ($node->biblio_pages) ? (($node->biblio_volume || $node->biblio_secondary_title) ? ', ' : ' ') . (($node->biblio_volume || $node->biblio_issue) ? '' : 'pp. ') . check_plain($node->biblio_pages) . '.' : '';
+ break; // 1003
+
+ case 1004 : // Journal Issue (a specific copy - volume and issue number, not an article)
+ case 1005 : // Newsletter Issue (a specific copy - volume and issue number, not an article)
+ if ( !empty($authors) && strlen($node->biblio_year) ) { // year goes before title, if authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ $output .= '<span class="biblio-title"><i>';
+ $url = biblio_get_title_url_info($node);
+ $output .= l($node->title, $url['link'], $url['options']);
+ $output .= "</i>. </span> \n";
+ if ( empty($authors) && strlen($node->biblio_year) ) { // year goes after title, if no authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ // $output .= !empty ($node->biblio_contributors[2]) ? '(' . theme('biblio_authors', $node->biblio_contributors[2], 'apa', 2, $inline) . ', Ed.).' : "";
+
+ // $output .= ($node->biblio_secondary_title) ? '<i>' . check_plain($node->biblio_secondary_title) . '</i>' : '';
+ // $output .= ($node->biblio_volume) ? (($node->biblio_secondary_title) ? ', ' : ' ') . check_plain($node->biblio_volume) . ($node->biblio_issue ? '(' . check_plain($node->biblio_issue) . ')' : '') : '';
+ // $output .= ($node->biblio_pages) ? (($node->biblio_volume || $node->biblio_secondary_title) ? ', ' : ' ') . (($node->biblio_volume || $node->biblio_issue) ? '' : 'pp. ') . check_plain($node->biblio_pages) . '.' : '';
+ $output .= ($node->biblio_access_date) ? ' Retrieved ' . check_plain($node->biblio_access_date) . ($url ? ', from: ' . l(check_plain($node->biblio_url), $url['link'], $url['options']) . '.' : '.') : ' ';
+ break; // 1004
+
+ default : // Tested for:
+ // 102 Journal Article
+ if ( !empty($authors) && strlen($node->biblio_year) ) { // year goes before title, if authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ $output .= '<span class="biblio-title">';
+ $url = biblio_get_title_url_info($node);
+ $output .= l($node->title, $url['link'], $url['options']);
+ $output .= ". </span> \n";
+ if ( empty($authors) && strlen($node->biblio_year) ) { // year goes after title, if no authors.
+ $output .= "(" . check_plain($node->biblio_year) . ").&nbsp;&nbsp;";
+ }
+ // $output .= !empty ($node->biblio_contributors[2]) ? '(' . theme('biblio_authors', $node->biblio_contributors[2], 'apa', 2, $inline) . ', Ed.).' : "";
+
+ $output .= ($node->biblio_secondary_title) ? '<i>' . check_plain($node->biblio_secondary_title) . '</i>' : '';
+ $output .= ($node->biblio_volume) ? (($node->biblio_secondary_title) ? ', ' : ' ') . check_plain($node->biblio_volume) . ($node->biblio_issue ? '(' . check_plain($node->biblio_issue) . ')' : '') : '';
+ $output .= ($node->biblio_pages) ? (($node->biblio_volume || $node->biblio_secondary_title) ? ', ' : ' ') . (($node->biblio_volume || $node->biblio_issue) ? '' : 'pp. ') . check_plain($node->biblio_pages) . '.' : '';
+ $output .= ($node->biblio_access_date) ? ' Retrieved ' . check_plain($node->biblio_access_date) . ($url ? ', from: ' . l(check_plain($node->biblio_url), $url['link'], $url['options']) . '.' : '.') : ' ';
break; // generic
}
+
+
/* if ($node->biblio_date) $output .= ', '. check_plain($node->biblio_date);
if ($node->biblio_number) $output .= ', Number '. check_plain($node->biblio_number);
- if ($node->biblio_place_published) $output .= ', '. check_plain($node->biblio_place_published);
+
*/
return filter_xss($output, biblio_get_allowed_tags());
}
/**
*
*/
+//function _apa_format_author($author) {
+// $format = $author['prefix'] . ' ' . $author['lastname'];
+// $format .= !empty ($author['firstname']) ? ' ' . drupal_substr($author['firstname'], 0, 1) . '.' : '';
+// $format .= !empty ($author['initials']) ? $author['initials'] . '.' : '';
+// return $format;
+//}
+
function _apa_format_author($author) {
- $format = $author['prefix'] . ' ' . $author['lastname'];
- $format .= !empty ($author['firstname']) ? ' ' . drupal_substr($author['firstname'], 0, 1) . '.' : '';
- $format .= !empty ($author['initials']) ? $author['initials'] . '.' : '';
+ $format = $author['prefix'] . ' ' . $author['lastname'] . ', ';
+ $format .= !empty ($author['firstname']) ? ' ' . substr($author['firstname'], 0, 1) . '.' : '';
+ $format .= !empty ($author['initials']) ? ' ' . substr($author['initials'], 0, 1) . '.' : '';
+ $format .= (strlen($author['initials']) > 1) ? ' ' . substr($author['initials'], 2, 1) . '.' : '';
+ $format .= (strlen($author['initials']) > 3) ? ' ' . substr($author['initials'], 4, 1) . '.' : '';
+
+ if ($author['prefix'] == 'al.et') $format = "et al.";
return $format;
-}
\ No newline at end of file
+}
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment