| 1 |
<?php
|
| 2 |
|
| 3 |
|
| 4 |
// $Id: biblio_style_apa.inc,v 1.23 2009/06/25 18:23:09 rjerome Exp $
|
| 5 |
/**
|
| 6 |
* Get the style information
|
| 7 |
*
|
| 8 |
* @return
|
| 9 |
* The name of the style
|
| 10 |
*/
|
| 11 |
function biblio_style_apa_info() {
|
| 12 |
return array(
|
| 13 |
'apa' => 'American Psychological Association (APA)'
|
| 14 |
);
|
| 15 |
}
|
| 16 |
|
| 17 |
function biblio_style_apa_author_options() {
|
| 18 |
$author_options = array(
|
| 19 |
'BetweenAuthorsDelimStandard' => ', ', //4
|
| 20 |
'BetweenAuthorsDelimLastAuthor' => ', & ', //5
|
| 21 |
'AuthorsInitialsDelimFirstAuthor' => ', ', //7
|
| 22 |
'AuthorsInitialsDelimStandard' => ' ', //8
|
| 23 |
'betweenInitialsDelim' => '. ', //9
|
| 24 |
'initialsBeforeAuthorFirstAuthor' => FALSE, //10
|
| 25 |
'initialsBeforeAuthorStandard' => TRUE, //11
|
| 26 |
'shortenGivenNames' => FALSE, //12
|
| 27 |
'numberOfAuthorsTriggeringEtAl' => 6, //13
|
| 28 |
'includeNumberOfAuthors' => 6, //14
|
| 29 |
'customStringAfterFirstAuthors' => ', et al.',//15
|
| 30 |
'encodeHTML' => true
|
| 31 |
);
|
| 32 |
return $author_options;
|
| 33 |
}
|
| 34 |
|
| 35 |
/**
|
| 36 |
* Apply a bibliographic style to the node
|
| 37 |
*
|
| 38 |
*
|
| 39 |
* @param $node
|
| 40 |
* An object containing the node data to render
|
| 41 |
* @param $base
|
| 42 |
* The base URL of the biblio module (defaults to /biblio)
|
| 43 |
* @param $inline
|
| 44 |
* A logical value indicating if this is being rendered within the
|
| 45 |
* Drupal framwork (FALSE) or we are just passing back the html (true)
|
| 46 |
* @return
|
| 47 |
* The styled biblio entry
|
| 48 |
*/
|
| 49 |
function biblio_style_apa($node, $base = 'biblio', $inline = FALSE) {
|
| 50 |
$author_options = biblio_style_apa_author_options();
|
| 51 |
$authors = theme('biblio_format_authors', $node->biblio_contributors[1], $author_options, $inline);
|
| 52 |
if (empty($authors) && count($node->biblio_contributors[5])) {// if no authors substitute corp author if available
|
| 53 |
foreach ($node->biblio_contributors[5] as $rank => $author) {
|
| 54 |
$authors .= (empty($authors)) ? '' : ', ';
|
| 55 |
$authors .= (variable_get('biblio_author_links', 1)) ? theme('biblio_author_link',$author['name'], $author['cid'], variable_get('biblio_base', 'biblio'), $inline) : $author['name'];
|
| 56 |
}
|
| 57 |
}
|
| 58 |
if (empty($authors)) $authors = '[' . t('Anonymous') . ']'; // use anonymous if we still have nothing.
|
| 59 |
if (!empty ($node->biblio_citekey)&&(variable_get('biblio_display_citation_key',0))) {
|
| 60 |
$output .= '[' . check_plain($node->biblio_citekey) . '] ';
|
| 61 |
}
|
| 62 |
$output .= '<span class="biblio-authors">' . $authors . "</span> \n";
|
| 63 |
$output .= (strrpos($authors, '.') == strlen($authors)) ? ". " : " ";
|
| 64 |
switch ($node->biblio_type) {
|
| 65 |
case 1 : // Journal Article
|
| 66 |
case 2 : //Conference Paper
|
| 67 |
case 3 : // are all
|
| 68 |
case 4 :
|
| 69 |
case 5 :
|
| 70 |
case 6 :
|
| 71 |
case 7 :
|
| 72 |
case 8 :
|
| 73 |
case 9 :
|
| 74 |
default :
|
| 75 |
if (isset ($node->biblio_year)) {
|
| 76 |
$output .= "(" . check_plain($node->biblio_year) . "). ";
|
| 77 |
}
|
| 78 |
$output .= '<span class="biblio-title">';
|
| 79 |
$url = biblio_get_title_url_info($node);
|
| 80 |
$output .= l($node->title, $url['link'], $url['options']);
|
| 81 |
$output .= ". </span> \n";
|
| 82 |
$output .= !empty ($node->biblio_contributors[2]) ? '(' . theme('biblio_authors', $node->biblio_contributors[2], 'apa', 2, $inline) . ', Ed.).' : "";
|
| 83 |
$output .= ($node->biblio_secondary_title) ? '<u>' . check_plain($node->biblio_secondary_title) . '. ' : '<u>';
|
| 84 |
$output .= ($node->biblio_volume) ? check_plain($node->biblio_volume) . ($node->biblio_issue ? '</u>(' . check_plain($node->biblio_issue) . '), ' : ',</u> ') : '</u> ';
|
| 85 |
// $output .= ($node->biblio_issue) ? '('. check_plain($node->biblio_issue).')' :'';
|
| 86 |
$output .= ($node->biblio_pages) ? check_plain($node->biblio_pages) . '.' : '';
|
| 87 |
break; // generic
|
| 88 |
}
|
| 89 |
/* if ($node->biblio_date) $output .= ', '. check_plain($node->biblio_date);
|
| 90 |
if ($node->biblio_number) $output .= ', Number '. check_plain($node->biblio_number);
|
| 91 |
|
| 92 |
if ($node->biblio_place_published) $output .= ', '. check_plain($node->biblio_place_published);
|
| 93 |
*/
|
| 94 |
return filter_xss($output, biblio_get_allowed_tags());
|
| 95 |
}
|
| 96 |
/**
|
| 97 |
*
|
| 98 |
*/
|
| 99 |
function _apa_format_author($author) {
|
| 100 |
$format = $author['prefix'] . ' ' . $author['lastname'];
|
| 101 |
$format .= !empty ($author['firstname']) ? ' ' . drupal_substr($author['firstname'], 0, 1) . '.' : '';
|
| 102 |
$format .= !empty ($author['initials']) ? $author['initials'] . '.' : '';
|
| 103 |
return $format;
|
| 104 |
}
|